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

public Class ListBranchCommand

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

Used to obtain a list of branches.

In case HEAD is detached (it points directly to a commit), it is also returned in the results.

See Also
Git documentation about Branch

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
ListBranchCommand.ListMode

The modes available for listing branches (corresponding to the -r and -a options)

Field Summary

Modifier and TypeField and Description
private String
private ListBranchCommand.ListMode
Inherited from org.eclipse.jgit.api.GitCommand:
repo

Constructor Summary

AccessConstructor and Description
protected
ListBranchCommand(Repository repo)

Constructor for ListBranchCommand.

Method Summary

Modifier and TypeMethod and Description
public List<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 Collection<Ref>
public ListBranchCommand

Returns:

this instance
setContains
(String
a commit ID or ref name
containsCommitish
)

If this is set, only the branches that contain the specified commit-ish as an ancestor are returned.

public ListBranchCommand

Returns:

this instance
setListMode
(ListBranchCommand.ListMode
optional: corresponds to the -r/-a options; by default, only local branches will be listed
listMode
)

Set the list mode

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

Field Detail

containsCommitishback to summary
private String containsCommitish
listModeback to summary
private ListBranchCommand.ListMode listMode

Constructor Detail

ListBranchCommandback to summary
protected ListBranchCommand(Repository repo)

Constructor for ListBranchCommand.

Parameters
repo:Repository

a org.eclipse.jgit.lib.Repository object.

Method Detail

callback to summary
public List<Ref> call() throws GitAPIException

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<Ref>

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

computed result

Annotations
@Override
filterRefsback to summary
private Collection<Ref> filterRefs(Collection<Ref> refs) throws RefNotFoundException, IOException
setContainsback to summary
public ListBranchCommand setContains(String containsCommitish)

If this is set, only the branches that contain the specified commit-ish as an ancestor are returned.

Parameters
containsCommitish:String

a commit ID or ref name

Returns:ListBranchCommand

this instance

Since
3.4
setListModeback to summary
public ListBranchCommand setListMode(ListBranchCommand.ListMode listMode)

Set the list mode

Parameters
listMode:ListBranchCommand.ListMode

optional: corresponds to the -r/-a options; by default, only local branches will be listed

Returns:ListBranchCommand

this instance

org.eclipse.jgit.api back to summary

public final Enum ListBranchCommand.ListMode

extends Enum<ListBranchCommand.ListMode>
Class Inheritance

The modes available for listing branches (corresponding to the -r and -a options)

Field Summary

Modifier and TypeField and Description
public static final ListBranchCommand.ListMode
ALL

Corresponds to the -a option (all branches)

public static final ListBranchCommand.ListMode
REMOTE

Corresponds to the -r option (remote branches only)

Constructor Summary

AccessConstructor and Description
private

Method Summary

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

Field Detail

ALLback to summary
public static final ListBranchCommand.ListMode ALL

Corresponds to the -a option (all branches)

REMOTEback to summary
public static final ListBranchCommand.ListMode REMOTE

Corresponds to the -r option (remote branches only)

Constructor Detail

ListModeback to summary
private ListMode()

Method Detail

valueOfback to summary
public static ListBranchCommand.ListMode valueOf(String name)
valuesback to summary
public static ListBranchCommand.ListMode[] values()