From patchwork Tue Sep 15 09:58:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Xin X-Patchwork-Id: 11775949 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A2B5618 for ; Tue, 15 Sep 2020 09:58:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7040D21D1B for ; Tue, 15 Sep 2020 09:58:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c35QBtw7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726244AbgIOJ6f (ORCPT ); Tue, 15 Sep 2020 05:58:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726169AbgIOJ6e (ORCPT ); Tue, 15 Sep 2020 05:58:34 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E616C06174A for ; Tue, 15 Sep 2020 02:58:34 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id r19so1074478pls.1 for ; Tue, 15 Sep 2020 02:58:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7IoT8GOmscal161OYichbAoqU3UPkvQAY6LdkJudSZ8=; b=c35QBtw7KJ0ztnc4GJvGJIxTS8JnIUFtWvobcMGWuRABvbWuJ9Qt1Y5PxFAabDl9MZ 70ia/Rp7GoEcglpC7yCOKLx1Cf840565HRs36rRa4edyFMwf05ySBIDHMttaGcj++0BF g7GW2nMNGVo4u8zswYVeiGclIIyRqd4SEFuZSl4yag3y4PgK7Are9tZ5HZ6Dd+nE+Fv9 Jqy4ICOYl0eVLmPewXkMfyQbC2RpNntv6nVpDzE3W/Sx3iA8MFAs2KTlRDh2cMCTXGjk GD/x2mGEZczFeqZniJ0wZyUP1r+NBjwhv4g6Y5fUfbldU9+wB2d+Zg5V+30Rp0LgeeV+ uyKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7IoT8GOmscal161OYichbAoqU3UPkvQAY6LdkJudSZ8=; b=C5W5uWz8Uf0ufuK3reGsN5Nm6NL9+ygnKgq1mg/71pYAO5BeT0Q5Q+pr4V0npH3uqR I3xe4FRKEkFgZIIuQf4a0MgMs05SQ8U2H5VtoxAPfD3UZkeJq+KM16pPRUTGOwt74ZXg j+HdnuoG2Mbuiz3+wLSD6ulLFYsf0eqFUr3gFYmSOmMooCEgdJSix1wvUIyQlcZQl0HL eaTZmPrmkjFYx2eNXBt8ZuZfB3jVIbh5P6iFN1OFTqwmMFaH50u7KAs/EFWZkP5WQlmx NtReOlNmrNfENiUbU/8jHvsp6/jaZiruy/WrMEQ0eS+wiDHi67ZuYqZywf+MMYPhRzRW +I2A== X-Gm-Message-State: AOAM5306J/vijbto8s/VlA75loBDSdFa0lMiPQIJvjbOfNXEYbdxzrAt dCs871GmGunq714TfHvci1M= X-Google-Smtp-Source: ABdhPJxJORJ5hrB3G4iJiyxgq/uAFru4+4nfcVJhtpqIlZoL7IldNMPIibuf94Xrr39eFOdzrtHJ1g== X-Received: by 2002:a17:90a:d702:: with SMTP id y2mr3469043pju.216.1600163913736; Tue, 15 Sep 2020 02:58:33 -0700 (PDT) Received: from localhost.localdomain ([205.204.117.14]) by smtp.gmail.com with ESMTPSA id i62sm12839400pfe.140.2020.09.15.02.58.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2020 02:58:33 -0700 (PDT) From: Han Xin X-Google-Original-From: Han Xin To: Junio C Hamano , Git List Cc: Han Xin , Jiang Xin Subject: [PATCH 1/2] t5534: new test case for atomic signed push Date: Tue, 15 Sep 2020 17:58:26 +0800 Message-Id: <20200915095827.52047-1-hanxin.hx@alibaba-inc.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In order to test signed atomic push, add a new test case. Reviewed-by: Jiang Xin Signed-off-by: Han Xin --- t/t5534-push-signed.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/t/t5534-push-signed.sh b/t/t5534-push-signed.sh index 030331f1c5..d0fcdc900e 100755 --- a/t/t5534-push-signed.sh +++ b/t/t5534-push-signed.sh @@ -273,4 +273,21 @@ 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' ' + prepare_dst && + git -C dst config receive.certnonceseed sekrit && + write_script gpg <<-EOF && + echo >&2 "Fake gpg is called." + exit 1 + EOF + test_must_fail env PATH="$TRASH_DIRECTORY:$PATH" git push --signed --atomic \ + dst noop ff noff >out 2>&1 && + grep "^error:" out >actual && + cat >expect <<-EOF && + error: atomic push failed for ref refs/heads/noff. status: 2 + error: failed to push some refs to '"'"'dst'"'"' + EOF + test_i18ncmp expect actual +' + test_done From patchwork Tue Sep 15 09:58:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Xin X-Patchwork-Id: 11775951 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3515C618 for ; Tue, 15 Sep 2020 09:59:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13ABA21974 for ; Tue, 15 Sep 2020 09:59:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UHU6Ytvr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726157AbgIOJ66 (ORCPT ); Tue, 15 Sep 2020 05:58:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726130AbgIOJ65 (ORCPT ); Tue, 15 Sep 2020 05:58:57 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB6C5C06174A for ; Tue, 15 Sep 2020 02:58:56 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id f2so1730498pgd.3 for ; Tue, 15 Sep 2020 02:58:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jTZQ31mtMWxwSvHvDRHm45lHcgOK3Fudagf4JUQTq+s=; b=UHU6Ytvr9L7/7FYGdzNTJfp6JEhVGCrlYaVvLGbKSgOyE4Zbq7viY2ZiyguzURwBPe O8DJ6AtDXdGxkMmNl386vWop4CUR/L0PtvoiXhu0fqFwY+Gqnszbg3froujH3n0oeQBp uuV9UmOA2rmg1easIeEF74wLOU9ce3cuV3W6w8dNn2Wb0Wz6pD3Y+74bpe2gtlTSMZMp ow64uOWvsHGYEl/JvF3f6+6+uH7I1r1E9+0GVMiiQVzOj3LJsUvgIJkKafMq8m7UZAWO qPHhooQV6EYhrsATWRQjGBCnPrGSh1oXt0x0RSh7oIWct85FPkKroGUIR8nfG8kHRkgZ s/VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jTZQ31mtMWxwSvHvDRHm45lHcgOK3Fudagf4JUQTq+s=; b=J1jYX8deBO9e9KCLkkmoSJ4lrhV1aC4QLTlk/HJ1ljx/gosiVDkFRfnFvmyCrj7d0H SIF6vVd3cX/K0RoN7lxiGXABJad04Y8muVtGvUlFFGOAz9XsRI5xy7Kvm4JSFpYgh0aH djS/FvlxOv7VlqF0NHf7Gd1MLPaGSSssFHDz4TU1Q+eYbBwU7PiKDMF6QmhLKjjc7PFY KCT6cQ4z7BuLl51P5j1G6yVvZd2Gp/YY6fe0pFZOeDAtFaqBwQA4/RvmHIvlA3ApXpiv W2J9xGKvyOFX9V8wwaVmIbz6DAQQd9IE67HjSenUoemlMbsH/C7a3yPRTf8K0rI4vHRz Isfw== X-Gm-Message-State: AOAM532f7ba6yyVMB3Vkgoak7EbUsY0yS4+kiyJ+5RvbfiwVdQgz+Nqo HJrwPur8TiCALUmyVjj0tpY= X-Google-Smtp-Source: ABdhPJwF9IkY9A8HwjjLRhN48YL2+sbo32tFKEnpltd3pFXlCFdP/aIOWye51+eC02Ws96/xIFWMwA== X-Received: by 2002:a62:cfc5:0:b029:13e:d13d:a083 with SMTP id b188-20020a62cfc50000b029013ed13da083mr17464651pfg.26.1600163936310; Tue, 15 Sep 2020 02:58:56 -0700 (PDT) Received: from localhost.localdomain ([205.204.117.14]) by smtp.gmail.com with ESMTPSA id i62sm12839400pfe.140.2020.09.15.02.58.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2020 02:58:55 -0700 (PDT) From: Han Xin X-Google-Original-From: Han Xin To: Junio C Hamano , Git List Cc: Han Xin , Jiang Xin Subject: [PATCH 2/2] send-pack: check atomic push before running GPG Date: Tue, 15 Sep 2020 17:58:27 +0800 Message-Id: <20200915095827.52047-2-hanxin.hx@alibaba-inc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915095827.52047-1-hanxin.hx@alibaba-inc.com> References: <20200915095827.52047-1-hanxin.hx@alibaba-inc.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 Signed-off-by: Han Xin --- 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 &&