Commit b57221e8 by Miguel Arroz

#6422: handle dangling symbolic refs gracefully

parent a3841af5
......@@ -121,8 +121,12 @@ int git_revwalk__push_ref(git_revwalk *walk, const char *refname, const git_revw
{
git_oid oid;
if (git_reference_name_to_id(&oid, walk->repo, refname) < 0)
int error = git_reference_name_to_id(&oid, walk->repo, refname);
if (opts->from_glob && (error == GIT_ENOTFOUND || error == GIT_EINVALIDSPEC || error == GIT_EPEEL)) {
return 0;
} else if (error < 0) {
return -1;
}
return git_revwalk__push_commit(walk, &oid, opts);
}
......
......@@ -180,6 +180,23 @@ void test_revwalk_basic__glob_heads_with_invalid(void)
cl_assert_equal_i(20, i);
}
void test_revwalk_basic__glob_invalid_symbolic_ref(void)
{
int i;
git_oid oid;
revwalk_basic_setup_walk("testrepo");
cl_git_mkfile("testrepo/.git/refs/heads/broken-sym-ref", "ref: refs/heads/does-not-exist");
cl_git_pass(git_revwalk_push_glob(_walk, "heads"));
for (i = 0; !git_revwalk_next(&oid, _walk); ++i)
/* walking */;
/* git log --branches --oneline | wc -l => 16 */
cl_assert_equal_i(20, i);
}
void test_revwalk_basic__push_head(void)
{
int i = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment