From 2bbe15abd412d62a6d5a9ccddda73920943cb6f0 Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Wed, 2 Aug 2017 10:39:27 -0400 Subject: ReflogWriter: Align auto-creation defaults with C git Per git-config(1), core.logAllRefUpdates auto-creates reflogs for HEAD and for refs under heads, notes, tags, and for HEAD. Add notes and remove stash from ReflogWriter#shouldAutoCreateLog. Explicitly force writing reflogs for refs/stash at call sites, now that this is supported. Change-Id: I3a46d2c2703b7c243e0ee2bbf6948279800c485c --- .../org/eclipse/jgit/api/StashListCommandTest.java | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/api') diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashListCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashListCommandTest.java index a7e0ab9f51..d658a53942 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashListCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashListCommandTest.java @@ -51,6 +51,7 @@ import java.util.Iterator; import org.eclipse.jgit.junit.RepositoryTestCase; import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.RefUpdate; import org.eclipse.jgit.lib.RefUpdate.Result; import org.eclipse.jgit.revwalk.RevCommit; @@ -94,9 +95,7 @@ public class StashListCommandTest extends RepositoryTestCase { git.add().addFilepattern("file.txt").call(); RevCommit commit = git.commit().setMessage("create file").call(); - RefUpdate update = db.updateRef(Constants.R_STASH); - update.setNewObjectId(commit); - assertEquals(Result.NEW, update.update()); + assertEquals(Result.NEW, newStashUpdate(commit).update()); StashListCommand command = git.stashList(); Collection stashed = command.call(); @@ -117,13 +116,8 @@ public class StashListCommandTest extends RepositoryTestCase { git.add().addFilepattern("file.txt").call(); RevCommit commit2 = git.commit().setMessage("edit file").call(); - RefUpdate create = db.updateRef(Constants.R_STASH); - create.setNewObjectId(commit1); - assertEquals(Result.NEW, create.update()); - - RefUpdate update = db.updateRef(Constants.R_STASH); - update.setNewObjectId(commit2); - assertEquals(Result.FAST_FORWARD, update.update()); + assertEquals(Result.NEW, newStashUpdate(commit1).update()); + assertEquals(Result.FAST_FORWARD, newStashUpdate(commit2).update()); StashListCommand command = git.stashList(); Collection stashed = command.call(); @@ -133,4 +127,11 @@ public class StashListCommandTest extends RepositoryTestCase { assertEquals(commit2, iter.next()); assertEquals(commit1, iter.next()); } + + private RefUpdate newStashUpdate(ObjectId newId) throws Exception { + RefUpdate ru = db.updateRef(Constants.R_STASH); + ru.setNewObjectId(newId); + ru.setForceRefLog(true); + return ru; + } } -- cgit v1.2.3