Click or drag to resize

RepositoryGetBranchSpecs Method

Get a list of branches from the repository

Namespace:  Perforce.P4
Assembly:  p4api.net (in p4api.net.dll) Version: 2023.2.255.3501
Syntax
public IList<BranchSpec> GetBranchSpecs(
	Options options
)

Parameters

options
Type: Perforce.P4Options

Return Value

Type: IListBranchSpec
A list containing the matching branches
Remarks

p4 help branches

branches -- Display list of branch specifications

p4 branches [-t] [-u user] [[-e|-E] nameFilter -m max]

Lists branch specifications. (See 'p4 help branch'.)

The -t flag displays the time as well as the date.

The -u user flag lists branch specs owned by the specified user.

The -e nameFilter flag lists branch specs with a name that matches
the nameFilter pattern, for example: -e 'svr-dev-rel*'. The -e flag
uses the server's normal case-sensitivity rules. The -E flag makes
the matching case-insensitive, even on a case-sensitive server.

The -m max flag limits output to the specified number of branch specs.

Examples
To get all branches and include timestamps [-t] (WARNING, will fetch all branches from the repository):
Options opts = new Options(BranchSpecsCmdFlags.Time, "", "", -1);
IList<Branch> branches = _repository.GetBranchSpecs(opts);
To get branches owned by 'Bob' [-u]:
Options opts = new Options(BranchSpecsCmdFlags.None, "Bob", "", -1);
IList<Branch> branches = _repository.GetBranchSpecs(opts);
To get the first 10 branches that start with the capital letter 'A' [-m] [-e]:
Options opts = new Options(BranchSpecsCmdFlags.None, "", "A*", 10);
IList<Branch> branches = _repository.GetBranchSpecs(opts);
To get the first 10 branches that start with the letter 'A' case insensitive [-m] [-E]:
Options opts = new Options(BranchSpecsCmdFlags.IgnoreCase, "", "A*", 10);
IList<Branch> branches = _repository.GetBranchSpecs(opts);
See Also