Top Description Fields Constructors Methods
org.eclipse.jgit.api

public Class PullCommand

extends TransportCommand<PullCommand, PullResult>
Class Inheritance
Imports
java.io.IOException, java.text.MessageFormat, org.eclipse.jgit.annotations.Nullable, org.eclipse.jgit.api.MergeCommand.FastForwardMode, .MergeCommand.FastForwardMode.Merge, .RebaseCommand.Operation, org.eclipse.jgit.api.errors.CanceledException, .GitAPIException, .InvalidConfigurationException, .InvalidRemoteException, .JGitInternalException, .NoHeadException, .RefNotAdvertisedException, .RefNotFoundException, .WrongRepositoryStateException, org.eclipse.jgit.dircache.DirCacheCheckout, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.AnyObjectId, .BranchConfig.BranchRebaseMode, .Config, .ConfigConstants, .Constants, .NullProgressMonitor, .ObjectId, .ProgressMonitor, .Ref, .RefUpdate, .RefUpdate.Result, .Repository, .RepositoryState, .SubmoduleConfig.FetchRecurseSubmodulesMode, org.eclipse.jgit.merge.ContentMergeStrategy, .MergeStrategy, org.eclipse.jgit.revwalk.RevCommit, .RevWalk, org.eclipse.jgit.transport.FetchResult, .TagOpt

The Pull command
See Also
Git documentation about Pull

Field Summary

Modifier and TypeField and Description
private ContentMergeStrategy
private static final String
private MergeCommand.FastForwardMode
private ProgressMonitor
private BranchConfig.BranchRebaseMode
private String
private String
private MergeStrategy
private SubmoduleConfig.FetchRecurseSubmodulesMode
private TagOpt
Inherited from org.eclipse.jgit.api.TransportCommand:
credentialsProvidertimeouttransportConfigCallback

Constructor Summary

AccessConstructor and Description
protected
PullCommand(Repository repo)

Constructor for PullCommand.

Method Summary

Modifier and TypeMethod and Description
public PullResult
call()

Implements abstract org.eclipse.jgit.api.GitCommand.call.

Implements java.util.concurrent.Callable.call.

Computes a result, or throws an exception if unable to do so.

private MergeCommand.FastForwardMode
public static BranchConfig.BranchRebaseMode
getRebaseMode(String
name of the local branch
branchName
,
Config
the org.eclipse.jgit.lib.Config to read the value from
config
)

Reads the rebase mode to use for a pull command from the repository configuration.

public String

Returns:

the remote used for the pull operation if it was set explicitly
getRemote
()

Get the remote name used for pull operation

public String

Returns:

the remote branch name used for the pull operation if it was set explicitly
getRemoteBranchName
()

Get the remote branch name for the pull operation

public PullCommand

Returns:

this
setContentMergeStrategy
(ContentMergeStrategy
the ContentMergeStrategy to be used
strategy
)

Sets the content merge strategy to use if the merge strategy is "resolve" or "recursive".

public PullCommand

Returns:

this
setFastForward
(MergeCommand.FastForwardMode
corresponds to the --ff/--no-ff/--ff-only options. If null use the value of pull.ff configured in git config. If pull.ff is not configured fall back to the value of merge.ff. If merge.ff is not configured --ff is the built-in default.
fastForwardMode
)

Set the fast forward mode.

public PullCommand

Returns:

this instance
setProgressMonitor
(ProgressMonitor
a progress monitor
monitor
)

Set progress monitor

public PullCommand

Returns:

this
setRebase
(boolean
whether to use rebase after fetching
useRebase
)

Set if rebase should be used after fetching.

public PullCommand
public PullCommand

Returns:

this
setRecurseSubmodules
(SubmoduleConfig.FetchRecurseSubmodulesMode
the org.eclipse.jgit.lib.SubmoduleConfig.FetchRecurseSubmodulesMode to be used for recursing into submodules
recurse
)

Set the mode to be used for recursing into submodules.

public PullCommand

Returns:

this
setRemote
(String
name of the remote to pull from
remote
)

The remote (uri or name) to be used for the pull operation.

public PullCommand

Returns:

this
setRemoteBranchName
(String
remote branch name to be used for pull operation
remoteBranchName
)

The remote branch name to be used for the pull operation.

public PullCommand

Returns:

this
setStrategy
(MergeStrategy
The merge strategy to use during this pull operation.
strategy
)

Set the @{code MergeStrategy}

public PullCommand

Returns:

this
setTagOpt
(TagOpt tagOpt)

Set the specification of annotated tag behavior during fetch

Inherited from org.eclipse.jgit.api.TransportCommand:
configureconfigureselfsetCredentialsProvidersetTimeoutsetTransportConfigCallback

Field Detail

contentStrategyback to summary
private ContentMergeStrategy contentStrategy
DOTback to summary
private static final String DOT
fastForwardModeback to summary
private MergeCommand.FastForwardMode fastForwardMode
monitorback to summary
private ProgressMonitor monitor
pullRebaseModeback to summary
private BranchConfig.BranchRebaseMode pullRebaseMode
remoteback to summary
private String remote
remoteBranchNameback to summary
private String remoteBranchName
strategyback to summary
private MergeStrategy strategy
submoduleRecurseModeback to summary
private SubmoduleConfig.FetchRecurseSubmodulesMode submoduleRecurseMode
tagOptionback to summary
private TagOpt tagOption

