Commit f470b00b by Russell Belfer

Fix one error not reported in revparse

There are many paths through revparse that may return an error
code without reporting an error, I believe.  This fixes one of
them.  Because of the backtracking in revparse, it is pretty
complicated to fix the others.
parent 1a9e406c
......@@ -17,7 +17,7 @@
static int disambiguate_refname(git_reference **out, git_repository *repo, const char *refname)
{
int error = 0, i;
bool fallbackmode = true;
bool fallbackmode = true, foundvalid = false;
git_reference *ref;
git_buf refnamebuf = GIT_BUF_INIT, name = GIT_BUF_INIT;
......@@ -49,6 +49,7 @@ static int disambiguate_refname(git_reference **out, git_repository *repo, const
error = GIT_EINVALIDSPEC;
continue;
}
foundvalid = true;
error = git_reference_lookup_resolved(&ref, repo, git_buf_cstr(&refnamebuf), -1);
......@@ -63,6 +64,12 @@ static int disambiguate_refname(git_reference **out, git_repository *repo, const
}
cleanup:
if (error && !foundvalid) {
/* never found a valid reference name */
giterr_set(GITERR_REFERENCE,
"Could not use '%s' as valid reference name", git_buf_cstr(&name));
}
git_buf_free(&name);
git_buf_free(&refnamebuf);
return error;
......
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