Atomic push may be rejected, which makes it meanigless to generate push cert first. Therefore, the push cert generation was moved after atomic check. Reviewed-by: Jiang Xin <zhiyou.jx@xxxxxxxxxxxxxxx> Signed-off-by: Han Xin <hanxin.hx@xxxxxxxxxxxxxxx> --- send-pack.c | 14 +++++++------- t/t5534-push-signed.sh | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/send-pack.c b/send-pack.c index d671ab5d05..58416a6f6d 100644 --- a/send-pack.c +++ b/send-pack.c @@ -447,13 +447,6 @@ int send_pack(struct send_pack_args *args, if (ref->deletion && !allow_deleting_refs) ref->status = REF_STATUS_REJECT_NODELETE; - if (!args->dry_run) - advertise_shallow_grafts_buf(&req_buf); - - if (!args->dry_run && push_cert_nonce) - cmds_sent = generate_push_cert(&req_buf, remote_refs, args, - cap_buf.buf, push_cert_nonce); - /* * Clear the status for each ref and see if we need to send * the pack data. @@ -489,6 +482,13 @@ int send_pack(struct send_pack_args *args, ref->status = REF_STATUS_EXPECTING_REPORT; } + if (!args->dry_run) + advertise_shallow_grafts_buf(&req_buf); + + if (!args->dry_run && push_cert_nonce) + cmds_sent = generate_push_cert(&req_buf, remote_refs, args, + cap_buf.buf, push_cert_nonce); + /* * Finally, tell the other end! */ diff --git a/t/t5534-push-signed.sh b/t/t5534-push-signed.sh index d0fcdc900e..927750a408 100755 --- a/t/t5534-push-signed.sh +++ b/t/t5534-push-signed.sh @@ -273,7 +273,7 @@ test_expect_success GPGSM 'fail without key and heed user.signingkey x509' ' test_cmp expect dst/push-cert-status ' -test_expect_failure GPG 'check atomic push before running GPG' ' +test_expect_success GPG 'check atomic push before running GPG' ' prepare_dst && git -C dst config receive.certnonceseed sekrit && write_script gpg <<-EOF && -- 2.28.0