aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2016-07-15 00:13:01 +0200
committerAndrey Loskutov <loskutov@gmx.de>2016-08-17 08:56:03 -0400
commit13f0db25f272e29b607c5b0e01a3b0d612731794 (patch)
tree32f1ab0541031d1fecf2f313ed08773394e3d40a /org.eclipse.jgit
parent0b4751e805e3792403c5e3b39aa4f5555081991d (diff)
downloadjgit-13f0db25f272e29b607c5b0e01a3b0d612731794.tar.gz
jgit-13f0db25f272e29b607c5b0e01a3b0d612731794.zip
Enhance ResetCommand to allow disabling reflog update
This will be used by EGit for implementing commit amend in the staging view (see Idcd1efeeee8b3065bae36e285bfc0af24ab1e88f). Change-Id: Ice9ebbb1c0c3314c679f4db40cdd3664f61c27c3 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java30
1 files changed, 28 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
index e385a5d174..3ceff843a5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
@@ -123,6 +123,8 @@ public class ResetCommand extends GitCommand<Ref> {
private Collection<String> filepaths = new LinkedList<String>();
+ private boolean isReflogDisabled;
+
/**
*
* @param repo
@@ -181,8 +183,12 @@ public class ResetCommand extends GitCommand<Ref> {
ru.setNewObjectId(commitId);
String refName = Repository.shortenRefName(getRefOrHEAD());
- String message = refName + ": updating " + Constants.HEAD; //$NON-NLS-1$
- ru.setRefLogMessage(message, false);
+ if (isReflogDisabled) {
+ ru.disableRefLog();
+ } else {
+ String message = refName + ": updating " + Constants.HEAD; //$NON-NLS-1$
+ ru.setRefLogMessage(message, false);
+ }
if (ru.forceUpdate() == RefUpdate.Result.LOCK_FAILURE)
throw new JGitInternalException(MessageFormat.format(
JGitText.get().cannotLock, ru.getName()));
@@ -289,6 +295,26 @@ public class ResetCommand extends GitCommand<Ref> {
return this;
}
+ /**
+ * @param disable
+ * if {@code true} disables writing a reflog entry for this reset
+ * command
+ * @return this instance
+ * @since 4.5
+ */
+ public ResetCommand disableRefLog(boolean disable) {
+ this.isReflogDisabled = disable;
+ return this;
+ }
+
+ /**
+ * @return {@code true} if writing reflog is disabled for this reset command
+ * @since 4.5
+ */
+ public boolean isReflogDisabled() {
+ return this.isReflogDisabled;
+ }
+
private String getRefOrHEAD() {
if (ref != null)
return ref;