diff options
author | Pierre-Olivier Latour <pol@mac.com> | 2015-03-05 22:13:54 -0800 |
---|---|---|
committer | Pierre-Olivier Latour <pol@mac.com> | 2015-03-11 11:51:12 -0700 |
commit | e22ffb42097671f1c6737be4c8bbf2ff36a9e290 (patch) | |
tree | 89be6e7f9e5e713166d83d53d02f30f6ef10b459 /src/push.c | |
parent | fe21d708b02c1b35c0ea717889ea633fe78eabaf (diff) | |
download | libgit2-e22ffb42097671f1c6737be4c8bbf2ff36a9e290.tar.gz |
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.
Diffstat (limited to 'src/push.c')
-rw-r--r-- | src/push.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/push.c b/src/push.c index c6a93ba2f..d4171bbd6 100644 --- a/src/push.c +++ b/src/push.c @@ -180,6 +180,10 @@ int git_push_update_tips(git_push *push) git_vector_foreach(&push->status, i, status) { int fire_callback = 1; + /* Skip unsuccessful updates which have non-empty messages */ + if (status->msg) + continue; + /* Find the corresponding remote ref */ fetch_spec = git_remote__matching_refspec(push->remote, status->ref); if (!fetch_spec) @@ -198,21 +202,18 @@ int git_push_update_tips(git_push *push) if (j == push->specs.length) continue; - /* If this ref update was successful (ok, not ng), it will have an empty message */ - if (status->msg == NULL) { - /* Update the remote ref */ - if (git_oid_iszero(&push_spec->loid)) { - error = git_reference_lookup(&remote_ref, push->remote->repo, git_buf_cstr(&remote_ref_name)); + /* Update the remote ref */ + if (git_oid_iszero(&push_spec->loid)) { + error = git_reference_lookup(&remote_ref, push->remote->repo, git_buf_cstr(&remote_ref_name)); - if (error >= 0) { - error = git_reference_delete(remote_ref); - git_reference_free(remote_ref); - } - } else { - error = git_reference_create(NULL, push->remote->repo, - git_buf_cstr(&remote_ref_name), &push_spec->loid, 1, - "update by push"); + if (error >= 0) { + error = git_reference_delete(remote_ref); + git_reference_free(remote_ref); } + } else { + error = git_reference_create(NULL, push->remote->repo, + git_buf_cstr(&remote_ref_name), &push_spec->loid, 1, + "update by push"); } if (error < 0) { |