aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2017-06-12 19:29:55 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2017-06-16 23:20:20 +0200
commitdf638e0cfc628469eee9a91df5b2b65634e274d7 (patch)
tree26bdfed7452dc84204aee3f8257628b1da34e738 /org.eclipse.jgit/src
parent0d447b16604d934675d2dc8e958fa043e945dfc6 (diff)
downloadjgit-df638e0cfc628469eee9a91df5b2b65634e274d7.tar.gz
jgit-df638e0cfc628469eee9a91df5b2b65634e274d7.zip
Allow to programmatically set FastForwardMode for PullCommand
Bug: 517847 Change-Id: I70d12dbe347a3d7a3528687ee04e52a2052bfb93 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java34
1 files changed, 29 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java
index 0f8eba2332..aa97996dfc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java
@@ -99,6 +99,8 @@ public class PullCommand extends TransportCommand<PullCommand, PullResult> {
private TagOpt tagOption;
+ private FastForwardMode fastForwardMode;
+
private FetchRecurseSubmodulesMode submoduleRecurseMode = null;
/**
@@ -350,11 +352,9 @@ public class PullCommand extends TransportCommand<PullCommand, PullResult> {
result = new PullResult(fetchRes, remote, rebaseRes);
} else {
MergeCommand merge = new MergeCommand(repo);
- merge.include(upstreamName, commitToMerge);
- merge.setStrategy(strategy);
- merge.setProgressMonitor(monitor);
- merge.setFastForward(getFastForwardMode());
- MergeResult mergeRes = merge.call();
+ MergeResult mergeRes = merge.include(upstreamName, commitToMerge)
+ .setStrategy(strategy).setProgressMonitor(monitor)
+ .setFastForward(getFastForwardMode()).call();
monitor.update(1);
result = new PullResult(fetchRes, remote, mergeRes);
}
@@ -437,6 +437,27 @@ public class PullCommand extends TransportCommand<PullCommand, PullResult> {
}
/**
+ * Sets the fast forward mode. It is used if pull is configured to do a
+ * merge as opposed to rebase. If non-{@code null} takes precedence over the
+ * fast-forward mode configured in git config.
+ *
+ * @param fastForwardMode
+ * corresponds to the --ff/--no-ff/--ff-only options. If
+ * {@code null} use the value of {@code pull.ff} configured in
+ * git config. If {@code pull.ff} is not configured fall back to
+ * the value of {@code merge.ff}. If {@code merge.ff} is not
+ * configured --ff is the built-in default.
+ * @return {@code this}
+ * @since 4.9
+ */
+ public PullCommand setFastForward(
+ @Nullable FastForwardMode fastForwardMode) {
+ checkCallable();
+ this.fastForwardMode = fastForwardMode;
+ return this;
+ }
+
+ /**
* Set the mode to be used for recursing into submodules.
*
* @param recurse
@@ -477,6 +498,9 @@ public class PullCommand extends TransportCommand<PullCommand, PullResult> {
}
private FastForwardMode getFastForwardMode() {
+ if (fastForwardMode != null) {
+ return fastForwardMode;
+ }
Config config = repo.getConfig();
Merge ffMode = config.getEnum(Merge.values(),
ConfigConstants.CONFIG_PULL_SECTION, null,