]> source.dussan.org Git - jgit.git/commitdiff
Indicate initial commit on a branch in the reflog 65/11565/4
authorRobin Rosenberg <robin.rosenberg@dewire.com>
Fri, 29 Mar 2013 22:59:21 +0000 (23:59 +0100)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Tue, 2 Apr 2013 19:57:17 +0000 (21:57 +0200)
Bug: 393463
Change-Id: I4733d6f719bc0dc694e7a6a6ad2092de6364898c

org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ReflogCommandTest.java
org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java

index e2797bd5a024306b21f019b87dfa0630e3c8c13a..a09bb11fdec4c237e4ed082eff7bca01c9207c41 100644 (file)
@@ -48,7 +48,6 @@ import org.eclipse.jgit.api.Git;
 import org.eclipse.jgit.api.ReflogCommand;\r
 import org.eclipse.jgit.internal.storage.file.ReflogEntry;\r
 import org.eclipse.jgit.lib.Constants;\r
-import org.eclipse.jgit.lib.ObjectId;\r
 import org.eclipse.jgit.lib.Repository;\r
 import org.kohsuke.args4j.Argument;\r
 \r
@@ -77,12 +76,7 @@ class Reflog extends TextBuiltin {
                s.append(ref == null ? Constants.HEAD : Repository.shortenRefName(ref));\r
                s.append("@{" + i + "}:"); //$NON-NLS-1$ //$NON-NLS-2$\r
                s.append(" "); //$NON-NLS-1$\r
-               // temporary workaround for bug 393463\r
-               if (entry.getOldId().equals(ObjectId.zeroId()))\r
-                       s.append(entry.getComment().replaceFirst("^commit:", //$NON-NLS-1$\r
-                                       "commit (initial):")); //$NON-NLS-1$\r
-               else\r
-                       s.append(entry.getComment());\r
+               s.append(entry.getComment());\r
                return s.toString();\r
        }\r
 }\r
index dfd5c5476175c568dd42c7475e740543d0f37c8d..cf9573e44c21e354faa3e02830e7d718a68f663c 100644 (file)
@@ -96,10 +96,10 @@ public class MergeCommandTest extends RepositoryTestCase {
                MergeResult result = git.merge().include(db.getRef(Constants.HEAD)).call();
                assertEquals(MergeResult.MergeStatus.ALREADY_UP_TO_DATE, result.getMergeStatus());
                // no reflog entry written by merge
-               assertEquals("commit: initial commit",
+               assertEquals("commit (initial): initial commit",
                                db
                                .getReflogReader(Constants.HEAD).getLastEntry().getComment());
-               assertEquals("commit: initial commit",
+               assertEquals("commit (initial): initial commit",
                                db
                                .getReflogReader(db.getBranch()).getLastEntry().getComment());
        }
index a30b4963f9b210afb0f66a28ef5133f7d7af24b6..318d1f98b93921c4804c674af66e96632d88d319 100644 (file)
@@ -90,7 +90,8 @@ public class ReflogCommandTest extends RepositoryTestCase {
                assertNotNull(reflog);
                assertEquals(3, reflog.size());
                ReflogEntry[] reflogs = reflog.toArray(new ReflogEntry[reflog.size()]);
-               assertEquals(reflogs[2].getComment(), "commit: Initial commit");
+               assertEquals(reflogs[2].getComment(),
+                               "commit (initial): Initial commit");
                assertEquals(reflogs[2].getNewId(), commit1.getId());
                assertEquals(reflogs[2].getOldId(), ObjectId.zeroId());
                assertEquals(reflogs[1].getComment(),
@@ -136,7 +137,8 @@ public class ReflogCommandTest extends RepositoryTestCase {
                assertNotNull(reflog);
                assertEquals(4, reflog.size());
                ReflogEntry[] reflogs = reflog.toArray(new ReflogEntry[reflog.size()]);
-               assertEquals(reflogs[3].getComment(), "commit: Initial commit");
+               assertEquals(reflogs[3].getComment(),
+                               "commit (initial): Initial commit");
                assertEquals(reflogs[3].getNewId(), commit1.getId());
                assertEquals(reflogs[3].getOldId(), ObjectId.zeroId());
                assertEquals(reflogs[2].getComment(),
index 26a64ebcfc7390f86e64428d9600d51b089e9f6f..1f68a7df2cba8ae73a9707220d953dc4bb4ba23f 100644 (file)
@@ -228,7 +228,8 @@ public class CommitCommand extends GitCommand<RevCommit> {
                                                        ru.setRefLogMessage(reflogComment, false);
                                                } else {
                                                        String prefix = amend ? "commit (amend): " //$NON-NLS-1$
-                                                                       : "commit: ";
+                                                                       : parents.size() == 0 ? "commit (initial): "
+                                                                                       : "commit: ";
                                                        ru.setRefLogMessage(
                                                                        prefix + revCommit.getShortMessage(), false);
                                                }