diff options
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/lib')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java | 30 |
1 files changed, 30 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 9fb4b3e17d..8c3f6f37c3 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 @@ -47,6 +47,7 @@ import java.util.Map; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.MergeResult.MergeStatus; +import org.eclipse.jgit.api.ResetCommand.ResetType; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.NoFilepatternException; import org.eclipse.jgit.dircache.DirCache; @@ -147,6 +148,35 @@ public class DirCacheCheckoutTest extends ReadTreeTest { "h()", "untracked", "untracked")); } + /** + * Reset hard from unclean condition. + * <p> + * WorkDir: Empty <br/> + * Index: f/g <br/> + * Merge: x + * + * @throws Exception + */ + @Test + public void testResetHardFromIndexEntryWithoutFileToTreeWithoutFile() + throws Exception { + Git git = new Git(db); + writeTrashFile("x", "x"); + git.add().addFilepattern("x").call(); + RevCommit id1 = git.commit().setMessage("c1").call(); + + writeTrashFile("f/g", "f/g"); + git.rm().addFilepattern("x").call(); + git.add().addFilepattern("f/g").call(); + git.commit().setMessage("c2").call(); + deleteTrashFile("f/g"); + deleteTrashFile("f"); + + // The actual test + git.reset().setMode(ResetType.HARD).setRef(id1.getName()).call(); + assertIndex(mkmap("x", "x")); + } + private DirCacheCheckout resetHard(RevCommit commit) throws NoWorkTreeException, CorruptObjectException, IOException { |