Commit 6eebfc06 by Patrick Steinhardt

push: check error code returned by `git_revwalk_hide`

When queueing objects we want to push, we call `git_revwalk_hide` to
hide all objects already known to the remote from our revwalk. We do not
check its return value though, where the orginial intent was to ignore
the case where the pushed OID is not a known committish. As
`git_revwalk_hide` can fail due to other reasons like out-of-memory
exceptions, we should still check its return value.

Fix the issue by checking the function's return value, ignoring
errors hinting that it's not a committish. As `git_revwalk__push_commit`
currently clobbers these error codes, we need to adjust it as well in
order to make it available downstream.
parent 31a577d0
......@@ -349,8 +349,9 @@ static int queue_objects(git_push *push)
if (git_oid_is_zero(&head->oid))
continue;
/* TODO */
git_revwalk_hide(rw, &head->oid);
if ((error = git_revwalk_hide(rw, &head->oid)) < 0 &&
error != GIT_ENOTFOUND && error != GIT_EINVALIDSPEC && error != GIT_EPEEL)
goto on_error;
}
error = git_packbuilder_insert_walk(push->pb, rw);
......
......@@ -58,7 +58,7 @@ int git_revwalk__push_commit(git_revwalk *walk, const git_oid *oid, const git_re
return 0;
git_error_set(GIT_ERROR_INVALID, "object is not a committish");
return -1;
return error;
}
if (error < 0)
return error;
......
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