diff options
author | Russell Belfer <rb@github.com> | 2013-05-01 15:48:40 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-05-01 15:48:40 -0700 |
commit | f470b00b037cfcd40e19e88913a9a8b64d98288f (patch) | |
tree | 3800d336f00b72af767d59cafd61b6c50a28bded /src | |
parent | 1a9e406c218e3d5a174bc4f8dce0333d73d7bbff (diff) | |
download | libgit2-f470b00b037cfcd40e19e88913a9a8b64d98288f.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/revparse.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/revparse.c b/src/revparse.c index 8a22a04f3..e8cc32aff 100644 --- a/src/revparse.c +++ b/src/revparse.c @@ -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; |