Skip to content

calculating convenient patches locks files without autocrlf #877

Description

@implausible

When calculating patches for a diff of the working directory, if autocrlf is unset or false, the libgit2 creates a file lock for all patches until the patches are freed.

Unfortunately, @srajko and I were working on this issue today and uncovered the fact that we are also not freeing objects that libgit 2 creates for us that libgit2 wants us to free. This means that when patches are created, even after the reference to the javascript object is GCd, the patch and associated handle exist out in heap land.

Due to this problem, it is necessary that we specify in our descriptor objects that need to be freed in the GC process. I have a branch https://github.com/nodegit/nodegit/tree/free-raw-on-demand which begins the implementation of that. The branch also starts introducing the ability to free raw objects while in javascript.

The mechanisms for freeing the resources would also need to be templated out such that if we declare in javascript, free this object, the object should now return 'not allocated' errors or we should specify some other means of emptying the object.

Interestingly enough, since this error affects patches, which are directly linked to the hunks of the diff, I am also proposing that we move the convenience classes for patches, lines, and hunks into a manual C++ template. The reasoning behind this is that at the time that patches are calculated, it is possible to transfer all of that data into a single object that is not locking any files via libgit2. This convenience wrapper would discard all libgit2 references and purely represent the diff data. This means that our convenience class can serve that data to javascript land faster and more conveniently.

Looking for opinions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions