]> source.dussan.org Git - jgit.git/commitdiff
Extend ResetCommandTest 88/128588/2
authorRené Scheibe <rene.scheibe@gmail.com>
Mon, 3 Sep 2018 21:22:31 +0000 (23:22 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 5 Sep 2018 19:32:11 +0000 (15:32 -0400)
Also check that reflog is enabled by default.
Also check that a file in a folder is reset correctly.

Change-Id: I4bc6649928ce10d7b558901e465e8032b083ade0
Signed-off-by: René Scheibe <rene.scheibe@gmail.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java

index 2b97b307bf153adfc72a81bb1e3ddbc472549c7b..9b12011aabe86be0b682b6f18fdbbb9477af8185 100644 (file)
@@ -82,6 +82,8 @@ public class ResetCommandTest extends RepositoryTestCase {
 
        private File indexFile;
 
+       private File indexNestedFile;
+
        private File untrackedFile;
 
        private DirCacheEntry prestage;
@@ -97,7 +99,7 @@ public class ResetCommandTest extends RepositoryTestCase {
                indexFile = writeTrashFile("a.txt", "content");
 
                // create nested file
-               writeTrashFile("dir/b.txt", "content");
+               indexNestedFile = writeTrashFile("dir/b.txt", "content");
 
                // add files and commit them
                git.add().addFilepattern("a.txt").addFilepattern("dir/b.txt").call();
@@ -119,13 +121,16 @@ public class ResetCommandTest extends RepositoryTestCase {
                        AmbiguousObjectException, IOException, GitAPIException {
                setupRepository();
                ObjectId prevHead = db.resolve(Constants.HEAD);
-               assertSameAsHead(git.reset().setMode(ResetType.HARD)
+               ResetCommand reset = git.reset();
+               assertSameAsHead(reset.setMode(ResetType.HARD)
                                .setRef(initialCommit.getName()).call());
+               assertFalse("reflog should be enabled", reset.isReflogDisabled());
                // check if HEAD points to initial commit now
                ObjectId head = db.resolve(Constants.HEAD);
                assertEquals(initialCommit, head);
                // check if files were removed
                assertFalse(indexFile.exists());
+               assertFalse(indexNestedFile.exists());
                assertTrue(untrackedFile.exists());
                // fileInIndex must no longer be in HEAD and in the index
                String fileInIndexPath = indexFile.getAbsolutePath();
@@ -148,6 +153,7 @@ public class ResetCommandTest extends RepositoryTestCase {
                assertEquals(initialCommit, head);
                // check if files were removed
                assertFalse(indexFile.exists());
+               assertFalse(indexNestedFile.exists());
                assertTrue(untrackedFile.exists());
                // fileInIndex must no longer be in HEAD and in the index
                String fileInIndexPath = indexFile.getAbsolutePath();