Skip to content

Commit e22ffb4

Browse files
committed
Fixed update_tips callback called for failed pushed references
The current implementation does not set 'fire_callback' back to 0 for failed updates so the callback still fires. Instead of adding yet another condition check to set 'fire_callback' to 0 if needed, considering this function should be a no-op for failed updates anyway, the best fix is to simplify its logic to check upfront if the update is a failed one.
1 parent fe21d70 commit e22ffb4

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/push.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ int git_push_update_tips(git_push *push)
180180
git_vector_foreach(&push->status, i, status) {
181181
int fire_callback = 1;
182182

183+
/* Skip unsuccessful updates which have non-empty messages */
184+
if (status->msg)
185+
continue;
186+
183187
/* Find the corresponding remote ref */
184188
fetch_spec = git_remote__matching_refspec(push->remote, status->ref);
185189
if (!fetch_spec)
@@ -198,21 +202,18 @@ int git_push_update_tips(git_push *push)
198202
if (j == push->specs.length)
199203
continue;
200204

201-
/* If this ref update was successful (ok, not ng), it will have an empty message */
202-
if (status->msg == NULL) {
203-
/* Update the remote ref */
204-
if (git_oid_iszero(&push_spec->loid)) {
205-
error = git_reference_lookup(&remote_ref, push->remote->repo, git_buf_cstr(&remote_ref_name));
205+
/* Update the remote ref */
206+
if (git_oid_iszero(&push_spec->loid)) {
207+
error = git_reference_lookup(&remote_ref, push->remote->repo, git_buf_cstr(&remote_ref_name));
206208

207-
if (error >= 0) {
208-
error = git_reference_delete(remote_ref);
209-
git_reference_free(remote_ref);
210-
}
211-
} else {
212-
error = git_reference_create(NULL, push->remote->repo,
213-
git_buf_cstr(&remote_ref_name), &push_spec->loid, 1,
214-
"update by push");
209+
if (error >= 0) {
210+
error = git_reference_delete(remote_ref);
211+
git_reference_free(remote_ref);
215212
}
213+
} else {
214+
error = git_reference_create(NULL, push->remote->repo,
215+
git_buf_cstr(&remote_ref_name), &push_spec->loid, 1,
216+
"update by push");
216217
}
217218

218219
if (error < 0) {

0 commit comments

Comments
 (0)