Community
Participate
Working Groups
SUMMARY: The order of precedence is incorrect and does not match git's documentation: https://git-scm.com/docs/gitignore Specifically, the .git/info/exclude should have a lower precedence over any .gitignore files. However this is not the case when a .gitignore file is present under a directory inside a repo. SETUP: mydir/myfile: """ This is my test file """ .git/info/exclude: """ mydir/myfile """ .gitignore """ !mydir/myfile """ EXPECTED: myfile should not be ignored ACTUAL: myfile is ignored LIKELY PROBLEM: WorkingTreeIterator.RootIgnoreNode.load(): In this method, we load the CWD's ".gitignore" file, then the "exclude" file(s) which seems reasonable. However, in WorkingTreeIterator, we check the IgnoreNode for the current path (mydir/), then the parent's IgnoreNode (.) causing this sequence of precedence from highest to lowest: mydir/.gitignore .git/info/exclude (Wrong, should not be checked now) .gitignore .git/info/exclude
I can confirm this bug, but the "likely problem" is off. (There is not even a "mydir/.gitignore" in the test setup.) JGit correctly loads and considers the info/exclude only once. The problem is that inside RootIgnoreNode, it appends all rules to the same list. It behaves as if there was no info/exclude but only a single .gitignore with entries !mydir/myfile mydir/myfile and ends up ignoring the file. This needs to be split really into different nodes in a hierarchy.
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/194738
Gerrit change https://git.eclipse.org/r/c/jgit/jgit/+/194738 was merged to [master]. Commit: http://git.eclipse.org/c/jgit/jgit.git/commit/?id=a1ce9063fbcafbc306f40f6d384d48726de09da4