diff options
author | Robin Stocker <robin@nibor.org> | 2012-10-28 15:35:21 +0100 |
---|---|---|
committer | Chris Aniszczyk <zx@twitter.com> | 2012-11-01 10:33:50 -0700 |
commit | 3f1d56d6b7105eec88eea59730a5d78f668df179 (patch) | |
tree | 85998a8ca422164e5ffad6c7ddfede4de38225e8 /org.eclipse.jgit.test/tst/org/eclipse | |
parent | 8acaae802c8908712663b0c21b7b09ac602ecb1d (diff) | |
download | jgit-3f1d56d6b7105eec88eea59730a5d78f668df179.tar.gz jgit-3f1d56d6b7105eec88eea59730a5d78f668df179.zip |
ResetCommand: Correctly reset unmerged paths in resetIndexForPaths
The previous implementation used a PathEdit, which does not reset the
stage of the entry.
Bug: 391860
Change-Id: If26d3a35abfee85424ad69de724f06a28b6e9efb
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 | 32 |
1 files changed, 32 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 8f2e54388b..3b0e7bd935 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 @@ -58,9 +58,11 @@ import org.eclipse.jgit.api.ResetCommand.ResetType; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.dircache.DirCache; +import org.eclipse.jgit.dircache.DirCacheBuilder; import org.eclipse.jgit.dircache.DirCacheEntry; import org.eclipse.jgit.errors.AmbiguousObjectException; import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.lib.FileMode; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.RepositoryTestCase; import org.eclipse.jgit.revwalk.RevCommit; @@ -342,6 +344,36 @@ public class ResetCommandTest extends RepositoryTestCase { } @Test + public void testPathsResetWithUnmerged() throws Exception { + setupRepository(); + + String file = "a.txt"; + writeTrashFile(file, "data"); + + git.add().addFilepattern(file).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, "")); + builder.add(createEntry("b.txt", FileMode.REGULAR_FILE)); + assertTrue(builder.commit()); + + assertEquals("[a.txt, mode:100644, stage:1]" + + "[a.txt, mode:100644, stage:2]" + + "[a.txt, mode:100644, stage:3]" + + "[b.txt, mode:100644]", + indexState(0)); + + git.reset().addPath(file).call(); + + assertEquals("[a.txt, mode:100644]" + "[b.txt, mode:100644]", + indexState(0)); + } + + @Test public void testHardResetOnTag() throws Exception { setupRepository(); String tagName = "initialtag"; |