diff options
author | Jacques Germishuys <jacquesg@striata.com> | 2014-04-21 17:02:05 +0200 |
---|---|---|
committer | Jacques Germishuys <jacquesg@striata.com> | 2014-04-21 17:28:03 +0200 |
commit | 321d377a6ad3528f38ab99dacf22a51f721fa57b (patch) | |
tree | 3259dfeb3b43068a7a9a20d5be371e6a55d7ad5b | |
parent | 8b686b318b60e39ef36aae14311c07e5b72a5a5a (diff) | |
download | libgit2-321d377a6ad3528f38ab99dacf22a51f721fa57b.tar.gz |
Fire update_tips callback also for pushes.
-rw-r--r-- | src/push.c | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/src/push.c b/src/push.c index bd4d872c5..9943f215c 100644 --- a/src/push.c +++ b/src/push.c @@ -208,9 +208,7 @@ int git_push_update_tips( int error = 0; git_vector_foreach(&push->status, i, status) { - /* If this ref update was successful (ok, not ng), it will have an empty message */ - if (status->msg) - continue; + int fire_callback = 1; /* Find the corresponding remote ref */ fetch_spec = git_remote__matching_refspec(push->remote, status->ref); @@ -230,24 +228,38 @@ int git_push_update_tips( if (j == push->specs.length) continue; - /* 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 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)); - if (!error) { - if ((error = git_reference_delete(remote_ref)) < 0) { + if (error >= 0) { + error = git_reference_delete(remote_ref); git_reference_free(remote_ref); - goto on_error; } - git_reference_free(remote_ref); - } else if (error == GIT_ENOTFOUND) - giterr_clear(); - else + } else { + error = git_reference_create(NULL, push->remote->repo, + git_buf_cstr(&remote_ref_name), &push_spec->loid, 1, signature, + reflog_message ? reflog_message : "update by push"); + } + } + + if (error < 0) { + if (error != GIT_ENOTFOUND) goto on_error; - } else if ((error = git_reference_create(NULL, push->remote->repo, - git_buf_cstr(&remote_ref_name), &push_spec->loid, 1, signature, - reflog_message ? reflog_message : "update by push")) < 0) - goto on_error; + + giterr_clear(); + fire_callback = 0; + } + + if (fire_callback && push->remote->callbacks.update_tips) { + error = push->remote->callbacks.update_tips(git_buf_cstr(&remote_ref_name), + &push_spec->roid, &push_spec->loid, push->remote->callbacks.payload); + + if (error < 0) + goto on_error; + } } error = 0; |