mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-09 15:00:04 +00:00
Rev-parse: proper error checking.
This commit is contained in:
parent
7e79d389a4
commit
94952ded3a
@ -169,32 +169,34 @@ static int walk_ref_history(git_object **out, git_repository *repo, const char *
|
|||||||
giterr_set(GITERR_INVALID, "Invalid reflogspec %s", reflogspec);
|
giterr_set(GITERR_INVALID, "Invalid reflogspec %s", reflogspec);
|
||||||
return GIT_ERROR;
|
return GIT_ERROR;
|
||||||
}
|
}
|
||||||
git_reference_lookup(&ref, repo, "HEAD");
|
|
||||||
git_reflog_read(&reflog, ref);
|
|
||||||
git_reference_free(ref);
|
|
||||||
|
|
||||||
regex_error = regcomp(®ex, "checkout: moving from (.*) to .*", REG_EXTENDED);
|
if (!git_reference_lookup(&ref, repo, "HEAD")) {
|
||||||
if (regex_error != 0) {
|
if (!git_reflog_read(&reflog, ref)) {
|
||||||
giterr_set_regex(®ex, regex_error);
|
regex_error = regcomp(®ex, "checkout: moving from (.*) to .*", REG_EXTENDED);
|
||||||
} else {
|
if (regex_error != 0) {
|
||||||
regmatch_t regexmatches[2];
|
giterr_set_regex(®ex, regex_error);
|
||||||
|
} else {
|
||||||
|
regmatch_t regexmatches[2];
|
||||||
|
|
||||||
refloglen = git_reflog_entrycount(reflog);
|
refloglen = git_reflog_entrycount(reflog);
|
||||||
for (i=refloglen-1; i >= 0; i--) {
|
for (i=refloglen-1; i >= 0; i--) {
|
||||||
const char *msg;
|
const char *msg;
|
||||||
entry = git_reflog_entry_byindex(reflog, i);
|
entry = git_reflog_entry_byindex(reflog, i);
|
||||||
|
|
||||||
msg = git_reflog_entry_msg(entry);
|
msg = git_reflog_entry_msg(entry);
|
||||||
if (!regexec(®ex, msg, 2, regexmatches, 0)) {
|
if (!regexec(®ex, msg, 2, regexmatches, 0)) {
|
||||||
n--;
|
n--;
|
||||||
if (!n) {
|
if (!n) {
|
||||||
git_buf_put(&buf, msg+regexmatches[1].rm_so, regexmatches[1].rm_eo - regexmatches[1].rm_so);
|
git_buf_put(&buf, msg+regexmatches[1].rm_so, regexmatches[1].rm_eo - regexmatches[1].rm_so);
|
||||||
retcode = revparse_lookup_object(out, repo, git_buf_cstr(&buf));
|
retcode = revparse_lookup_object(out, repo, git_buf_cstr(&buf));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
regfree(®ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
regfree(®ex);
|
git_reference_free(ref);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
git_buf datebuf = GIT_BUF_INIT;
|
git_buf datebuf = GIT_BUF_INIT;
|
||||||
|
Loading…
Reference in New Issue
Block a user