summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2016-04-11 16:50:10 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2016-04-11 16:50:11 -0400
commiteeeca8042f39c2a46ae0acc1cce4a206b9b2d560 (patch)
tree5cf0c8d2c10605f2e3d0d0dbbfccbcb1b9895a30 /org.eclipse.jgit.test
parentccf83636936b714729fb89620f7b323c626f10e8 (diff)
parent36a53d1a3cdd66c40b6db241a75a28293f22f5e1 (diff)
downloadjgit-eeeca8042f39c2a46ae0acc1cce4a206b9b2d560.tar.gz
jgit-eeeca8042f39c2a46ae0acc1cce4a206b9b2d560.zip
Merge "Fix CommitCommand to be able to skip writing to RefLog"
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)) {