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

public Class CreateBranchCommand

extends GitCommand<Ref>
Class Inheritance
Static Imports
org.eclipse.jgit.lib.Constants.HEAD, .Constants.R_HEADS

Used to create a local branch.
See Also
Git documentation about Branch

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
CreateBranchCommand.SetupUpstreamMode

The modes available for setting up the upstream configuration (corresponding to the --set-upstream, --track, --no-track options

Field Summary

Modifier and TypeField and Description
private boolean
private String
private RevCommit
private String
private CreateBranchCommand.SetupUpstreamMode
Inherited from org.eclipse.jgit.api.GitCommand:
repo

Constructor Summary

AccessConstructor and Description
protected
CreateBranchCommand(Repository repo)

Constructor for CreateBranchCommand

Method Summary

Modifier and TypeMethod and Description
public Ref
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 ObjectId
private String
public static boolean

Returns:

true if the branch name is valid
isValidBranchName
(String
branch name to check
branchName
)

Check if the given branch name is valid

private void
public CreateBranchCommand

Returns:

this instance
setForce
(boolean
if true and the branch with the given name already exists, the start-point of an existing branch will be set to a new start-point; if false, the existing branch will not be changed
force
)

Set whether to create the branch forcefully

public CreateBranchCommand

Returns:

this instance
setName
(String
the name of the new branch
name
)

Set the name of the new branch

public CreateBranchCommand

Returns:

this instance
setStartPoint
(String
corresponds to the start-point option; if null, the current HEAD will be used
startPoint
)

Set the start point

public CreateBranchCommand

Returns:

this instance
setStartPoint
(RevCommit
corresponds to the start-point option; if null, the current HEAD will be used
startPoint
)

Set the start point

public CreateBranchCommand

Returns:

this instance
setUpstreamMode
(CreateBranchCommand.SetupUpstreamMode
corresponds to the --track/--no-track/--set-upstream options; may be null
mode
)

Set the upstream mode

Inherited from org.eclipse.jgit.api.GitCommand:
checkCallablegetRepositorysetCallable

Field Detail

forceback to summary
private boolean force
nameback to summary
private String name
startCommitback to summary
private RevCommit startCommit
startPointback to summary
private String startPoint
upstreamModeback to summary
private CreateBranchCommand.SetupUpstreamMode upstreamMode

Constructor Detail

CreateBranchCommandback to summary
protected CreateBranchCommand(Repository repo)

Constructor for CreateBranchCommand

Parameters
repo:Repository

the org.eclipse.jgit.lib.Repository

Method Detail

callback to summary
public Ref call() throws GitAPIException, RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException

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

Returns:Ref

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

computed result

Annotations
@Override
getStartPointObjectIdback to summary
private ObjectId getStartPointObjectId() throws AmbiguousObjectException, RefNotFoundException, IOException
getStartPointOrHeadback to summary
private String getStartPointOrHead()
isValidBranchNameback to summary
public static boolean isValidBranchName(String branchName)

Check if the given branch name is valid

Parameters
branchName:String

branch name to check

Returns:boolean

true if the branch name is valid

Since
5.0
processOptionsback to summary
private void processOptions() throws InvalidRefNameException
setForceback to summary
public CreateBranchCommand setForce(boolean force)

Set whether to create the branch forcefully

Parameters
force:boolean

if true and the branch with the given name already exists, the start-point of an existing branch will be set to a new start-point; if false, the existing branch will not be changed

Returns:CreateBranchCommand

this instance

setNameback to summary
public CreateBranchCommand setName(String name)

Set the name of the new branch

Parameters
name:String

the name of the new branch

Returns:CreateBranchCommand

this instance

setStartPointback to summary
public CreateBranchCommand setStartPoint(String startPoint)

Set the start point

Parameters
startPoint:String

corresponds to the start-point option; if null, the current HEAD will be used

Returns:CreateBranchCommand

this instance

setStartPointback to summary
public CreateBranchCommand setStartPoint(RevCommit startPoint)

Set the start point

Parameters
startPoint:RevCommit

corresponds to the start-point option; if null, the current HEAD will be used

Returns:CreateBranchCommand

this instance

setUpstreamModeback to summary
public CreateBranchCommand setUpstreamMode(CreateBranchCommand.SetupUpstreamMode mode)

Set the upstream mode

Parameters
mode:CreateBranchCommand.SetupUpstreamMode

corresponds to the --track/--no-track/--set-upstream options; may be null

Returns:CreateBranchCommand

this instance

org.eclipse.jgit.api back to summary

public final Enum CreateBranchCommand.SetupUpstreamMode

extends Enum<CreateBranchCommand.SetupUpstreamMode>
Class Inheritance

The modes available for setting up the upstream configuration (corresponding to the --set-upstream, --track, --no-track options

Field Summary

Modifier and TypeField and Description
public static final CreateBranchCommand.SetupUpstreamMode
NOTRACK

Corresponds to the --no-track option

public static final CreateBranchCommand.SetupUpstreamMode
SET_UPSTREAM

Corresponds to the --set-upstream option

public static final CreateBranchCommand.SetupUpstreamMode
TRACK

Corresponds to the --track option

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static CreateBranchCommand.SetupUpstreamMode
public static CreateBranchCommand.SetupUpstreamMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

NOTRACKback to summary
public static final CreateBranchCommand.SetupUpstreamMode NOTRACK

Corresponds to the --no-track option

SET_UPSTREAMback to summary
public static final CreateBranchCommand.SetupUpstreamMode SET_UPSTREAM

Corresponds to the --set-upstream option

TRACKback to summary
public static final CreateBranchCommand.SetupUpstreamMode TRACK

Corresponds to the --track option

Constructor Detail

SetupUpstreamModeback to summary
private SetupUpstreamMode()

Method Detail

valueOfback to summary
public static CreateBranchCommand.SetupUpstreamMode valueOf(String name)
valuesback to summary
public static CreateBranchCommand.SetupUpstreamMode[] values()