C git apparently resolves a relative path in core.excludesFile against the repository worktree root, whereas JGit resolves it against the current directory. Witness:
~/tmp $ mkdir exclusiontest
~/tmp $ cd exclusiontest
~/tmp/exclusiontest $ git init
Initialized empty Git repository in C:/Users/THWO/tmp/exclusiontest/.git/
~/tmp/exclusiontest (master) $ mkdir sub
~/tmp/exclusiontest (master) $ echo "ignoring" > sub/myexclusions
~/tmp/exclusiontest (master) $ echo -e '\texcludesFile = sub/myexclusions' >> .git/config
~/tmp/exclusiontest (master) $ cat .git/config
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
excludesFile = sub/myexclusions
~/tmp/exclusiontest (master) $ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
sub/
nothing added to commit but untracked files present (use "git add" to track)
~/tmp/exclusiontest (master) $ echo "foo" > foo
~/tmp/exclusiontest (master) $ echo "foo" > ignoring
~/tmp/exclusiontest (master) $ echo "foo" > sub/foo
~/tmp/exclusiontest (master) $ echo "foo" > sub/ignoring
~/tmp/exclusiontest (master) $ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
foo
sub/
nothing added to commit but untracked files present (use "git add" to track)
~/tmp/exclusiontest (master) $ cd sub
~/tmp/exclusiontest/sub (master) $ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
../foo
./
nothing added to commit but untracked files present (use "git add" to track)
~/tmp/exclusiontest/sub (master) $ git ls-files --exclude-standard -oi | git check-ignore -vn --stdin
sub/myexclusions:1:ignoring ignoring
~/tmp/exclusiontest/sub (master) $ cd ..
~/tmp/exclusiontest (master) $ git ls-files --exclude-standard -oi | git check-ignore -vn --stdin
sub/myexclusions:1:ignoring ignoring
sub/myexclusions:1:ignoring sub/ignoring
~/tmp/exclusiontest (master) $ jgit-7.7.1 status
Picked up _JAVA_OPTIONS: -Duser.language=en
On branch master
Untracked files:
foo
sub/foo
sub/myexclusions
~/tmp/exclusiontest (master) $ cd sub
~/tmp/exclusiontest/sub (master) $ jgit-7.7.1 status
Picked up _JAVA_OPTIONS: -Duser.language=en
On branch master
Untracked files:
foo
ignoring
sub/foo
sub/ignoring
sub/myexclusions
~/tmp/exclusiontest/sub (master) $
Expected: JGit resolves a relative path the same way C git does; i.e., against the repository worktree root.
Note: I set core.excludesFile here in .git/config, but the behavior is the same if you use ~/.gitconfig instead.
C git apparently resolves a relative path in core.excludesFile against the repository worktree root, whereas JGit resolves it against the current directory. Witness:
Expected: JGit resolves a relative path the same way C git does; i.e., against the repository worktree root.
Note: I set
core.excludesFilehere in .git/config, but the behavior is the same if you use ~/.gitconfig instead.