diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2014-11-06 19:01:23 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2014-11-06 15:27:46 -0500 |
commit | 8456927b1bbb344cc6a768b1f491dddd50d4ce7c (patch) | |
tree | bf02328525243eb8dbb3490180f188a8d8684897 /org.eclipse.jgit.test | |
parent | abb57e6b5674b7251bd94b7238e5d995ad9c30c5 (diff) | |
download | jgit-8456927b1bbb344cc6a768b1f491dddd50d4ce7c.tar.gz jgit-8456927b1bbb344cc6a768b1f491dddd50d4ce7c.zip |
Make sure checkout doesn't report conflicts on ignored paths
In a situation where a certain path was ignored but a working tree file
with this path existed jgit didn't allow to checkout a branch which
didn't ignore this path but contained different content. JGit considered
this to be a checkout conflict to prevent overwriting the file in the
working tree and raised an error. This commit fixes this by ensuring
that ignored dirty working tree files don't lead to a checkout conflict.
Bug: 450169
Change-Id: I90288d314ffac73c24a9c70a5181f8243bd4679a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java index f7e6fa9b79..48debae932 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java @@ -986,6 +986,38 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { } @Test + public void testOverwriteUntrackedIgnoredFile() throws IOException, + GitAPIException { + String fname="file.txt"; + Git git = Git.wrap(db); + + // Add a file + writeTrashFile(fname, "a"); + git.add().addFilepattern(fname).call(); + git.commit().setMessage("create file").call(); + + // Create branch + git.branchCreate().setName("side").call(); + + // Modify file + writeTrashFile(fname, "b"); + git.add().addFilepattern(fname).call(); + git.commit().setMessage("modify file").call(); + + // Switch branches + git.checkout().setName("side").call(); + git.rm().addFilepattern(fname).call(); + writeTrashFile(".gitignore", fname); + git.add().addFilepattern(".gitignore").call(); + git.commit().setMessage("delete and ignore file").call(); + + writeTrashFile(fname, "Something different"); + git.checkout().setName("master").call(); + assertWorkDir(mkmap(fname, "b")); + assertTrue(git.status().call().isClean()); + } + + @Test public void testFileModeChangeWithNoContentChangeUpdate() throws Exception { if (!FS.DETECTED.supportsExecute()) return; |