Rev-parse: proper error checking.

This commit is contained in:
Ben Straub 2012-05-10 15:07:04 -07:00
parent 7e79d389a4
commit 94952ded3a

View File

@ -169,10 +169,9 @@ static int walk_ref_history(git_object **out, git_repository *repo, const char *
giterr_set(GITERR_INVALID, "Invalid reflogspec %s", reflogspec);
return GIT_ERROR;
}
git_reference_lookup(&ref, repo, "HEAD");
git_reflog_read(&reflog, ref);
git_reference_free(ref);
if (!git_reference_lookup(&ref, repo, "HEAD")) {
if (!git_reflog_read(&reflog, ref)) {
regex_error = regcomp(&regex, "checkout: moving from (.*) to .*", REG_EXTENDED);
if (regex_error != 0) {
giterr_set_regex(&regex, regex_error);
@ -196,6 +195,9 @@ static int walk_ref_history(git_object **out, git_repository *repo, const char *
}
regfree(&regex);
}
}
git_reference_free(ref);
}
} else {
git_buf datebuf = GIT_BUF_INIT;
git_buf_put(&datebuf, reflogspec+2, reflogspeclen-3);