Browse Source

Allow to programmatically set FastForwardMode for PullCommand

Bug: 517847
Change-Id: I70d12dbe347a3d7a3528687ee04e52a2052bfb93
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-4.9
Matthias Sohn 8 years ago
parent
commit
df638e0cfc
  1. 34
      org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java

34
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);
}
@ -436,6 +436,27 @@ public class PullCommand extends TransportCommand<PullCommand, PullResult> {
return this;
}
/**
* 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.
*
@ -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,

Loading…
Cancel
Save