summaryrefslogtreecommitdiff
path: root/src/revparse.c
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2013-05-06 06:45:53 -0700
committerVicent Martí <vicent@github.com>2013-05-06 06:45:53 -0700
commit03c28d92d00074f1501cb0d7ce9f5e3e0154a244 (patch)
tree64c394dc10a839fd0766a800ff31a1d0236360d6 /src/revparse.c
parentd5e5bbd7193924aa845e107f747a15814a679b10 (diff)
parent6e286e8dc59874db30b6fbb0ca5d32d4a2b5642c (diff)
downloadlibgit2-03c28d92d00074f1501cb0d7ce9f5e3e0154a244.tar.gz
Merge pull request #1526 from arrbee/cleanup-error-return-without-msg
Make sure error messages are set for most error returns
Diffstat (limited to 'src/revparse.c')
-rw-r--r--src/revparse.c9
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;