Constructor Detail

PullCommandback to summary
protected PullCommand(Repository repo)

Constructor for PullCommand.

Parameters
repo:Repository

the org.eclipse.jgit.lib.Repository

Method Detail

callback to summary
public PullResult call() throws GitAPIException, WrongRepositoryStateException, InvalidConfigurationException, InvalidRemoteException, CanceledException, RefNotFoundException, RefNotAdvertisedException, NoHeadException, TransportException

Implements abstract org.eclipse.jgit.api.GitCommand.call.

Implements java.util.concurrent.Callable.call.

Doc from org.eclipse.jgit.api.GitCommand.call.

Computes a result, or throws an exception if unable to do so.

Execute the command

Execute the Pull command 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.

Returns:PullResult

Doc from java.util.concurrent.Callable.call.

computed result

Annotations
@Override
getFastForwardModeback to summary
private MergeCommand.FastForwardMode getFastForwardMode()
getRebaseModeback to summary
public static BranchConfig.BranchRebaseMode getRebaseMode(String branchName, Config config)

Reads the rebase mode to use for a pull command from the repository configuration. This is the value defined for the configurations branch.[branchName].rebase, or,if not set, pull.rebase. If neither is set, yields org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode#NONE.

Parameters
branchName:String

name of the local branch

config:Config

the org.eclipse.jgit.lib.Config to read the value from

Returns:BranchConfig.BranchRebaseMode

the org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode

Since
4.5
getRemoteback to summary
public String getRemote()

Get the remote name used for pull operation

Returns:String

the remote used for the pull operation if it was set explicitly

Since
3.3
getRemoteBranchNameback to summary
public String getRemoteBranchName()

Get the remote branch name for the pull operation

Returns:String

the remote branch name used for the pull operation if it was set explicitly

Since
3.3
setContentMergeStrategyback to summary
public PullCommand setContentMergeStrategy(ContentMergeStrategy strategy)

Sets the content merge strategy to use if the merge strategy is "resolve" or "recursive".

Parameters
strategy:ContentMergeStrategy

the ContentMergeStrategy to be used

Returns:PullCommand

this

Since
5.12
setFastForwardback to summary
public PullCommand setFastForward(MergeCommand.FastForwardMode fastForwardMode)

Set the fast forward mode. It is used if pull is configured to do a merge as opposed to rebase. If non-null takes precedence over the fast-forward mode configured in git config.

Parameters
fastForwardMode:MergeCommand.FastForwardMode

corresponds to the --ff/--no-ff/--ff-only options. If null use the value of pull.ff configured in git config. If pull.ff is not configured fall back to the value of merge.ff. If merge.ff is not configured --ff is the built-in default.

Returns:PullCommand

this

Since
4.9
setProgressMonitorback to summary
public PullCommand setProgressMonitor(ProgressMonitor monitor)

Set progress monitor

Parameters
monitor:ProgressMonitor

a progress monitor

Returns:PullCommand

this instance

setRebaseback to summary
public PullCommand setRebase(boolean useRebase)

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:boolean

whether to use rebase after fetching

Returns:PullCommand

this

setRebaseback to summary
public PullCommand setRebase(BranchConfig.BranchRebaseMode rebaseMode)

Sets the org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode to use after fetching.

BranchRebaseMode.REBASE
Equivalent to --rebase on the command line: use rebase instead of merge after fetching.
BranchRebaseMode.MERGES
Equivalent to --rebase-merges on the command line: rebase preserving local merge commits.
BranchRebaseMode.INTERACTIVE
Equivalent to --interactive on 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].rebase or, if not set, pull.rebase
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, branch.autosetuprebase, and pull.rebase.

Parameters
rebaseMode:BranchConfig.BranchRebaseMode

the org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode to use

Returns:PullCommand

this

Since
4.5
setRecurseSubmodulesback to summary
public PullCommand setRecurseSubmodules(SubmoduleConfig.FetchRecurseSubmodulesMode recurse)

Set the mode to be used for recursing into submodules.

Parameters
recurse:SubmoduleConfig.FetchRecurseSubmodulesMode

the org.eclipse.jgit.lib.SubmoduleConfig.FetchRecurseSubmodulesMode to be used for recursing into submodules

Returns:PullCommand

this

Since
4.7
See Also
FetchCommand#setRecurseSubmodules(FetchRecurseSubmodulesMode)
setRemoteback to summary
public PullCommand setRemote(String remote)

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 of Constants.DEFAULT_REMOTE_NAME will be used.

Parameters
remote:String

name of the remote to pull from

Returns:PullCommand

this

Since
3.3
See Also
Constants#DEFAULT_REMOTE_NAME
setRemoteBranchNameback to summary
public PullCommand setRemoteBranchName(String remoteBranchName)

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:String

remote branch name to be used for pull operation

Returns:PullCommand

this

Since
3.3
setStrategyback to summary
public PullCommand setStrategy(MergeStrategy strategy)

Set the @{code MergeStrategy}

Parameters
strategy:MergeStrategy

The merge strategy to use during this pull operation.

Returns:PullCommand

this

Since
3.4
setTagOptback to summary
public PullCommand setTagOpt(TagOpt tagOpt)

Set the specification of annotated tag behavior during fetch

Parameters
tagOpt:TagOpt

the org.eclipse.jgit.transport.TagOpt

Returns:PullCommand

this

Since
4.7