summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2020-02-07 11:57:48 +0100
committerPatrick Steinhardt <ps@pks.im>2020-02-07 13:04:02 +0100
commit6eebfc06989c42132f58b9f0b40283b067dd8613 (patch)
tree45eddfaa8617c50be3d89095e6fe76e251c2d037
parent31a577d066f8b56901dc84d2addef97280463ac9 (diff)
downloadlibgit2-6eebfc06989c42132f58b9f0b40283b067dd8613.tar.gz
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.
-rw-r--r--src/push.c5
-rw-r--r--src/revwalk.c2
2 files changed, 4 insertions, 3 deletions
diff --git a/src/push.c b/src/push.c
index 67ebcfb3e..34867c2e4 100644
--- a/src/push.c
+++ b/src/push.c
@@ -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);
diff --git a/src/revwalk.c b/src/revwalk.c
index 4587b5acc..abbd65ac2 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -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;