aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Baumgart2011-03-09 12:26:46 (EST)
committerChris Aniszczyk2011-03-14 16:51:31 (EDT)
commit9830baf48dd5b3feb9780a3cc1d83b79e1d4c46b (patch)
treeee4d28337a83a6a5ec6d33f866630b580a120fb1
parent65f9a6e58bd9296cbbe1cffc7cf079fd65991686 (diff)
downloadjgit-9830baf48dd5b3feb9780a3cc1d83b79e1d4c46b.zip
jgit-9830baf48dd5b3feb9780a3cc1d83b79e1d4c46b.tar.gz
jgit-9830baf48dd5b3feb9780a3cc1d83b79e1d4c46b.tar.bz2
CommitCommand: set correct Reflog message when amendingrefs/changes/78/2678/2
Change-Id: I2322d31b09ca63bdcee50e90340e326467dc5021 Signed-off-by: Jens Baumgart <jens.baumgart@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java14
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java5
2 files changed, 13 insertions, 6 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java
index 3d79357..d863f45 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java
@@ -68,6 +68,7 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryTestCase;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
+import org.eclipse.jgit.storage.file.ReflogReader;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.util.FileUtils;
import org.junit.Test;
@@ -150,8 +151,8 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
@Test
public void testSomeCommits() throws NoHeadException, NoMessageException,
- UnmergedPathException, ConcurrentRefUpdateException,
- JGitInternalException, WrongRepositoryStateException {
+ ConcurrentRefUpdateException, JGitInternalException,
+ WrongRepositoryStateException, IOException {
// do 4 commits
Git git = new Git(db);
@@ -180,6 +181,8 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
l--;
}
assertEquals(l, -1);
+ ReflogReader reader = db.getReflogReader(Constants.HEAD);
+ assertTrue(reader.getLastEntry().getComment().startsWith("commit:"));
}
// try to do a commit without specifying a message. Should fail!
@@ -319,8 +322,8 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
@Test
public void testCommitAmend() throws NoHeadException, NoMessageException,
- UnmergedPathException, ConcurrentRefUpdateException,
- JGitInternalException, WrongRepositoryStateException {
+ ConcurrentRefUpdateException, JGitInternalException,
+ WrongRepositoryStateException, IOException {
Git git = new Git(db);
git.commit().setMessage("first comit").call(); // typo
git.commit().setAmend(true).setMessage("first commit").call();
@@ -332,6 +335,9 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
c++;
}
assertEquals(1, c);
+ ReflogReader reader = db.getReflogReader(Constants.HEAD);
+ assertTrue(reader.getLastEntry().getComment()
+ .startsWith("commit (amend):"));
}
@Test
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
index 8d9ce98..0d7a7da 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
@@ -211,8 +211,9 @@ public class CommitCommand extends GitCommand<RevCommit> {
RevCommit revCommit = revWalk.parseCommit(commitId);
RefUpdate ru = repo.updateRef(Constants.HEAD);
ru.setNewObjectId(commitId);
- ru.setRefLogMessage("commit : "
- + revCommit.getShortMessage(), false);
+ String prefix = amend ? "commit (amend): " : "commit: ";
+ ru.setRefLogMessage(
+ prefix + revCommit.getShortMessage(), false);
ru.setExpectedOldObjectId(headId);
Result rc = ru.forceUpdate();