diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2016-04-08 16:04:17 +0200 |
---|---|---|
committer | Christian Halstrick <christian.halstrick@sap.com> | 2016-04-11 08:58:48 +0200 |
commit | 36a53d1a3cdd66c40b6db241a75a28293f22f5e1 (patch) | |
tree | ee5d8db745d6153399b0c63eb608155a2ccdb473 /org.eclipse.jgit/src | |
parent | 2708b11b6c6f0e6a1ecd4a6e430756501a783bc6 (diff) | |
download | jgit-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/src')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java | 7 |
1 files changed, 6 insertions, 1 deletions
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 0abb8ba4ec..e54169adec 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java @@ -124,6 +124,8 @@ public class CommitCommand extends GitCommand<RevCommit> { private String reflogComment; + private boolean useDefaultReflogMessage = true; + /** * Setting this option bypasses the pre-commit and commit-msg hooks. */ @@ -258,7 +260,7 @@ public class CommitCommand extends GitCommand<RevCommit> { RevCommit revCommit = rw.parseCommit(commitId); RefUpdate ru = repo.updateRef(Constants.HEAD); ru.setNewObjectId(commitId); - if (reflogComment != null) { + if (!useDefaultReflogMessage) { ru.setRefLogMessage(reflogComment, false); } else { String prefix = amend ? "commit (amend): " //$NON-NLS-1$ @@ -790,10 +792,13 @@ public class CommitCommand extends GitCommand<RevCommit> { * Override the message written to the reflog * * @param reflogComment + * the comment to be written into the reflog or <code>null</code> + * to specify that no reflog should be written * @return {@code this} */ public CommitCommand setReflogComment(String reflogComment) { this.reflogComment = reflogComment; + useDefaultReflogMessage = false; return this; } |