diff options
author | Robin Stocker <robin@nibor.org> | 2012-10-28 15:57:43 +0100 |
---|---|---|
committer | Chris Aniszczyk <zx@twitter.com> | 2012-11-01 10:47:10 -0700 |
commit | de2455af678b5c9d0111336daed1ca0e0958ca01 (patch) | |
tree | f608f31deba41a70e512ec6459c515f1d307dfdd /org.eclipse.jgit.test/tst/org/eclipse | |
parent | 3f1d56d6b7105eec88eea59730a5d78f668df179 (diff) | |
download | jgit-de2455af678b5c9d0111336daed1ca0e0958ca01.tar.gz jgit-de2455af678b5c9d0111336daed1ca0e0958ca01.zip |
ResetCommand: Use DirCacheBuilder in resetIndex
With bug 391855, DirCacheEditor's PathEdit will be applied for each
stage. For an unmerged path, this would result in 3 equal entries for
the same path.
By using a DirCacheBuilder, the code is simpler and does not have the
above problem with unmerged paths.
Bug: 391860
Change-Id: I785deeaeb8474f8c7a7fbc9ef00d3131fac87e41
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java index 3b0e7bd935..dd6fc67c7b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java @@ -257,6 +257,36 @@ public class ResetCommandTest extends RepositoryTestCase { } @Test + public void testMixedResetWithUnmerged() throws Exception { + git = new Git(db); + + String file = "a.txt"; + writeTrashFile(file, "data"); + String file2 = "b.txt"; + writeTrashFile(file2, "data"); + + git.add().addFilepattern(file).addFilepattern(file2).call(); + git.commit().setMessage("commit").call(); + + DirCache index = db.lockDirCache(); + DirCacheBuilder builder = index.builder(); + builder.add(createEntry(file, FileMode.REGULAR_FILE, 1, "")); + builder.add(createEntry(file, FileMode.REGULAR_FILE, 2, "")); + builder.add(createEntry(file, FileMode.REGULAR_FILE, 3, "")); + assertTrue(builder.commit()); + + assertEquals("[a.txt, mode:100644, stage:1]" + + "[a.txt, mode:100644, stage:2]" + + "[a.txt, mode:100644, stage:3]", + indexState(0)); + + git.reset().setMode(ResetType.MIXED).call(); + + assertEquals("[a.txt, mode:100644]" + "[b.txt, mode:100644]", + indexState(0)); + } + + @Test public void testPathsReset() throws Exception { setupRepository(); |