Fire update_tips callback also for pushes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
diff --git a/src/push.c b/src/push.c
index bd4d872..9943f21 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;