diff options
author | Thomas Wolf <twolf@apache.org> | 2023-06-15 22:08:06 +0200 |
---|---|---|
committer | Thomas Wolf <twolf@apache.org> | 2023-06-19 08:19:29 +0200 |
commit | faefa90f990858db7bec199501cb37f2631c43d0 (patch) | |
tree | 0a0500f2e2cd11b8582ee01a4582f5dcaa756bc2 /org.eclipse.jgit.junit.ssh | |
parent | 7b955048eb86e1c12114554beacb27b329252b15 (diff) | |
download | jgit-faefa90f990858db7bec199501cb37f2631c43d0.tar.gz jgit-faefa90f990858db7bec199501cb37f2631c43d0.zip |
Default for global (user) git ignore file
C git has a default for git config core.excludesfile: "Its default
value is $XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either
not set or empty, $HOME/.config/git/ignore is used instead." [1]
Implement this in the WorkingTreeIterator$RootIgnoreNode.
To make this testable, mock the "user.home" directory for all JGit
tests, otherwise tests might pick up a real user's git ignore file.
Also ensure that JGit code always reads "user.home" via the
SystemReader.
Add tests for both locations.
[1] https://git-scm.com/docs/gitignore#_description
Bug: 436127
Change-Id: Ie510259320286c3c13a6464a37da1bd9ca1e373a
Signed-off-by: Thomas Wolf <twolf@apache.org>
Diffstat (limited to 'org.eclipse.jgit.junit.ssh')
-rw-r--r-- | org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestHarness.java | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestHarness.java b/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestHarness.java index 6fa30d7e1e..b183b22603 100644 --- a/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestHarness.java +++ b/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestHarness.java @@ -89,8 +89,6 @@ public abstract class SshTestHarness extends RepositoryTestCase { protected File knownHosts; - private File homeDir; - @Override public void setUp() throws Exception { super.setUp(); @@ -99,13 +97,8 @@ public abstract class SshTestHarness extends RepositoryTestCase { git.add().addFilepattern("file.txt").call(); git.commit().setMessage("Initial commit").call(); } - mockSystemReader.setProperty("user.home", - getTemporaryDirectory().getAbsolutePath()); - mockSystemReader.setProperty("HOME", - getTemporaryDirectory().getAbsolutePath()); - homeDir = FS.DETECTED.userHome(); - FS.DETECTED.setUserHome(getTemporaryDirectory().getAbsoluteFile()); - sshDir = new File(getTemporaryDirectory(), ".ssh"); + // The home directory is mocked here + sshDir = new File(FS.DETECTED.userHome(), ".ssh"); assertTrue(sshDir.mkdir()); File serverDir = new File(getTemporaryDirectory(), "srv"); assertTrue(serverDir.mkdir()); @@ -236,7 +229,6 @@ public abstract class SshTestHarness extends RepositoryTestCase { server.stop(); server = null; } - FS.DETECTED.setUserHome(homeDir); SshSessionFactory.setInstance(null); factory = null; } |