- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<List<String>>
-
- org.eclipse.jgit.api.DeleteBranchCommand
-
public class DeleteBranchCommand extends GitCommand<List<String>>
Used to delete one or several branches. The result ofcall()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
-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDeleteBranchCommand(Repository repo)Constructor for DeleteBranchCommand
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>call()DeleteBranchCommandsetBranchNames(String... branchnames)Set the names of the branches to deleteDeleteBranchCommandsetForce(boolean force)Set whether to forcefully delete branches-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Constructor Detail
-
DeleteBranchCommand
protected DeleteBranchCommand(Repository repo)
Constructor for DeleteBranchCommand- Parameters:
repo- theRepository
-
-
Method Detail
-
call
public List<String> call() throws GitAPIException, NotMergedException, CannotDeleteCurrentBranchException
Execute the command
- Specified by:
callin interfaceCallable<List<String>>- Specified by:
callin classGitCommand<List<String>>- Throws:
GitAPIExceptionNotMergedExceptionCannotDeleteCurrentBranchException
-
setBranchNames
public DeleteBranchCommand setBranchNames(String... branchnames)
Set the names of the branches to delete- Parameters:
branchnames- the names of the branches to delete; if not set, this will do nothing; invalid branch names will simply be ignored- Returns:
- this instance
-
setForce
public DeleteBranchCommand setForce(boolean force)
Set whether to forcefully delete branches- Parameters:
force-truecorresponds to the -D option,falseto the -d option (default)
iffalsea 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:
- this instance
-
-