branch: have git_branch_lookup accept GIT_BRANCH_ALL

parent 0a25141e
......@@ -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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment