Commit 321d377a by Jacques Germishuys

Fire update_tips callback also for pushes.

parent 8b686b31
...@@ -208,9 +208,7 @@ int git_push_update_tips( ...@@ -208,9 +208,7 @@ int git_push_update_tips(
int error = 0; int error = 0;
git_vector_foreach(&push->status, i, status) { git_vector_foreach(&push->status, i, status) {
/* If this ref update was successful (ok, not ng), it will have an empty message */ int fire_callback = 1;
if (status->msg)
continue;
/* Find the corresponding remote ref */ /* Find the corresponding remote ref */
fetch_spec = git_remote__matching_refspec(push->remote, status->ref); fetch_spec = git_remote__matching_refspec(push->remote, status->ref);
...@@ -230,25 +228,39 @@ int git_push_update_tips( ...@@ -230,25 +228,39 @@ int git_push_update_tips(
if (j == push->specs.length) if (j == push->specs.length)
continue; continue;
/* If this ref update was successful (ok, not ng), it will have an empty message */
if (status->msg == NULL) {
/* Update the remote ref */ /* Update the remote ref */
if (git_oid_iszero(&push_spec->loid)) { if (git_oid_iszero(&push_spec->loid)) {
error = git_reference_lookup(&remote_ref, push->remote->repo, git_buf_cstr(&remote_ref_name)); error = git_reference_lookup(&remote_ref, push->remote->repo, git_buf_cstr(&remote_ref_name));
if (!error) { if (error >= 0) {
if ((error = git_reference_delete(remote_ref)) < 0) { error = git_reference_delete(remote_ref);
git_reference_free(remote_ref); git_reference_free(remote_ref);
goto on_error;
} }
git_reference_free(remote_ref); } else {
} else if (error == GIT_ENOTFOUND) error = git_reference_create(NULL, push->remote->repo,
giterr_clear();
else
goto on_error;
} else if ((error = git_reference_create(NULL, push->remote->repo,
git_buf_cstr(&remote_ref_name), &push_spec->loid, 1, signature, git_buf_cstr(&remote_ref_name), &push_spec->loid, 1, signature,
reflog_message ? reflog_message : "update by push")) < 0) reflog_message ? reflog_message : "update by push");
}
}
if (error < 0) {
if (error != GIT_ENOTFOUND)
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; goto on_error;
} }
}
error = 0; error = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment