mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-21 12:24:58 +00:00
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.
This commit is contained in:
parent
fe21d708b0
commit
e22ffb4209
27
src/push.c
27
src/push.c
@ -180,6 +180,10 @@ int git_push_update_tips(git_push *push)
|
|||||||
git_vector_foreach(&push->status, i, status) {
|
git_vector_foreach(&push->status, i, status) {
|
||||||
int fire_callback = 1;
|
int fire_callback = 1;
|
||||||
|
|
||||||
|
/* Skip unsuccessful updates which have non-empty messages */
|
||||||
|
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);
|
||||||
if (!fetch_spec)
|
if (!fetch_spec)
|
||||||
@ -198,21 +202,18 @@ int git_push_update_tips(git_push *push)
|
|||||||
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 */
|
/* Update the remote ref */
|
||||||
if (status->msg == NULL) {
|
if (git_oid_iszero(&push_spec->loid)) {
|
||||||
/* Update the remote ref */
|
error = git_reference_lookup(&remote_ref, push->remote->repo, git_buf_cstr(&remote_ref_name));
|
||||||
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) {
|
if (error >= 0) {
|
||||||
error = git_reference_delete(remote_ref);
|
error = git_reference_delete(remote_ref);
|
||||||
git_reference_free(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");
|
|
||||||
}
|
}
|
||||||
|
} 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) {
|
if (error < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user