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

public Class DeleteBranchCommand

extends GitCommand<List<String>>
Class Inheritance
Imports
java.io.IOException, java.text.MessageFormat, java.util.ArrayList, .Arrays, .Collection, .HashSet, .List, .Set, org.eclipse.jgit.api.errors.CannotDeleteCurrentBranchException, .GitAPIException, .JGitInternalException, .NotMergedException, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.ConfigConstants, .Constants, .NullProgressMonitor, .ProgressMonitor, .Ref, .RefUpdate, .RefUpdate.Result, .Repository, .StoredConfig, org.eclipse.jgit.revwalk.RevCommit, .RevWalk

Used to delete one or several branches. The result of call() is a list with the (full) names of the deleted branches. Note that we don't have a setter corresponding to the -r option; remote tracking branches are simply deleted just like local branches.
See Also
Git documentation about Branch

Field Summary

Modifier and TypeField and Description
private final Set<String>
private boolean
private ProgressMonitor
Inherited from org.eclipse.jgit.api.GitCommand:
repo

Constructor Summary

AccessConstructor and Description
protected
DeleteBranchCommand(Repository repo)

Constructor for DeleteBranchCommand

Method Summary

Modifier and TypeMethod and Description
public List<String>
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
deleteBranches(List<String> result, Set<String> shortNames)

public ProgressMonitor

Returns:

the ProgressMonitor for the delete operation
getProgressMonitor
()

Retrieves the progress monitor.

public DeleteBranchCommand

Returns:

this instance
setBranchNames
(String...
the names of the branches to delete; if not set, this will do nothing; invalid branch names will simply be ignored
branchnames
)

Set the names of the branches to delete

public DeleteBranchCommand

Returns:

this
setBranchNames
(Collection<String>
the names of the branches to delete; if not set, this will do nothing; invalid branch names will simply be ignored
branchNames
)

Sets the names of the branches to delete

public DeleteBranchCommand

Returns:

this instance
setForce
(boolean
true corresponds to the -D option, false to the -d option (default)
if false a check will be performed whether the branch to be deleted is already merged into the current branch and deletion will be refused in this case
force
)

Set whether to forcefully delete branches

public DeleteBranchCommand

Returns:

this
setProgressMonitor
(ProgressMonitor monitor)

Sets the progress monitor associated with the delete operation.

private void
updateConfig(Set<String> shortNames, Exception error)

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

Field Detail

branchNamesback to summary
private final Set<String> branchNames
forceback to summary
private boolean force
monitorback to summary
private ProgressMonitor monitor

Constructor Detail

DeleteBranchCommandback to summary
protected DeleteBranchCommand(Repository repo)

Constructor for DeleteBranchCommand

Parameters
repo:Repository

the org.eclipse.jgit.lib.Repository

Method Detail

callback to summary
public List<String> call() throws GitAPIException, NotMergedException, CannotDeleteCurrentBranchException

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

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

computed result

Annotations
@Override
deleteBranchesback to summary
private void deleteBranches(List<String> result, Set<String> shortNames) throws GitAPIException, NotMergedException, CannotDeleteCurrentBranchException
getProgressMonitorback to summary
public ProgressMonitor getProgressMonitor()

Retrieves the progress monitor.

Returns:ProgressMonitor

the ProgressMonitor for the delete operation

Since
6.8
setBranchNamesback to summary
public DeleteBranchCommand setBranchNames(String... branchnames)

Set the names of the branches to delete

Parameters
branchnames:String[]

the names of the branches to delete; if not set, this will do nothing; invalid branch names will simply be ignored

Returns:DeleteBranchCommand

this instance

setBranchNamesback to summary
public DeleteBranchCommand setBranchNames(Collection<String> branchNames)

Sets the names of the branches to delete

Parameters
branchNames:Collection<String>

the names of the branches to delete; if not set, this will do nothing; invalid branch names will simply be ignored

Returns:DeleteBranchCommand

this

Since
6.8
setForceback to summary
public DeleteBranchCommand setForce(boolean force)

Set whether to forcefully delete branches

Parameters
force:boolean

true corresponds to the -D option, false to the -d option (default)
if false a check will be performed whether the branch to be deleted is already merged into the current branch and deletion will be refused in this case

Returns:DeleteBranchCommand

this instance

setProgressMonitorback to summary
public DeleteBranchCommand setProgressMonitor(ProgressMonitor monitor)

Sets the progress monitor associated with the delete operation. By default, this is set to NullProgressMonitor

Parameters
monitor:ProgressMonitor

a ProgressMonitor

Returns:DeleteBranchCommand

this

Since
6.8
See Also
NullProgressMonitor
updateConfigback to summary
private void updateConfig(Set<String> shortNames, Exception error) throws GitAPIException