diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2019-10-02 17:33:43 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-10-07 16:07:47 +0200 |
commit | b87f1259d679c7af83b7fd1ab148c99c613beaf0 (patch) | |
tree | abbee6c895b0a38d918e65b16c123003ca28b60c /org.eclipse.jgit.test | |
parent | d0adf52df8ac83c8d5f49e3eddafb95b51a42fbc (diff) | |
download | jgit-b87f1259d679c7af83b7fd1ab148c99c613beaf0.tar.gz jgit-b87f1259d679c7af83b7fd1ab148c99c613beaf0.zip |
Fix parsing of core.logAllRefUpdates
Also correctly parse the "always" value (allowed in canonical git
since git 2.12.0[1]). Adapt the ReflogWriter.
[1] https://github.com/git/git/commit/341fb2862
Bug: 551664
Change-Id: I051c76ca355a2ac8d6092de65f44b18bf9aeb125
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogConfigTest.java | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogConfigTest.java index f2f277c6ea..9be71c3a02 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogConfigTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogConfigTest.java @@ -45,7 +45,7 @@ package org.eclipse.jgit.lib; -import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.IOException; @@ -78,7 +78,10 @@ public class ReflogConfigTest extends RepositoryTestCase { // set the logAllRefUpdates parameter to true and check it cfg.setBoolean("core", null, "logallrefupdates", true); cfg.save(); - assertTrue(cfg.get(CoreConfig.KEY).isLogAllRefUpdates()); + assertEquals(CoreConfig.LogRefUpdates.TRUE, + cfg.getEnum(ConfigConstants.CONFIG_CORE_SECTION, null, + ConfigConstants.CONFIG_KEY_LOGALLREFUPDATES, + CoreConfig.LogRefUpdates.FALSE)); // do one commit and check that reflog size is increased to 1 commit("A Commit\n", commitTime, tz); @@ -90,13 +93,32 @@ public class ReflogConfigTest extends RepositoryTestCase { // set the logAllRefUpdates parameter to false and check it cfg.setBoolean("core", null, "logallrefupdates", false); cfg.save(); - assertFalse(cfg.get(CoreConfig.KEY).isLogAllRefUpdates()); + assertEquals(CoreConfig.LogRefUpdates.FALSE, + cfg.getEnum(ConfigConstants.CONFIG_CORE_SECTION, null, + ConfigConstants.CONFIG_KEY_LOGALLREFUPDATES, + CoreConfig.LogRefUpdates.TRUE)); // do one commit and check that reflog size is 2 commit("A Commit\n", commitTime, tz); + commitTime += 60 * 1000; assertTrue( "Reflog for HEAD should contain two entries", db.getReflogReader(Constants.HEAD).getReverseEntries().size() == 2); + + // set the logAllRefUpdates parameter to false and check it + cfg.setEnum("core", null, "logallrefupdates", + CoreConfig.LogRefUpdates.ALWAYS); + cfg.save(); + assertEquals(CoreConfig.LogRefUpdates.ALWAYS, + cfg.getEnum(ConfigConstants.CONFIG_CORE_SECTION, null, + ConfigConstants.CONFIG_KEY_LOGALLREFUPDATES, + CoreConfig.LogRefUpdates.FALSE)); + + // do one commit and check that reflog size is 3 + commit("A Commit\n", commitTime, tz); + assertTrue("Reflog for HEAD should contain three entries", + db.getReflogReader(Constants.HEAD).getReverseEntries() + .size() == 3); } private void commit(String commitMsg, long commitTime, int tz) |