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

public Class PushCommand

extends TransportCommand<PushCommand, Iterable<PushResult>>
Class Inheritance
Imports
java.io.IOException, .OutputStream, .PrintStream, java.net.URISyntaxException, java.text.MessageFormat, java.util.ArrayList, .Arrays, .Collection, .Collections, .HashMap, .List, .Map, org.eclipse.jgit.api.errors.DetachedHeadException, .GitAPIException, .InvalidRefNameException, .InvalidRemoteException, .JGitInternalException, org.eclipse.jgit.errors.NotSupportedException, .TooLargeObjectInPackException, .TooLargePackException, .TransportException, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.BranchConfig, .Config, .ConfigConstants, .Constants, .NullProgressMonitor, .ProgressMonitor, .Ref, .Repository, org.eclipse.jgit.transport.PushConfig, .PushConfig.PushDefault, .PushResult, .RefLeaseSpec, .RefSpec, .RemoteConfig, .RemoteRefUpdate, .Transport

A class used to execute a Push command. It has setters for all supported options and arguments of this command and a call() method to finally execute the command.
See Also
Git documentation about Push

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private boolean
private PrintStream
private PrintStream
private ProgressMonitor
private OutputStream
private PushConfig.PushDefault
private List<String>
private String
private final Map<String, RefLeaseSpec>
private final List<RefSpec>
private String
private boolean
private boolean
Inherited from org.eclipse.jgit.api.TransportCommand:
credentialsProvidertimeouttransportConfigCallback

Constructor Summary

AccessConstructor and Description
protected
PushCommand(Repository repo)

Constructor for PushCommand.

Method Summary

Modifier and TypeMethod and Description
public PushCommand

Returns:

this.
add
(Ref
the source reference. The remote name will match.
ref
)

Add a reference to push.

public PushCommand

Returns:

this.
add
(String
any reference name, or a reference specification.
nameOrSpec
)

Add a reference to push.

public Iterable<PushResult>
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 void
private String
determineRemote(Config config, String remoteName)

private String
public ProgressMonitor

Returns:

the progress monitor for the push operation
getProgressMonitor
()

Get the progress monitor

public PushConfig.PushDefault

Returns:

the PushDefault, or null if not set
getPushDefault
()

Retrieves the PushDefault currently set.

public List<String>

Returns:

the option strings associated with the push operation
getPushOptions
()

Get push options

public String

Returns:

the receive-pack used for the remote operation
getReceivePack
()

Get the name of the remote executable providing the receive-pack service

public List<RefLeaseSpec>

Returns:

the RefLeaseSpecs
getRefLeaseSpecs
()

Get the RefLeaseSpecs.

public List<RefSpec>

Returns:

the ref specs
getRefSpecs
()

Get RefSpecs.

public String

Returns:

the remote used for the remote operation
getRemote
()

Get remote name

public int

Returns:

the timeout used for the push operation
getTimeout
()

Get timeout used for push operation

public boolean

Returns:

true if all-or-nothing behavior is requested.
isAtomic
()

Whether this push should be executed atomically (all references updated, or none)

public boolean

Returns:

the dry run preference for the push operation
isDryRun
()

Whether to run the push operation as a dry run

public boolean

Returns:

the force preference for push operation
isForce
()

Whether to push forcefully

public boolean

Returns:

the thin-pack preference for push operation
isThin
()

Get the thin-pack preference

public boolean

Returns:

true if push use bitmaps.
isUseBitmaps
()

Whether to use bitmaps for push.

public PushCommand

Returns:

this
setAtomic
(boolean
whether to run the push atomically
atomic
)

Requests atomic push (all references updated, or no updates).

public PushCommand

Returns:

this
setDryRun
(boolean
a boolean.
dryRun
)

Sets whether the push operation should be a dry run

public PushCommand

Returns:

this
setForce
(boolean
whether to push forcefully
force
)

Sets the force preference for push operation.

public PushCommand

Returns:

