Skip to content

Commit 6eebfc0

Browse files
committed
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.
1 parent 31a577d commit 6eebfc0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/push.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,9 @@ static int queue_objects(git_push *push)
349349
if (git_oid_is_zero(&head->oid))
350350
continue;
351351

352-
/* TODO */
353-
git_revwalk_hide(rw, &head->oid);
352+
if ((error = git_revwalk_hide(rw, &head->oid)) < 0 &&
353+
error != GIT_ENOTFOUND && error != GIT_EINVALIDSPEC && error != GIT_EPEEL)
354+
goto on_error;
354355
}
355356

356357
error = git_packbuilder_insert_walk(push->pb, rw);

src/revwalk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int git_revwalk__push_commit(git_revwalk *walk, const git_oid *oid, const git_re
5858
return 0;
5959

6060
git_error_set(GIT_ERROR_INVALID, "object is not a committish");
61-
return -1;
61+
return error;
6262
}
6363
if (error < 0)
6464
return error;

0 commit comments

Comments
 (0)