Class PullCommand
- All Implemented Interfaces:
Callable<PullResult>
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ContentMergeStrategyprivate static final Stringprivate MergeCommand.FastForwardModeprivate ProgressMonitorprivate BranchConfig.BranchRebaseModeprivate Stringprivate Stringprivate MergeStrategyprivate TagOptFields inherited from class org.eclipse.jgit.api.TransportCommand
credentialsProvider, timeout, transportConfigCallbackFields inherited from class org.eclipse.jgit.api.GitCommand
repo -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPullCommand(Repository repo) Constructor for PullCommand. -
Method Summary
Modifier and TypeMethodDescriptioncall()private MergeCommand.FastForwardModegetRebaseMode(String branchName, Config config) Reads the rebase mode to use for a pull command from the repository configuration.Get the remote name used for pull operationGet the remote branch name for the pull operationsetContentMergeStrategy(ContentMergeStrategy strategy) Sets the content merge strategy to use if themerge strategyis "resolve" or "recursive".setFastForward(MergeCommand.FastForwardMode fastForwardMode) Set the fast forward mode.setProgressMonitor(ProgressMonitor monitor) Set progress monitorsetRebase(boolean useRebase) Set if rebase should be used after fetching.setRebase(BranchConfig.BranchRebaseMode rebaseMode) Sets theBranchConfig.BranchRebaseModeto use after fetching.Set the mode to be used for recursing into submodules.The remote (uri or name) to be used for the pull operation.setRemoteBranchName(String remoteBranchName) The remote branch name to be used for the pull operation.setStrategy(MergeStrategy strategy) Set the @{code MergeStrategy}Set the specification of annotated tag behavior during fetchMethods inherited from class org.eclipse.jgit.api.TransportCommand
configure, configure, self, setCredentialsProvider, setTimeout, setTransportConfigCallbackMethods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
Field Details
-
DOT
- See Also:
-
monitor
-
pullRebaseMode
-
remote
-
remoteBranchName
-
strategy
-
contentStrategy
-
tagOption
-
fastForwardMode
-
submoduleRecurseMode
-
-
Constructor Details
-
PullCommand
Constructor for PullCommand.- Parameters:
repo- theRepository
-
-
Method Details
-
setProgressMonitor
Set progress monitor- Parameters:
monitor- a progress monitor- Returns:
- this instance
-
setRebase
Set if rebase should be used after fetching. If set to true, rebase is used instead of merge. This is equivalent to --rebase on the command line.If set to false, merge is used after fetching, overriding the configuration file. This is equivalent to --no-rebase on the command line.
This setting overrides the settings in the configuration file. By default, the setting in the repository configuration file is used.
A branch can be configured to use rebase by default. See branch.[name].rebase and branch.autosetuprebase.
- Parameters:
useRebase- whether to use rebase after fetching- Returns:
this
-
setRebase
Sets theBranchConfig.BranchRebaseModeto use after fetching.- BranchRebaseMode.REBASE
- Equivalent to
--rebaseon the command line: use rebase instead of merge after fetching. - BranchRebaseMode.PRESERVE
- Equivalent to
--preserve-mergeson the command line: rebase preserving local merge commits. - BranchRebaseMode.INTERACTIVE
- Equivalent to
--interactiveon the command line: use interactive rebase. - BranchRebaseMode.NONE
- Equivalent to
--no-rebase: merge instead of rebasing. null- Use the setting defined in the git configuration, either
branch.[name].rebaseor, if not set,pull.rebase
A branch can be configured to use rebase by default. See
branch.[name].rebase,branch.autosetuprebase, andpull.rebase.- Parameters:
rebaseMode- theBranchConfig.BranchRebaseModeto use- Returns:
this- Since:
- 4.5
-
call
public PullResult call() throws GitAPIException, WrongRepositoryStateException, InvalidConfigurationException, InvalidRemoteException, CanceledException, RefNotFoundException, RefNotAdvertisedException, NoHeadException, TransportExceptionExecute the command
Execute the
Pullcommand with all the options and parameters collected by the setter methods (e.g.setProgressMonitor(ProgressMonitor)) of this class. Each instance of this class should only be used for one invocation of the command. Don't call this method twice on an instance.- Specified by:
callin interfaceCallable<PullResult>- Specified by:
callin classGitCommand<PullResult>- Throws:
GitAPIExceptionWrongRepositoryStateExceptionInvalidConfigurationExceptionInvalidRemoteExceptionCanceledExceptionRefNotFoundExceptionRefNotAdvertisedExceptionNoHeadExceptionTransportException
-
setRemote
The remote (uri or name) to be used for the pull operation. If no remote is set, the branch's configuration will be used. If the branch configuration is missing the default value ofConstants.DEFAULT_REMOTE_NAMEwill be used.- Parameters:
remote- name of the remote to pull from- Returns:
this- Since:
- 3.3
- See Also:
-
setRemoteBranchName
The remote branch name to be used for the pull operation. If no remoteBranchName is set, the branch's configuration will be used. If the branch configuration is missing the remote branch with the same name as the current branch is used.- Parameters:
remoteBranchName- remote branch name to be used for pull operation- Returns:
this- Since:
- 3.3
-
getRemote
Get the remote name used for pull operation- Returns:
- the remote used for the pull operation if it was set explicitly
- Since:
- 3.3
-
getRemoteBranchName
Get the remote branch name for the pull operation- Returns:
- the remote branch name used for the pull operation if it was set explicitly
- Since:
- 3.3
-
setStrategy
Set the @{code MergeStrategy}- Parameters:
strategy- The merge strategy to use during this pull operation.- Returns:
this- Since:
- 3.4
-
setContentMergeStrategy
Sets the content merge strategy to use if themerge strategyis "resolve" or "recursive".- Parameters:
strategy- theContentMergeStrategyto be used- Returns:
this- Since:
- 5.12
-
setTagOpt
Set the specification of annotated tag behavior during fetch- Parameters:
tagOpt- theTagOpt- Returns:
this- Since:
- 4.7
-
setFastForward
Set the fast forward mode. It is used if pull is configured to do a merge as opposed to rebase. If non-nulltakes precedence over the fast-forward mode configured in git config.- Parameters:
fastForwardMode- corresponds to the --ff/--no-ff/--ff-only options. Ifnulluse the value ofpull.ffconfigured in git config. Ifpull.ffis not configured fall back to the value ofmerge.ff. Ifmerge.ffis not configured --ff is the built-in default.- Returns:
this- Since:
- 4.9
-
setRecurseSubmodules
public PullCommand setRecurseSubmodules(@Nullable SubmoduleConfig.FetchRecurseSubmodulesMode recurse) Set the mode to be used for recursing into submodules.- Parameters:
recurse- theSubmoduleConfig.FetchRecurseSubmodulesModeto be used for recursing into submodules- Returns:
this- Since:
- 4.7
- See Also:
-
getRebaseMode
Reads the rebase mode to use for a pull command from the repository configuration. This is the value defined for the configurationsbranch.[branchName].rebase, or,if not set,pull.rebase. If neither is set, yieldsBranchConfig.BranchRebaseMode.NONE.- Parameters:
branchName- name of the local branchconfig- theConfigto read the value from- Returns:
- the
BranchConfig.BranchRebaseMode - Since:
- 4.5
-
getFastForwardMode
-