this
setHookErrorStream
(PrintStream
PrintStream to use; if null, System#err will be used
redirect
)

Sets a PrintStream a "pre-push" hook may write its stderr to.

public PushCommand

Returns:

this
setHookOutputStream
(PrintStream
PrintStream to use; if null, System#out will be used
redirect
)

Sets a PrintStream a "pre-push" hook may write its stdout to.

public PushCommand

Returns:

this
setOutputStream
(OutputStream out)

Sets the output stream to write sideband messages to

public PushCommand

Returns:

this
setProgressMonitor
(ProgressMonitor monitor)

The progress monitor associated with the push operation.

public PushCommand

Returns:

this
setPushAll
()

Push all branches under refs/heads/*.

public PushCommand

Returns:

this
setPushDefault
(PushConfig.PushDefault
PushDefault to set; if null the value defined in the git config will be used.
pushDefault
)

Sets an explicit PushDefault.

public PushCommand

Returns:

this
setPushOptions
(List<String>
a java.util.List of push option strings
pushOptions
)

Set the option strings associated with the push operation.

public PushCommand

Returns:

this
setPushTags
()

Push all tags under refs/tags/*.

public PushCommand

Returns:

this
setReceivePack
(String
name of the remote executable providing the receive-pack service
receivePack
)

The remote executable providing receive-pack service for pack transports.

public PushCommand

Returns:

this
setRefLeaseSpecs
(RefLeaseSpec... specs)

The ref lease specs to be used in the push operation, for a force-with-lease push operation.

public PushCommand

Returns:

this
setRefLeaseSpecs
(List<RefLeaseSpec>
list of RefLeaseSpecs
specs
)

The ref lease specs to be used in the push operation, for a force-with-lease push operation.

public PushCommand

Returns:

this
setRefSpecs
(RefSpec... specs)

The ref specs to be used in the push operation

public PushCommand

Returns:

this
setRefSpecs
(List<RefSpec> specs)

The ref specs to be used in the push operation

public PushCommand

Returns:

this
setRemote
(String
the remote name
remote
)

The remote (uri or name) used for the push operation.

public PushCommand

Returns:

this
setThin
(boolean
the thin-pack preference value
thinPack
)

Set the thin-pack preference for push operation.

public PushCommand

Returns:

this
setUseBitmaps
(boolean
false to disable use of bitmaps for push, true otherwise.
useBitmaps
)

Set whether to use bitmaps for push.

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

Field Detail

atomicback to summary
private boolean atomic
dryRunback to summary
private boolean dryRun
forceback to summary
private boolean force
hookErrRedirectback to summary
private PrintStream hookErrRedirect
hookOutRedirectback to summary
private PrintStream hookOutRedirect
monitorback to summary
private ProgressMonitor monitor
outback to summary
private OutputStream out
pushDefaultback to summary
private PushConfig.PushDefault pushDefault
pushOptionsback to summary
private List<String> pushOptions
receivePackback to summary
private String receivePack
refLeaseSpecsback to summary
private final Map<String, RefLeaseSpec> refLeaseSpecs
refSpecsback to summary
private final List<RefSpec> refSpecs
remoteback to summary
private String remote
thinback to summary
private boolean thin
useBitmapsback to summary
private boolean useBitmaps

Constructor Detail

PushCommandback to summary
protected PushCommand(Repository repo)

Constructor for PushCommand.

Parameters
repo:Repository

the org.eclipse.jgit.lib.Repository

Method Detail

addback to summary
public PushCommand add(Ref ref)

Add a reference to push.

Parameters
ref:Ref

the source reference. The remote name will match.

Returns:PushCommand

this.

addback to summary
public PushCommand add(String nameOrSpec)

Add a reference to push.

Parameters
nameOrSpec:String

any reference name, or a reference specification.

Returns:PushCommand

this.

Exceptions
JGitInternalException:
the reference name cannot be resolved.
callback to summary
public Iterable<PushResult> call() throws GitAPIException, InvalidRemoteException, 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 push command with all the options and parameters collected by the setter methods of this class. Each instance of this class should only be used for one invocation of the command (means: one call to call())

Returns:Iterable<PushResult>

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

computed result

Annotations
@Override
determineDefaultRefSpecsback to summary
private void determineDefaultRefSpecs(Config config) throws IOException, GitAPIException
determineRemoteback to summary
private String determineRemote(Config config, String remoteName) throws IOException
getCurrentBranchback to summary
private String getCurrentBranch() throws IOException, DetachedHeadException
getProgressMonitorback to summary
public ProgressMonitor getProgressMonitor()

Get the progress monitor

Returns:ProgressMonitor

the progress monitor for the push operation

getPushDefaultback to summary
public PushConfig.PushDefault getPushDefault()

Retrieves the PushDefault currently set.

Returns:PushConfig.PushDefault

the PushDefault, or null if not set

Since
6.1
getPushOptionsback to summary
public List<String> getPushOptions()

Get push options

Returns:List<String>

the option strings associated with the push operation

Since
4.5
getReceivePackback to summary
public String getReceivePack()

Get the name of the remote executable providing the receive-pack service

Returns:String

the receive-pack used for the remote operation

getRefLeaseSpecsback to summary
public List<RefLeaseSpec> getRefLeaseSpecs()

Get the RefLeaseSpecs.

Returns:List<RefLeaseSpec>

the RefLeaseSpecs

Since
4.7
getRefSpecsback to summary
public List<RefSpec> getRefSpecs()

Get RefSpecs.

Returns:List<RefSpec>

the ref specs

getRemoteback to summary
public String getRemote()

Get remote name

Returns:String

the remote used for the remote operation

getTimeoutback to summary
public int getTimeout()

Get timeout used for push operation

Returns:int

the timeout used for the push operation

isAtomicback to summary
public boolean isAtomic()

Whether this push should be executed atomically (all references updated, or none)

Returns:boolean

true if all-or-nothing behavior is requested.

Since
4.2
isDryRunback to summary
public boolean isDryRun()

Whether to run the push operation as a dry run

Returns:boolean

the dry run preference for the push operation

isForceback to summary
public boolean isForce()

Whether to push forcefully

Returns:boolean

the force preference for push operation

isThinback to summary
public boolean isThin()

Get the thin-pack preference

Returns:boolean

the thin-pack preference for push operation

isUseBitmapsback to summary
public boolean isUseBitmaps()

Whether to use bitmaps for push.

Returns:boolean

true if push use bitmaps.

Since
6.4
setAtomicback to summary
public PushCommand setAtomic(boolean atomic)

Requests atomic push (all references updated, or no updates). Default setting is false.

Parameters
atomic:boolean

whether to run the push atomically

Returns:PushCommand

this

Since
4.2
setDryRunback to summary
public PushCommand setDryRun(boolean dryRun)

Sets whether the push operation should be a dry run

Parameters
dryRun:boolean

a boolean.

Returns:PushCommand

this

setForceback to summary
public PushCommand setForce(boolean force)

Sets the force preference for push operation.

Parameters
force:boolean

whether to push forcefully

Returns:PushCommand

this

setHookErrorStreamback to summary
public PushCommand setHookErrorStream(PrintStream redirect)

Sets a PrintStream a "pre-push" hook may write its stderr to. If not set, System#err will be used.

When pushing to several remote repositories the stream is shared for all pushes.

Parameters
redirect:PrintStream

PrintStream to use; if null, System#err will be used

Returns:PushCommand

this

Since
6.4
setHookOutputStreamback to summary
public PushCommand setHookOutputStream(PrintStream redirect)

Sets a PrintStream a "pre-push" hook may write its stdout to. If not set, System#out will be used.

When pushing to several remote repositories the stream is shared for all pushes.

Parameters
redirect:PrintStream

PrintStream to use; if null, System#out will be used

Returns:PushCommand

this

Since
6.4
setOutputStreamback to summary
public PushCommand setOutputStream(OutputStream out)

Sets the output stream to write sideband messages to

Parameters
out:OutputStream

an java.io.OutputStream

Returns:PushCommand

this

Since
3.0
setProgressMonitorback to summary
public PushCommand setProgressMonitor(ProgressMonitor monitor)

The progress monitor associated with the push operation. By default, this is set to NullProgressMonitor

Parameters
monitor:ProgressMonitor

a org.eclipse.jgit.lib.ProgressMonitor

Returns:PushCommand

this

See Also
NullProgressMonitor
setPushAllback to summary
public PushCommand setPushAll()

Push all branches under refs/heads/*.

Returns:PushCommand

this

setPushDefaultback to summary
public PushCommand setPushDefault(PushConfig.PushDefault pushDefault)

Sets an explicit PushDefault. The default used if this is not called is PushDefault#CURRENT for compatibility reasons with earlier JGit versions.

Parameters
pushDefault:PushConfig.PushDefault

PushDefault to set; if null the value defined in the git config will be used.

Returns:PushCommand

this

Since
6.1
setPushOptionsback to summary
public PushCommand setPushOptions(List<String> pushOptions)

Set the option strings associated with the push operation.

Parameters
pushOptions:List<String>

a java.util.List of push option strings

Returns:PushCommand

this

Since
4.5
setPushTagsback to summary
public PushCommand setPushTags()

Push all tags under refs/tags/*.

Returns:PushCommand

this

setReceivePackback to summary
public PushCommand setReceivePack(String receivePack)

The remote executable providing receive-pack service for pack transports. If no receive-pack is set, the default value of RemoteConfig.DEFAULT_RECEIVE_PACK will be used.

Parameters
receivePack:String

name of the remote executable providing the receive-pack service

Returns:PushCommand

this

See Also
RemoteConfig#DEFAULT_RECEIVE_PACK
setRefLeaseSpecsback to summary
public PushCommand setRefLeaseSpecs(RefLeaseSpec... specs)

The ref lease specs to be used in the push operation, for a force-with-lease push operation.

Parameters
specs:RefLeaseSpec[]

a org.eclipse.jgit.transport.RefLeaseSpec object.

Returns:PushCommand

this

Since
4.7
setRefLeaseSpecsback to summary
public PushCommand setRefLeaseSpecs(List<RefLeaseSpec> specs)

The ref lease specs to be used in the push operation, for a force-with-lease push operation.

Parameters
specs:List<RefLeaseSpec>

list of RefLeaseSpecs

Returns:PushCommand

this

Since
4.7
setRefSpecsback to summary
public PushCommand setRefSpecs(RefSpec... specs)

The ref specs to be used in the push operation

Parameters
specs:RefSpec[]

a org.eclipse.jgit.transport.RefSpec object.

Returns:PushCommand

this

setRefSpecsback to summary
public PushCommand setRefSpecs(List<RefSpec> specs)

The ref specs to be used in the push operation

Parameters
specs:List<RefSpec>

list of org.eclipse.jgit.transport.RefSpecs

Returns:PushCommand

this

setRemoteback to summary
public PushCommand setRemote(String remote)

The remote (uri or name) used for the push operation. If no remote is set, the default value of Constants.DEFAULT_REMOTE_NAME will be used.

Parameters
remote:String

the remote name

Returns:PushCommand

this

See Also
Constants#DEFAULT_REMOTE_NAME
setThinback to summary
public PushCommand setThin(boolean thinPack)

Set the thin-pack preference for push operation. Default setting is Transport.DEFAULT_PUSH_THIN

Parameters
thinPack:boolean

the thin-pack preference value

Returns:PushCommand

this

setUseBitmapsback to summary
public PushCommand setUseBitmaps(boolean useBitmaps)

Set whether to use bitmaps for push. Default setting is true

Parameters
useBitmaps:boolean

false to disable use of bitmaps for push, true otherwise.

Returns:PushCommand

this

Since
6.4