-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Bit of an oddball problem. I suspect #2746 Might be related. Found the issue using nodegit, but I've dug through the code and it's definitely happening at the libgit2 level.
I have a project which clones another project. We'll call them parent and child. Both being git repositories, they each have a gitignore. The parent explicitly ignores the subrepository path, without a trailing slash.
parent's gitignore (relative path to root of parent: ./.gitignore)
someSubDir/child
child's gitignore (relative path to root of parent: ./someSubDir/child/.gitignore)
/otherDir/**/*.json
!/otherDir/input/*.json
if i call git_index_add_all in the parent, using a wildcard pathspec (['*'] essentially) the entire contents of someSubDir/child/otherDir get added, unlike git add ..
Removing the negated dir in the sub repo fixes it (hence why i pointed out that PR).
Appending a / to the directory in the parent gitignore fixes it.
Removing the leading / on the child or adding one to the parent has no effect. Git cli in general ignores anything to do with the subrepo in this case. I suspect the lack of a trailing slash is the culprit here, allowing the child .gitignore to even be interpreted at all (it should just be out of the picture, if it's ignored no?)
Workaround is to get the status and add everything in the status to the index (or the pathspec). Not ideal, but it works in the meantime.