Rev-parse: better error handling for chaining.

Fixed an error where "nonexistant^N" or similar
would fall into an assert. This now properly returns
an error.
This commit is contained in:
Ben Straub 2012-05-11 11:58:02 -07:00
parent 92ad5a5cda
commit 72b86bae50
2 changed files with 6 additions and 1 deletions

View File

@ -564,7 +564,10 @@ int git_revparse_single(git_object **out, git_repository *repo, const char *spec
if (current_state != next_state && next_state != REVPARSE_STATE_DONE) { if (current_state != next_state && next_state != REVPARSE_STATE_DONE) {
/* Leaving INIT state, find the object specified, in case that state needs it */ /* Leaving INIT state, find the object specified, in case that state needs it */
revparse_lookup_object(&next_obj, repo, git_buf_cstr(&specbuffer)); if (revparse_lookup_object(&next_obj, repo, git_buf_cstr(&specbuffer)) < 0) {
retcode = GIT_ERROR;
next_state = REVPARSE_STATE_DONE;
}
} }
break; break;

View File

@ -36,6 +36,8 @@ void test_refs_revparse__cleanup(void)
void test_refs_revparse__nonexistant_object(void) void test_refs_revparse__nonexistant_object(void)
{ {
cl_git_fail(git_revparse_single(&g_obj, g_repo, "this doesn't exist")); cl_git_fail(git_revparse_single(&g_obj, g_repo, "this doesn't exist"));
cl_git_fail(git_revparse_single(&g_obj, g_repo, "this doesn't exist^1"));
cl_git_fail(git_revparse_single(&g_obj, g_repo, "this doesn't exist~2"));
} }
void test_refs_revparse__shas(void) void test_refs_revparse__shas(void)