summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAugustin Fabre <augustin@augfab.fr>2019-02-21 21:46:39 +0100
committerAugustin Fabre <augustin@augfab.fr>2019-02-22 22:19:44 +0100
commitc5d8e3006d98023d1540f1404b28a5db1ca0ecd2 (patch)
tree2c6b3fce8c20c0b532736101bcff9a9a42de7491 /src
parent0a25141e7b39ed0bda19a97dbfcbe4789779a5c9 (diff)
downloadlibgit2-c5d8e3006d98023d1540f1404b28a5db1ca0ecd2.tar.gz
branch: have git_branch_lookup accept GIT_BRANCH_ALL
Diffstat (limited to 'src')
-rw-r--r--src/branch.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/branch.c b/src/branch.c
index 7c6d747b4..a93db7e5b 100644
--- a/src/branch.c
+++ b/src/branch.c
@@ -22,7 +22,7 @@ static int retrieve_branch_reference(
git_reference **branch_reference_out,
git_repository *repo,
const char *branch_name,
- int is_remote)
+ bool is_remote)
{
git_reference *branch = NULL;
int error = 0;
@@ -334,9 +334,23 @@ int git_branch_lookup(
const char *branch_name,
git_branch_t branch_type)
{
+ int error = -1;
assert(ref_out && repo && branch_name);
- return retrieve_branch_reference(ref_out, repo, branch_name, branch_type == GIT_BRANCH_REMOTE);
+ switch (branch_type) {
+ case GIT_BRANCH_LOCAL:
+ case GIT_BRANCH_REMOTE:
+ error = retrieve_branch_reference(ref_out, repo, branch_name, branch_type == GIT_BRANCH_REMOTE);
+ break;
+ case GIT_BRANCH_ALL:
+ error = retrieve_branch_reference(ref_out, repo, branch_name, false);
+ if (error == GIT_ENOTFOUND)
+ error = retrieve_branch_reference(ref_out, repo, branch_name, true);
+ break;
+ default:
+ assert(false);
+ }
+ return error;
}
int git_branch_name(