summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2016-04-08 16:04:17 +0200
committerChristian Halstrick <christian.halstrick@sap.com>2016-04-11 08:58:48 +0200
commit36a53d1a3cdd66c40b6db241a75a28293f22f5e1 (patch)
treeee5d8db745d6153399b0c63eb608155a2ccdb473 /org.eclipse.jgit.test
parent2708b11b6c6f0e6a1ecd4a6e430756501a783bc6 (diff)
downloadjgit-36a53d1a3cdd66c40b6db241a75a28293f22f5e1.tar.gz
jgit-36a53d1a3cdd66c40b6db241a75a28293f22f5e1.zip
Fix CommitCommand to be able to skip writing to RefLog
CommitCommand already provided a method to set the comment which should be written into the reflog. The underlying RefUpdate class supported to skip writing a reflog entry. But through the CommitCommand API it was not possible to prevent writing a reflog entry. Fix this and allow creating commits which don't occur in the reflog. Change-Id: I193c53de71fb5958ea749c4bfa8360a51acc9b58
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java
index 9d87f0c29c..8a07118f84 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java
@@ -68,6 +68,7 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.RefUpdate.Result;
+import org.eclipse.jgit.lib.ReflogEntry;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -436,6 +437,36 @@ public class CommitCommandTest extends RepositoryTestCase {
}
}
+ @Test
+ public void testReflogs() throws Exception {
+ try (Git git = new Git(db)) {
+ writeTrashFile("f", "1");
+ git.add().addFilepattern("f").call();
+ git.commit().setMessage("c1").call();
+ writeTrashFile("f", "2");
+ git.commit().setMessage("c2").setAll(true).setReflogComment(null)
+ .call();
+ writeTrashFile("f", "3");
+ git.commit().setMessage("c3").setAll(true)
+ .setReflogComment("testRl").call();
+
+ db.getReflogReader(Constants.HEAD).getReverseEntries();
+
+ assertEquals("testRl;commit (initial): c1;", reflogComments(
+ db.getReflogReader(Constants.HEAD).getReverseEntries()));
+ assertEquals("testRl;commit (initial): c1;", reflogComments(
+ db.getReflogReader(db.getBranch()).getReverseEntries()));
+ }
+ }
+
+ private static String reflogComments(List<ReflogEntry> entries) {
+ StringBuffer b = new StringBuffer();
+ for (ReflogEntry e : entries) {
+ b.append(e.getComment()).append(";");
+ }
+ return b.toString();
+ }
+
@Test(expected = WrongRepositoryStateException.class)
public void commitAmendOnInitialShouldFail() throws Exception {
try (Git git = new Git(db)) {