Browse Source

Merge "Indicate initial commit on a branch in the reflog"

stable-3.0
Christian Halstrick 12 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
ac0481039d
  1. 8
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java
  2. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java
  3. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ReflogCommandTest.java
  4. 3
      org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java

8
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java

@ -48,7 +48,6 @@ import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.ReflogCommand; import org.eclipse.jgit.api.ReflogCommand;
import org.eclipse.jgit.internal.storage.file.ReflogEntry; import org.eclipse.jgit.internal.storage.file.ReflogEntry;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Argument;
@ -77,12 +76,7 @@ class Reflog extends TextBuiltin {
s.append(ref == null ? Constants.HEAD : Repository.shortenRefName(ref)); s.append(ref == null ? Constants.HEAD : Repository.shortenRefName(ref));
s.append("@{" + i + "}:"); //$NON-NLS-1$ //$NON-NLS-2$ s.append("@{" + i + "}:"); //$NON-NLS-1$ //$NON-NLS-2$
s.append(" "); //$NON-NLS-1$ s.append(" "); //$NON-NLS-1$
// temporary workaround for bug 393463 s.append(entry.getComment());
if (entry.getOldId().equals(ObjectId.zeroId()))
s.append(entry.getComment().replaceFirst("^commit:", //$NON-NLS-1$
"commit (initial):")); //$NON-NLS-1$
else
s.append(entry.getComment());
return s.toString(); return s.toString();
} }
} }

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java

@ -96,10 +96,10 @@ public class MergeCommandTest extends RepositoryTestCase {
MergeResult result = git.merge().include(db.getRef(Constants.HEAD)).call(); MergeResult result = git.merge().include(db.getRef(Constants.HEAD)).call();
assertEquals(MergeResult.MergeStatus.ALREADY_UP_TO_DATE, result.getMergeStatus()); assertEquals(MergeResult.MergeStatus.ALREADY_UP_TO_DATE, result.getMergeStatus());
// no reflog entry written by merge // no reflog entry written by merge
assertEquals("commit: initial commit", assertEquals("commit (initial): initial commit",
db db
.getReflogReader(Constants.HEAD).getLastEntry().getComment()); .getReflogReader(Constants.HEAD).getLastEntry().getComment());
assertEquals("commit: initial commit", assertEquals("commit (initial): initial commit",
db db
.getReflogReader(db.getBranch()).getLastEntry().getComment()); .getReflogReader(db.getBranch()).getLastEntry().getComment());
} }

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ReflogCommandTest.java

@ -90,7 +90,8 @@ public class ReflogCommandTest extends RepositoryTestCase {
assertNotNull(reflog); assertNotNull(reflog);
assertEquals(3, reflog.size()); assertEquals(3, reflog.size());
ReflogEntry[] reflogs = reflog.toArray(new ReflogEntry[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].getNewId(), commit1.getId());
assertEquals(reflogs[2].getOldId(), ObjectId.zeroId()); assertEquals(reflogs[2].getOldId(), ObjectId.zeroId());
assertEquals(reflogs[1].getComment(), assertEquals(reflogs[1].getComment(),
@ -136,7 +137,8 @@ public class ReflogCommandTest extends RepositoryTestCase {
assertNotNull(reflog); assertNotNull(reflog);
assertEquals(4, reflog.size()); assertEquals(4, reflog.size());
ReflogEntry[] reflogs = reflog.toArray(new ReflogEntry[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].getNewId(), commit1.getId());
assertEquals(reflogs[3].getOldId(), ObjectId.zeroId()); assertEquals(reflogs[3].getOldId(), ObjectId.zeroId());
assertEquals(reflogs[2].getComment(), assertEquals(reflogs[2].getComment(),

3
org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java

@ -228,7 +228,8 @@ public class CommitCommand extends GitCommand<RevCommit> {
ru.setRefLogMessage(reflogComment, false); ru.setRefLogMessage(reflogComment, false);
} else { } else {
String prefix = amend ? "commit (amend): " //$NON-NLS-1$ String prefix = amend ? "commit (amend): " //$NON-NLS-1$
: "commit: "; : parents.size() == 0 ? "commit (initial): "
: "commit: ";
ru.setRefLogMessage( ru.setRefLogMessage(
prefix + revCommit.getShortMessage(), false); prefix + revCommit.getShortMessage(), false);
} }

Loading…
Cancel
Save