From d80a01e6a0035ee7949486324c342d0383ec0e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Mon, 3 Sep 2018 23:22:31 +0200 Subject: [PATCH] Extend ResetCommandTest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../tst/org/eclipse/jgit/api/ResetCommandTest.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 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 2b97b307b..9b12011aa 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 @@ -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();