From patchwork Thu Jun 17 03:17:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 12326417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5444C48BE8 for ; Thu, 17 Jun 2021 03:17:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B7116613DE for ; Thu, 17 Jun 2021 03:17:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229569AbhFQDTm (ORCPT ); Wed, 16 Jun 2021 23:19:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229502AbhFQDTl (ORCPT ); Wed, 16 Jun 2021 23:19:41 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BED5EC061574 for ; Wed, 16 Jun 2021 20:17:33 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id v7so3778105pgl.2 for ; Wed, 16 Jun 2021 20:17:33 -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=uGI6Is+Wz7vysiC/Tg8KKBXsSfL7fyWwC9dTfE5WJuM=; b=qwMfkEbTQXHCyJeaT5U5p9Yf6lSQKbJQMdXsITaQpvd4WSZZdM63b0tt7+lD0hl8nh Zka1hLmkTIXnTi2wLaaiV8QuDA67TYA67ZKZWhpMslizzQgq5/QkoeEMv8caIWr5ndd+ 5O/ZkYwqoYnOcH2dqMeYJHjClPaCZMPazsEQ4CE8RRywFARYmU12tm9LySlHLWMhX4tB /IPFM4wLKcO2Y3lFGfeDFVbadZCt5R0QFzWLaNueT5V52FhWRLvj0G7bqISCGtUqP59j 5YgnLw4nKNzREDybpGbyiqiWzQZsN046VRyGkuHDUqqJUMN203sDwQuc95RTlNRxC0dr OJ+A== 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=uGI6Is+Wz7vysiC/Tg8KKBXsSfL7fyWwC9dTfE5WJuM=; b=HszpeWc5f8Qs2PZPs0WFm+KxddbFU9n6gSa1dCzkG03xCKObRbiii2ZDPCdk+mpnN5 u1Z+UkJju8Z5nLSB9WAQMGjOhNXnqWHCJxeTjnhIkLtPBwh4cD/DJtTJ4tLkE3TDrERG iuymuPOvNEU3aXCEvS8oSkuJNY6lP7mL+tCmEgCZ5/KnjLJUU70zHBlN3hF3/vj9gAa0 4D6taQdHZxZ7cbBdgeccm+bBodhRkWz4igeWcaN5L8aoXqwlNf8WbV8KWIF4VHIOY19P EpSHE0NAe6YXDErio8Gz2bW36f08rPsGI+pWKqAkQ1A3DzGVQQL7hWofoG/cBFgpZzTG J73g== X-Gm-Message-State: AOAM530vr6SwG3GmspkblpneIhn6y+NN/YQEArckZze+/G7lxIodj2om UJDdY5lXZCLub4BngZdw2pM= X-Google-Smtp-Source: ABdhPJw4cvZcUnyNCWs9Ps/f/lzNpQh1sfuuR6gbnCqzy/Hd7memAAoQ5yorE4S8KCDN0eRGCXR2WA== X-Received: by 2002:aa7:8c02:0:b029:2e9:c513:1e10 with SMTP id c2-20020aa78c020000b02902e9c5131e10mr3155052pfd.2.1623899853240; Wed, 16 Jun 2021 20:17:33 -0700 (PDT) Received: from localhost.localdomain ([47.246.98.151]) by smtp.gmail.com with ESMTPSA id ei10sm3301726pjb.8.2021.06.16.20.17.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jun 2021 20:17:32 -0700 (PDT) From: Jiang Xin X-Google-Original-From: Jiang Xin To: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= , Junio C Hamano , Git List , Nicolas Pitre Cc: Jiang Xin Subject: [PATCH 1/4] sideband: don't lose clear-to-eol at packet boundary Date: Thu, 17 Jun 2021 11:17:24 +0800 Message-Id: <20210617031727.81105-1-zhiyou.jx@alibaba-inc.com> X-Mailer: git-send-email 2.32.0.rc0.27.g7b1e85181b MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When "demultiplex_sideband()" sees a nonempty message ending with CR or LF on the sideband #2, it adds "suffix" string to clear to the end of the current line, which helps when relaying a progress display whose records are terminated with CRs. But if it sees a single LF, no clear-to-end suffix should be appended, because this single LF is used to end the progress display by moving to the next line, and the final progress display above should be preserved. However, the code forgot that depending on the length of the payload line, such a CR may fall exactly at the packet boundary and the number of bytes before the CR from the beginning of the packet could be zero. In such a case, the message that was terminated by the CR were leftover in the "scratch" buffer in the previous call to the function and we still need to clear to the end of the current line. Helped-by: Junio C Hamano Helped-by: Nicolas Pitre Signed-off-by: Jiang Xin --- sideband.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sideband.c b/sideband.c index 6f9e026732..85bddfdcd4 100644 --- a/sideband.c +++ b/sideband.c @@ -183,8 +183,31 @@ int demultiplex_sideband(const char *me, int status, while ((brk = strpbrk(b, "\n\r"))) { int linelen = brk - b; + /* + * For message accross packet boundary, there would have + * a nonempty "scratch" buffer from last call of this + * function, and there may have a leading CR/LF in "buf". + * For this case we should add a clear-to-eol suffix to + * clean leftover letters we previously have written on + * the same line. + */ + if (scratch->len && !linelen) + strbuf_addstr(scratch, suffix); + if (!scratch->len) strbuf_addstr(scratch, DISPLAY_PREFIX); + + /* + * A use case that we should not add clear-to-eol suffix + * to empty lines: + * + * For progress reporting we may receive a bunch of + * percentage updates followed by '\r' to remain on the + * same line, and at the end receive a single '\n' to + * move to the next line. We should preserve the final + * status report line by not appending clear-to-eol + * suffix to this single line break. + */ if (linelen > 0) { maybe_colorize_sideband(scratch, b, linelen); strbuf_addstr(scratch, suffix); From patchwork Thu Jun 17 03:17:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 12326421 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A22ECC48BE5 for ; Thu, 17 Jun 2021 03:17:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66D95613E2 for ; Thu, 17 Jun 2021 03:17:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229693AbhFQDTq (ORCPT ); Wed, 16 Jun 2021 23:19:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbhFQDTo (ORCPT ); Wed, 16 Jun 2021 23:19:44 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A15BC061574 for ; Wed, 16 Jun 2021 20:17:37 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id o88-20020a17090a0a61b029016eeb2adf66so5061127pjo.4 for ; Wed, 16 Jun 2021 20:17:37 -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=oSKUFQ1vYuG2jSfxNl+2KWKA1AfbLn3DVEYjeCncEo4=; b=Mi9pVU6o/3yln5PlrD0u7Ryff4Ma5+9z5A2yY+RWBGH5T2+/DvL3ztskZ0TrSTAxt3 rrGrWjh1tQmoI662E8pios5jEj7mOjgE7LUZNfhKZJpYXlPl7f/ZGDyq/P91kdg9ZEbO /CdBQW6zgwbwuLT47lI68p2GTi/CVgojzoKkuTDwy88DAWBeqwA3OvWt7+IkVrqFFwMp A41B7UZCst5BblFtHWE4ODsxdf6ntxqMbuyWpJ5qhNl6GIG+COncU2a8Os5XB0Is2zGr NIdt81zWMAtnBxIqftnkFGRo6np50zlcZN+e7yFWeIlkl9FMaijwejL9W9unxvhhHf+B h+ug== 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=oSKUFQ1vYuG2jSfxNl+2KWKA1AfbLn3DVEYjeCncEo4=; b=IsGAWpNxLpACaSZQKn0h/JawU6bvKMrd711Uh8AhHy7kkxxXVgqpr4YFJaHisR5nOl nDMiYfuJq0Ab2FEeE+jpafYkrTwnrLaYsdfiGyBGp+z8RAMEmiTpcWy14+Kky3CsSvD0 9CWgN6138/E+7q0MIOmkibyrWmJmegv2GxwHMy+Nq2+UxEivbUegziX9+qyBSswEcsc0 yIV9AsX81/qgwKuLstxMB0QT0r3sMrw0/W4mFPgyzqPA2IK7gyzI6M3WgKJrufpQCuR5 /4j/3KyVTFPSY1o7lUZYVq/2BHp9HI3RJK/h/+hM+HBO93nFiVOutGe+lUl0dmHNspC4 Mchg== X-Gm-Message-State: AOAM533r8gBLB4HRxrIDknis5PfLndLZ89JVKU+Ookr+MtQUpw3CdTuH 0yuqe/4G28QpXsifnTzSUK8= X-Google-Smtp-Source: ABdhPJyfuKENB2t+c6YWxD+qs8wYM6AbpZghb0jhmPX1vb6crX1Ud1F/ghpMKPszfFO6ZwG4gvztuQ== X-Received: by 2002:a17:902:7085:b029:114:eb3f:fe29 with SMTP id z5-20020a1709027085b0290114eb3ffe29mr2586503plk.40.1623899855815; Wed, 16 Jun 2021 20:17:35 -0700 (PDT) Received: from localhost.localdomain ([47.246.98.151]) by smtp.gmail.com with ESMTPSA id ei10sm3301726pjb.8.2021.06.16.20.17.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jun 2021 20:17:35 -0700 (PDT) From: Jiang Xin X-Google-Original-From: Jiang Xin To: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= , Junio C Hamano , Git List , Nicolas Pitre Cc: Jiang Xin Subject: [PATCH 2/4] test: compare raw output, not mangle tabs and spaces Date: Thu, 17 Jun 2021 11:17:25 +0800 Message-Id: <20210617031727.81105-2-zhiyou.jx@alibaba-inc.com> X-Mailer: git-send-email 2.32.0.rc0.27.g7b1e85181b In-Reply-To: <20210617031727.81105-1-zhiyou.jx@alibaba-inc.com> References: <20210617031727.81105-1-zhiyou.jx@alibaba-inc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Before comparing with the expect file, we used to call function "make_user_friendly_and_stable_output" to filter out trailing spaces in output. Ævar recommends using pattern "s/Z$//" to prepare expect file, and then compare it with raw output. Since we have fixed the issue of occasionally missing the clear-to-eol suffix when displaying sideband #2 messages, it is safe and stable to test against raw output. Suggested-by: Ævar Arnfjörð Bjarmason Signed-off-by: Jiang Xin --- t/t5411/common-functions.sh | 9 +- t/t5411/test-0000-standard-git-push.sh | 82 +++---- .../test-0001-standard-git-push--porcelain.sh | 90 ++++---- ...st-0003-pre-receive-declined--porcelain.sh | 8 +- t/t5411/test-0011-no-hook-error.sh | 40 ++-- t/t5411/test-0012-no-hook-error--porcelain.sh | 42 ++-- t/t5411/test-0013-bad-protocol.sh | 62 +++--- t/t5411/test-0014-bad-protocol--porcelain.sh | 80 +++---- t/t5411/test-0020-report-ng.sh | 32 +-- t/t5411/test-0021-report-ng--porcelain.sh | 36 ++-- t/t5411/test-0022-report-unexpect-ref.sh | 26 +-- ...est-0023-report-unexpect-ref--porcelain.sh | 28 +-- t/t5411/test-0024-report-unknown-ref.sh | 18 +- ...test-0025-report-unknown-ref--porcelain.sh | 20 +- t/t5411/test-0026-push-options.sh | 58 ++--- t/t5411/test-0027-push-options--porcelain.sh | 62 +++--- t/t5411/test-0030-report-ok.sh | 20 +- t/t5411/test-0031-report-ok--porcelain.sh | 22 +- t/t5411/test-0032-report-with-options.sh | 186 ++++++++-------- ...est-0033-report-with-options--porcelain.sh | 200 +++++++++--------- t/t5411/test-0034-report-ft.sh | 22 +- t/t5411/test-0035-report-ft--porcelain.sh | 24 +-- ...t-0036-report-multi-rewrite-for-one-ref.sh | 132 ++++++------ ...rt-multi-rewrite-for-one-ref--porcelain.sh | 138 ++++++------ t/t5411/test-0038-report-mixed-refs.sh | 74 +++---- .../test-0039-report-mixed-refs--porcelain.sh | 76 +++---- t/t5411/test-0040-process-all-refs.sh | 80 +++---- .../test-0041-process-all-refs--porcelain.sh | 82 +++---- ...t-0050-proc-receive-refs-with-modifiers.sh | 90 ++++---- t/t5548-push-porcelain.sh | 54 ++--- t/t6020-bundle-misc.sh | 45 ++-- 31 files changed, 972 insertions(+), 966 deletions(-) diff --git a/t/t5411/common-functions.sh b/t/t5411/common-functions.sh index 6694858e18..6c347b4caa 100644 --- a/t/t5411/common-functions.sh +++ b/t/t5411/common-functions.sh @@ -33,17 +33,14 @@ create_commits_in () { # Format the output of git-push, git-show-ref and other commands to make a # user-friendly and stable text. We can easily prepare the expect text -# without having to worry about future changes of the commit ID and spaces +# without having to worry about changes of the commit ID (full or abbrev.) # of the output. Single quotes are replaced with double quotes, because # it is boring to prepare unquoted single quotes in expect text. We also # remove some locale error messages. The emitted human-readable errors are # redundant to the more machine-readable output the tests already assert. make_user_friendly_and_stable_output () { sed \ - -e "s/ *\$//" \ - -e "s/ */ /g" \ -e "s/'/\"/g" \ - -e "s/ / /g" \ -e "s/$A//g" \ -e "s/$B//g" \ -e "s/$TAG//g" \ @@ -59,6 +56,10 @@ filter_out_user_friendly_and_stable_output () { sed -n ${1+"$@"} } +format_and_save_expect () { + sed -e 's/^> //' -e 's/Z$//' >expect +} + test_cmp_refs () { indir= if test "$1" = "-C" diff --git a/t/t5411/test-0000-standard-git-push.sh b/t/t5411/test-0000-standard-git-push.sh index e1e0175c12..d8aafc235c 100644 --- a/t/t5411/test-0000-standard-git-push.sh +++ b/t/t5411/test-0000-standard-git-push.sh @@ -7,16 +7,16 @@ test_expect_success "git-push ($PROTOCOL)" ' HEAD:refs/heads/next \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/main - remote: pre-receive< refs/heads/next - remote: # post-receive hook - remote: post-receive< refs/heads/main - remote: post-receive< refs/heads/next - To - .. -> main - * [new branch] HEAD -> next + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/main Z + > remote: pre-receive< refs/heads/next Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/main Z + > remote: post-receive< refs/heads/next Z + > To + > .. -> main + > * [new branch] HEAD -> next EOF test_cmp expect actual && @@ -38,10 +38,10 @@ test_expect_success "git-push --atomic ($PROTOCOL)" ' -e "/^To / { p; }" \ -e "/^ ! / { p; }" \ actual && - cat >expect <<-EOF && - To - ! [rejected] main -> main (non-fast-forward) - ! [rejected] -> next (atomic push failed) + format_and_save_expect <<-EOF && + > To + > ! [rejected] main -> main (non-fast-forward) + > ! [rejected] -> next (atomic push failed) EOF test_cmp expect actual && @@ -63,14 +63,14 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL)" ' $B:refs/heads/next \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/next - remote: # post-receive hook - remote: post-receive< refs/heads/next - To - .. -> next - ! [rejected] main -> main (non-fast-forward) + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/next Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/next Z + > To + > .. -> next + > ! [rejected] main -> main (non-fast-forward) EOF test_cmp expect actual && @@ -92,25 +92,25 @@ test_expect_success "git-push -f ($PROTOCOL)" ' HEAD:refs/heads/a/b/c \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/main - remote: pre-receive< refs/heads/next - remote: pre-receive< refs/tags/v123 - remote: pre-receive< refs/review/main/topic - remote: pre-receive< refs/heads/a/b/c - remote: # post-receive hook - remote: post-receive< refs/heads/main - remote: post-receive< refs/heads/next - remote: post-receive< refs/tags/v123 - remote: post-receive< refs/review/main/topic - remote: post-receive< refs/heads/a/b/c - To - + ... main -> main (forced update) - - [deleted] next - * [new tag] v123 -> v123 - * [new reference] main -> refs/review/main/topic - * [new branch] HEAD -> a/b/c + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/main Z + > remote: pre-receive< refs/heads/next Z + > remote: pre-receive< refs/tags/v123 Z + > remote: pre-receive< refs/review/main/topic Z + > remote: pre-receive< refs/heads/a/b/c Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/main Z + > remote: post-receive< refs/heads/next Z + > remote: post-receive< refs/tags/v123 Z + > remote: post-receive< refs/review/main/topic Z + > remote: post-receive< refs/heads/a/b/c Z + > To + > + ... main -> main (forced update) + > - [deleted] next + > * [new tag] v123 -> v123 + > * [new reference] main -> refs/review/main/topic + > * [new branch] HEAD -> a/b/c EOF test_cmp expect actual && diff --git a/t/t5411/test-0001-standard-git-push--porcelain.sh b/t/t5411/test-0001-standard-git-push--porcelain.sh index bcbda72341..2078d0a027 100644 --- a/t/t5411/test-0001-standard-git-push--porcelain.sh +++ b/t/t5411/test-0001-standard-git-push--porcelain.sh @@ -7,17 +7,17 @@ test_expect_success "git-push ($PROTOCOL/porcelain)" ' HEAD:refs/heads/next \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/main - remote: pre-receive< refs/heads/next - remote: # post-receive hook - remote: post-receive< refs/heads/main - remote: post-receive< refs/heads/next - To - :refs/heads/main .. - * HEAD:refs/heads/next [new branch] - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/main Z + > remote: pre-receive< refs/heads/next Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/main Z + > remote: post-receive< refs/heads/next Z + > To + > :refs/heads/main .. + > * HEAD:refs/heads/next [new branch] + > Done EOF test_cmp expect actual && @@ -38,12 +38,12 @@ test_expect_success "git-push --atomic ($PROTOCOL/porcelain)" ' filter_out_user_friendly_and_stable_output \ -e "s/^# GETTEXT POISON #//" \ -e "/^To / { p; }" \ - -e "/^! / { p; }" \ + -e "/^!/ { p; }" \ actual && - cat >expect <<-EOF && - To - ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) - ! :refs/heads/next [rejected] (atomic push failed) + format_and_save_expect <<-EOF && + > To + > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) + > ! :refs/heads/next [rejected] (atomic push failed) EOF test_cmp expect actual && @@ -65,15 +65,15 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL/porcelain)" ' $B:refs/heads/next \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/next - remote: # post-receive hook - remote: post-receive< refs/heads/next - To - :refs/heads/next .. - ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/next Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/next Z + > To + > :refs/heads/next .. + > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) + > Done EOF test_cmp expect actual && @@ -95,26 +95,26 @@ test_expect_success "git-push -f ($PROTOCOL/porcelain)" ' HEAD:refs/heads/a/b/c \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/main - remote: pre-receive< refs/heads/next - remote: pre-receive< refs/tags/v123 - remote: pre-receive< refs/review/main/topic - remote: pre-receive< refs/heads/a/b/c - remote: # post-receive hook - remote: post-receive< refs/heads/main - remote: post-receive< refs/heads/next - remote: post-receive< refs/tags/v123 - remote: post-receive< refs/review/main/topic - remote: post-receive< refs/heads/a/b/c - To - + refs/heads/main:refs/heads/main ... (forced update) - - :refs/heads/next [deleted] - * refs/tags/v123:refs/tags/v123 [new tag] - * refs/heads/main:refs/review/main/topic [new reference] - * HEAD:refs/heads/a/b/c [new branch] - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/main Z + > remote: pre-receive< refs/heads/next Z + > remote: pre-receive< refs/tags/v123 Z + > remote: pre-receive< refs/review/main/topic Z + > remote: pre-receive< refs/heads/a/b/c Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/main Z + > remote: post-receive< refs/heads/next Z + > remote: post-receive< refs/tags/v123 Z + > remote: post-receive< refs/review/main/topic Z + > remote: post-receive< refs/heads/a/b/c Z + > To + > + refs/heads/main:refs/heads/main ... (forced update) + > - :refs/heads/next [deleted] + > * refs/tags/v123:refs/tags/v123 [new tag] + > * refs/heads/main:refs/review/main/topic [new reference] + > * HEAD:refs/heads/a/b/c [new branch] + > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0003-pre-receive-declined--porcelain.sh b/t/t5411/test-0003-pre-receive-declined--porcelain.sh index e9c9db5d1f..2393b04ad9 100644 --- a/t/t5411/test-0003-pre-receive-declined--porcelain.sh +++ b/t/t5411/test-0003-pre-receive-declined--porcelain.sh @@ -14,10 +14,10 @@ test_expect_success "git-push is declined ($PROTOCOL/porcelain)" ' HEAD:refs/heads/next \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - To - ! :refs/heads/main [remote rejected] (pre-receive hook declined) - ! HEAD:refs/heads/next [remote rejected] (pre-receive hook declined) + format_and_save_expect <<-EOF && + > To + > ! :refs/heads/main [remote rejected] (pre-receive hook declined) + > ! HEAD:refs/heads/next [remote rejected] (pre-receive hook declined) Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0011-no-hook-error.sh b/t/t5411/test-0011-no-hook-error.sh index 3ef136e6ef..d35002b1f0 100644 --- a/t/t5411/test-0011-no-hook-error.sh +++ b/t/t5411/test-0011-no-hook-error.sh @@ -7,16 +7,16 @@ test_expect_success "proc-receive: no hook, fail to push special ref ($PROTOCOL) HEAD:refs/for/main/topic \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/next - remote: pre-receive< refs/for/main/topic - remote: error: cannot find hook "proc-receive" - remote: # post-receive hook - remote: post-receive< refs/heads/next - To - * [new branch] HEAD -> next - ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/next Z + > remote: pre-receive< refs/for/main/topic Z + > remote: error: cannot find hook "proc-receive" Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/next Z + > To + > * [new branch] HEAD -> next + > ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && @@ -41,16 +41,16 @@ test_expect_success "proc-receive: no hook, all failed for atomic push ($PROTOCO HEAD:next \ HEAD:refs/for/main/topic >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/main - remote: pre-receive< refs/heads/next - remote: pre-receive< refs/for/main/topic - remote: error: cannot find hook "proc-receive" - To - ! [remote rejected] -> main (fail to run proc-receive hook) - ! [remote rejected] HEAD -> next (fail to run proc-receive hook) - ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/main Z + > remote: pre-receive< refs/heads/next Z + > remote: pre-receive< refs/for/main/topic Z + > remote: error: cannot find hook "proc-receive" Z + > To + > ! [remote rejected] -> main (fail to run proc-receive hook) + > ! [remote rejected] HEAD -> next (fail to run proc-receive hook) + > ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && diff --git a/t/t5411/test-0012-no-hook-error--porcelain.sh b/t/t5411/test-0012-no-hook-error--porcelain.sh index 19f66fbd7d..04468b5018 100644 --- a/t/t5411/test-0012-no-hook-error--porcelain.sh +++ b/t/t5411/test-0012-no-hook-error--porcelain.sh @@ -7,16 +7,16 @@ test_expect_success "proc-receive: no hook, fail to push special ref ($PROTOCOL/ HEAD:refs/for/main/topic \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/next - remote: pre-receive< refs/for/main/topic - remote: error: cannot find hook "proc-receive" - remote: # post-receive hook - remote: post-receive< refs/heads/next - To - * HEAD:refs/heads/next [new branch] - ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/next Z + > remote: pre-receive< refs/for/main/topic Z + > remote: error: cannot find hook "proc-receive" Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/next Z + > To + > * HEAD:refs/heads/next [new branch] + > ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) Done EOF test_cmp expect actual && @@ -42,17 +42,17 @@ test_expect_success "proc-receive: no hook, all failed for atomic push ($PROTOCO HEAD:next \ HEAD:refs/for/main/topic >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/main - remote: pre-receive< refs/heads/next - remote: pre-receive< refs/for/main/topic - remote: error: cannot find hook "proc-receive" - To - ! :refs/heads/main [remote rejected] (fail to run proc-receive hook) - ! HEAD:refs/heads/next [remote rejected] (fail to run proc-receive hook) - ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/main Z + > remote: pre-receive< refs/heads/next Z + > remote: pre-receive< refs/for/main/topic Z + > remote: error: cannot find hook "proc-receive" Z + > To + > ! :refs/heads/main [remote rejected] (fail to run proc-receive hook) + > ! HEAD:refs/heads/next [remote rejected] (fail to run proc-receive hook) + > ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) + > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0013-bad-protocol.sh b/t/t5411/test-0013-bad-protocol.sh index 095e613f6f..c08a00ded2 100644 --- a/t/t5411/test-0013-bad-protocol.sh +++ b/t/t5411/test-0013-bad-protocol.sh @@ -29,8 +29,8 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL)" ' # message ("remote: fatal: the remote end hung up unexpectedly") which # is different from the remote HTTP server with different locale settings. grep "^remote: error:" actual-error && - cat >expect <<-EOF && - remote: error: proc-receive version "2" is not supported + format_and_save_expect <<-EOF && + > remote: error: proc-receive version "2" is not supported Z EOF test_cmp expect actual-error && @@ -208,17 +208,17 @@ test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL)" ' HEAD:refs/heads/next \ HEAD:refs/for/main/topic >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/next - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: # post-receive hook - remote: post-receive< refs/heads/next - To - * [new branch] HEAD -> next - ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/next Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/next Z + > To + > * [new branch] HEAD -> next + > ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) EOF test_cmp expect actual && @@ -251,15 +251,15 @@ test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL)" ' HEAD:refs/for/main/topic\ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok - remote: error: proc-receive reported incomplete status line: "ok" - To - ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok Z + > remote: error: proc-receive reported incomplete status line: "ok" Z + > To + > ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) EOF test_cmp expect actual && @@ -284,15 +284,15 @@ test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL)" ' HEAD:refs/for/main/topic \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> xx refs/for/main/topic - remote: error: proc-receive reported bad status "xx" on ref "refs/for/main/topic" - To - ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> xx refs/for/main/topic Z + > remote: error: proc-receive reported bad status "xx" on ref "refs/for/main/topic" Z + > To + > ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) EOF test_cmp expect actual && diff --git a/t/t5411/test-0014-bad-protocol--porcelain.sh b/t/t5411/test-0014-bad-protocol--porcelain.sh index a44649789c..3eaa597e0f 100644 --- a/t/t5411/test-0014-bad-protocol--porcelain.sh +++ b/t/t5411/test-0014-bad-protocol--porcelain.sh @@ -20,7 +20,7 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL/porc actual-report && cat >expect <<-EOF && To - ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) + ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) Done EOF test_cmp expect actual-report && @@ -29,8 +29,8 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL/porc # message ("remote: fatal: the remote end hung up unexpectedly") which # is different from the remote HTTP server with different locale settings. grep "^remote: error:" actual-error && - cat >expect <<-EOF && - remote: error: proc-receive version "2" is not supported + format_and_save_expect <<-EOF && + > remote: error: proc-receive version "2" is not supported Z EOF test_cmp expect actual-error && @@ -58,7 +58,7 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-version, $PROTO actual && cat >expect <<-EOF && To - ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) + ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) Done EOF test_cmp expect actual && @@ -89,7 +89,7 @@ test_expect_success "proc-receive: bad protocol (hook --die-write-version, $PROT actual && cat >expect <<-EOF && To - ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) + ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) Done EOF test_cmp expect actual && @@ -120,7 +120,7 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-commands, $PROT actual && cat >expect <<-EOF && To - ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) + ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) Done EOF test_cmp expect actual && @@ -152,7 +152,7 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-push-options, $ actual && cat >expect <<-EOF && To - ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) + ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) Done EOF test_cmp expect actual && @@ -182,7 +182,7 @@ test_expect_success "proc-receive: bad protocol (hook --die-write-report, $PROTO actual && cat >expect <<-EOF && To - ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) + ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) Done EOF test_cmp expect actual && @@ -208,18 +208,18 @@ test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL/porcelain) HEAD:refs/heads/next \ HEAD:refs/for/main/topic >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/next - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: # post-receive hook - remote: post-receive< refs/heads/next - To - * HEAD:refs/heads/next [new branch] - ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/next Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/next Z + > To + > * HEAD:refs/heads/next [new branch] + > ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) + > Done EOF test_cmp expect actual && @@ -251,16 +251,16 @@ test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL/porcelain)" ' HEAD:refs/for/main/topic\ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok - remote: error: proc-receive reported incomplete status line: "ok" - To - ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok Z + > remote: error: proc-receive reported incomplete status line: "ok" Z + > To + > ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) + > Done EOF test_cmp expect actual && @@ -285,16 +285,16 @@ test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL/porce HEAD:refs/for/main/topic \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> xx refs/for/main/topic - remote: error: proc-receive reported bad status "xx" on ref "refs/for/main/topic" - To - ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> xx refs/for/main/topic Z + > remote: error: proc-receive reported bad status "xx" on ref "refs/for/main/topic" Z + > To + > ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) + > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0020-report-ng.sh b/t/t5411/test-0020-report-ng.sh index ad2c8f6535..e915dbc28d 100644 --- a/t/t5411/test-0020-report-ng.sh +++ b/t/t5411/test-0020-report-ng.sh @@ -14,14 +14,14 @@ test_expect_success "proc-receive: fail to update (ng, no message, $PROTOCOL)" ' HEAD:refs/for/main/topic \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ng refs/for/main/topic - To - ! [remote rejected] HEAD -> refs/for/main/topic (failed) + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ng refs/for/main/topic Z + > To + > ! [remote rejected] HEAD -> refs/for/main/topic (failed) EOF test_cmp expect actual && @@ -46,14 +46,14 @@ test_expect_success "proc-receive: fail to update (ng, with message, $PROTOCOL)" HEAD:refs/for/main/topic \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ng refs/for/main/topic error msg - To - ! [remote rejected] HEAD -> refs/for/main/topic (error msg) + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ng refs/for/main/topic error msg Z + > To + > ! [remote rejected] HEAD -> refs/for/main/topic (error msg) EOF test_cmp expect actual && diff --git a/t/t5411/test-0021-report-ng--porcelain.sh b/t/t5411/test-0021-report-ng--porcelain.sh index d8ae9d3414..2a392e099b 100644 --- a/t/t5411/test-0021-report-ng--porcelain.sh +++ b/t/t5411/test-0021-report-ng--porcelain.sh @@ -14,15 +14,15 @@ test_expect_success "proc-receive: fail to update (ng, no message, $PROTOCOL/por HEAD:refs/for/main/topic \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ng refs/for/main/topic - To - ! HEAD:refs/for/main/topic [remote rejected] (failed) - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ng refs/for/main/topic Z + > To + > ! HEAD:refs/for/main/topic [remote rejected] (failed) + > Done EOF test_cmp expect actual && @@ -47,15 +47,15 @@ test_expect_success "proc-receive: fail to update (ng, with message, $PROTOCOL/p HEAD:refs/for/main/topic \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ng refs/for/main/topic error msg - To - ! HEAD:refs/for/main/topic [remote rejected] (error msg) - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ng refs/for/main/topic error msg Z + > To + > ! HEAD:refs/for/main/topic [remote rejected] (error msg) + > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0022-report-unexpect-ref.sh b/t/t5411/test-0022-report-unexpect-ref.sh index dbed467186..a2ce7ebdf6 100644 --- a/t/t5411/test-0022-report-unexpect-ref.sh +++ b/t/t5411/test-0022-report-unexpect-ref.sh @@ -15,19 +15,19 @@ test_expect_success "proc-receive: report unexpected ref ($PROTOCOL)" ' HEAD:refs/for/main/topic \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/main - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/heads/main - remote: error: proc-receive reported status on unexpected ref: refs/heads/main - remote: # post-receive hook - remote: post-receive< refs/heads/main - To - .. -> main - ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/main Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/heads/main Z + > remote: error: proc-receive reported status on unexpected ref: refs/heads/main Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/main Z + > To + > .. -> main + > ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) EOF test_cmp expect actual && diff --git a/t/t5411/test-0023-report-unexpect-ref--porcelain.sh b/t/t5411/test-0023-report-unexpect-ref--porcelain.sh index e89096fa13..4e56b163f8 100644 --- a/t/t5411/test-0023-report-unexpect-ref--porcelain.sh +++ b/t/t5411/test-0023-report-unexpect-ref--porcelain.sh @@ -15,20 +15,20 @@ test_expect_success "proc-receive: report unexpected ref ($PROTOCOL/porcelain)" HEAD:refs/for/main/topic \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/main - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/heads/main - remote: error: proc-receive reported status on unexpected ref: refs/heads/main - remote: # post-receive hook - remote: post-receive< refs/heads/main - To - :refs/heads/main .. - ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/main Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/heads/main Z + > remote: error: proc-receive reported status on unexpected ref: refs/heads/main Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/main Z + > To + > :refs/heads/main .. + > ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) + > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0024-report-unknown-ref.sh b/t/t5411/test-0024-report-unknown-ref.sh index 77204244b8..af055aa086 100644 --- a/t/t5411/test-0024-report-unknown-ref.sh +++ b/t/t5411/test-0024-report-unknown-ref.sh @@ -14,15 +14,15 @@ test_expect_success "proc-receive: report unknown reference ($PROTOCOL)" ' HEAD:refs/for/a/b/c/my/topic \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/a/b/c/my/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/a/b/c/my/topic - remote: proc-receive> ok refs/for/main/topic - remote: error: proc-receive reported status on unknown ref: refs/for/main/topic - To - ! [remote rejected] HEAD -> refs/for/a/b/c/my/topic (proc-receive failed to report status) + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/a/b/c/my/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/a/b/c/my/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: error: proc-receive reported status on unknown ref: refs/for/main/topic Z + > To + > ! [remote rejected] HEAD -> refs/for/a/b/c/my/topic (proc-receive failed to report status) EOF test_cmp expect actual && diff --git a/t/t5411/test-0025-report-unknown-ref--porcelain.sh b/t/t5411/test-0025-report-unknown-ref--porcelain.sh index eeb1ce6b2c..99601ca321 100644 --- a/t/t5411/test-0025-report-unknown-ref--porcelain.sh +++ b/t/t5411/test-0025-report-unknown-ref--porcelain.sh @@ -14,16 +14,16 @@ test_expect_success "proc-receive: report unknown reference ($PROTOCOL/porcelain HEAD:refs/for/a/b/c/my/topic \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/a/b/c/my/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/a/b/c/my/topic - remote: proc-receive> ok refs/for/main/topic - remote: error: proc-receive reported status on unknown ref: refs/for/main/topic - To - ! HEAD:refs/for/a/b/c/my/topic [remote rejected] (proc-receive failed to report status) - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/a/b/c/my/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/a/b/c/my/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: error: proc-receive reported status on unknown ref: refs/for/main/topic Z + > To + > ! HEAD:refs/for/a/b/c/my/topic [remote rejected] (proc-receive failed to report status) + > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0026-push-options.sh b/t/t5411/test-0026-push-options.sh index 1ec2cb95bc..fec5f95793 100644 --- a/t/t5411/test-0026-push-options.sh +++ b/t/t5411/test-0026-push-options.sh @@ -52,19 +52,19 @@ test_expect_success "proc-receive: ignore push-options for version 0 ($PROTOCOL) HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/next - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: # post-receive hook - remote: post-receive< refs/heads/next - remote: post-receive< refs/for/main/topic - To - * [new branch] HEAD -> next - * [new reference] HEAD -> refs/for/main/topic + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/next Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/next Z + > remote: post-receive< refs/for/main/topic Z + > To + > * [new branch] HEAD -> next + > * [new reference] HEAD -> refs/for/main/topic EOF test_cmp expect actual && @@ -101,22 +101,22 @@ test_expect_success "proc-receive: push with options ($PROTOCOL)" ' HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/next - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive: atomic push_options - remote: proc-receive< refs/for/main/topic - remote: proc-receive< issue=123 - remote: proc-receive< reviewer=user1 - remote: proc-receive> ok refs/for/main/topic - remote: # post-receive hook - remote: post-receive< refs/heads/next - remote: post-receive< refs/for/main/topic - To - * [new branch] HEAD -> next - * [new reference] HEAD -> refs/for/main/topic + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/next Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive: atomic push_options Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive< issue=123 Z + > remote: proc-receive< reviewer=user1 Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/next Z + > remote: post-receive< refs/for/main/topic Z + > To + > * [new branch] HEAD -> next + > * [new reference] HEAD -> refs/for/main/topic EOF test_cmp expect actual && diff --git a/t/t5411/test-0027-push-options--porcelain.sh b/t/t5411/test-0027-push-options--porcelain.sh index 447fbfec0c..8fb75a8789 100644 --- a/t/t5411/test-0027-push-options--porcelain.sh +++ b/t/t5411/test-0027-push-options--porcelain.sh @@ -54,20 +54,20 @@ test_expect_success "proc-receive: ignore push-options for version 0 ($PROTOCOL/ HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/next - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: # post-receive hook - remote: post-receive< refs/heads/next - remote: post-receive< refs/for/main/topic - To - * HEAD:refs/heads/next [new branch] - * HEAD:refs/for/main/topic [new reference] - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/next Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/next Z + > remote: post-receive< refs/for/main/topic Z + > To + > * HEAD:refs/heads/next [new branch] + > * HEAD:refs/for/main/topic [new reference] + > Done EOF test_cmp expect actual && @@ -105,23 +105,23 @@ test_expect_success "proc-receive: push with options ($PROTOCOL/porcelain)" ' HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/next - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive: atomic push_options - remote: proc-receive< refs/for/main/topic - remote: proc-receive< issue=123 - remote: proc-receive< reviewer=user1 - remote: proc-receive> ok refs/for/main/topic - remote: # post-receive hook - remote: post-receive< refs/heads/next - remote: post-receive< refs/for/main/topic - To - * HEAD:refs/heads/next [new branch] - * HEAD:refs/for/main/topic [new reference] - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/next Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive: atomic push_options Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive< issue=123 Z + > remote: proc-receive< reviewer=user1 Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/next Z + > remote: post-receive< refs/for/main/topic Z + > To + > * HEAD:refs/heads/next [new branch] + > * HEAD:refs/for/main/topic [new reference] + > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0030-report-ok.sh b/t/t5411/test-0030-report-ok.sh index 8acb4f204f..a3a6278213 100644 --- a/t/t5411/test-0030-report-ok.sh +++ b/t/t5411/test-0030-report-ok.sh @@ -14,16 +14,16 @@ test_expect_success "proc-receive: ok ($PROTOCOL)" ' HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: # post-receive hook - remote: post-receive< refs/for/main/topic - To - * [new reference] HEAD -> refs/for/main/topic + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: # post-receive hook Z + > remote: post-receive< refs/for/main/topic Z + > To + > * [new reference] HEAD -> refs/for/main/topic EOF test_cmp expect actual && diff --git a/t/t5411/test-0031-report-ok--porcelain.sh b/t/t5411/test-0031-report-ok--porcelain.sh index a967718046..0e175388b6 100644 --- a/t/t5411/test-0031-report-ok--porcelain.sh +++ b/t/t5411/test-0031-report-ok--porcelain.sh @@ -14,17 +14,17 @@ test_expect_success "proc-receive: ok ($PROTOCOL/porcelain)" ' HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: # post-receive hook - remote: post-receive< refs/for/main/topic - To - * HEAD:refs/for/main/topic [new reference] - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: # post-receive hook Z + > remote: post-receive< refs/for/main/topic Z + > To + > * HEAD:refs/for/main/topic [new reference] + > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0032-report-with-options.sh b/t/t5411/test-0032-report-with-options.sh index 437ade012d..cd4f213a7d 100644 --- a/t/t5411/test-0032-report-with-options.sh +++ b/t/t5411/test-0032-report-with-options.sh @@ -15,16 +15,16 @@ test_expect_success "proc-receive: report option without matching ok ($PROTOCOL) HEAD:refs/for/main/topic \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> option refname refs/pull/123/head - remote: proc-receive> option old-oid - remote: error: proc-receive reported "option" without a matching "ok/ng" directive - To - ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> option refname refs/pull/123/head Z + > remote: proc-receive> option old-oid Z + > remote: error: proc-receive reported "option" without a matching "ok/ng" directive Z + > To + > ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) EOF test_cmp expect actual ' @@ -46,17 +46,17 @@ test_expect_success "proc-receive: report option refname ($PROTOCOL)" ' HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/pull/123/head - remote: # post-receive hook - remote: post-receive< refs/pull/123/head - To - * [new reference] HEAD -> refs/pull/123/head + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/pull/123/head Z + > remote: # post-receive hook Z + > remote: post-receive< refs/pull/123/head Z + > To + > * [new reference] HEAD -> refs/pull/123/head EOF test_cmp expect actual ' @@ -78,18 +78,18 @@ test_expect_success "proc-receive: report option refname and forced-update ($PRO HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/pull/123/head - remote: proc-receive> option forced-update - remote: # post-receive hook - remote: post-receive< refs/pull/123/head - To - * [new reference] HEAD -> refs/pull/123/head + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/pull/123/head Z + > remote: proc-receive> option forced-update Z + > remote: # post-receive hook Z + > remote: post-receive< refs/pull/123/head Z + > To + > * [new reference] HEAD -> refs/pull/123/head EOF test_cmp expect actual ' @@ -112,18 +112,18 @@ test_expect_success "proc-receive: report option refname and old-oid ($PROTOCOL) HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/pull/123/head - remote: proc-receive> option old-oid - remote: # post-receive hook - remote: post-receive< refs/pull/123/head - To - .. HEAD -> refs/pull/123/head + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/pull/123/head Z + > remote: proc-receive> option old-oid Z + > remote: # post-receive hook Z + > remote: post-receive< refs/pull/123/head Z + > To + > .. HEAD -> refs/pull/123/head EOF test_cmp expect actual ' @@ -145,17 +145,17 @@ test_expect_success "proc-receive: report option old-oid ($PROTOCOL)" ' HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option old-oid - remote: # post-receive hook - remote: post-receive< refs/for/main/topic - To - .. HEAD -> refs/for/main/topic + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option old-oid Z + > remote: # post-receive hook Z + > remote: post-receive< refs/for/main/topic Z + > To + > .. HEAD -> refs/for/main/topic EOF test_cmp expect actual ' @@ -178,18 +178,18 @@ test_expect_success "proc-receive: report option old-oid and new-oid ($PROTOCOL) HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: # post-receive hook - remote: post-receive< refs/for/main/topic - To - .. HEAD -> refs/for/main/topic + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: # post-receive hook Z + > remote: post-receive< refs/for/main/topic Z + > To + > .. HEAD -> refs/for/main/topic EOF test_cmp expect actual ' @@ -219,31 +219,31 @@ test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL)" ' HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/next/topic - remote: pre-receive< refs/for/a/b/c/topic - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/next/topic - remote: proc-receive< refs/for/a/b/c/topic - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/a/b/c/topic - remote: proc-receive> ok refs/for/next/topic - remote: proc-receive> option refname refs/pull/123/head - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/pull/124/head - remote: proc-receive> option old-oid - remote: proc-receive> option forced-update - remote: proc-receive> option new-oid - remote: # post-receive hook - remote: post-receive< refs/pull/123/head - remote: post-receive< refs/for/a/b/c/topic - remote: post-receive< refs/pull/124/head - To - * [new reference] HEAD -> refs/pull/123/head - * [new reference] HEAD -> refs/for/a/b/c/topic - + ... HEAD -> refs/pull/124/head (forced update) + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/next/topic Z + > remote: pre-receive< refs/for/a/b/c/topic Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/next/topic Z + > remote: proc-receive< refs/for/a/b/c/topic Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/a/b/c/topic Z + > remote: proc-receive> ok refs/for/next/topic Z + > remote: proc-receive> option refname refs/pull/123/head Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/pull/124/head Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option forced-update Z + > remote: proc-receive> option new-oid Z + > remote: # post-receive hook Z + > remote: post-receive< refs/pull/123/head Z + > remote: post-receive< refs/for/a/b/c/topic Z + > remote: post-receive< refs/pull/124/head Z + > To + > * [new reference] HEAD -> refs/pull/123/head + > * [new reference] HEAD -> refs/for/a/b/c/topic + > + ... HEAD -> refs/pull/124/head (forced update) EOF test_cmp expect actual && diff --git a/t/t5411/test-0033-report-with-options--porcelain.sh b/t/t5411/test-0033-report-with-options--porcelain.sh index 11486720ee..7433870e40 100644 --- a/t/t5411/test-0033-report-with-options--porcelain.sh +++ b/t/t5411/test-0033-report-with-options--porcelain.sh @@ -15,17 +15,17 @@ test_expect_success "proc-receive: report option without matching ok ($PROTOCOL/ HEAD:refs/for/main/topic \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> option refname refs/pull/123/head - remote: proc-receive> option old-oid - remote: error: proc-receive reported "option" without a matching "ok/ng" directive - To - ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> option refname refs/pull/123/head Z + > remote: proc-receive> option old-oid Z + > remote: error: proc-receive reported "option" without a matching "ok/ng" directive Z + > To + > ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) + > Done EOF test_cmp expect actual ' @@ -47,18 +47,18 @@ test_expect_success "proc-receive: report option refname ($PROTOCOL/porcelain)" HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/pull/123/head - remote: # post-receive hook - remote: post-receive< refs/pull/123/head - To - * HEAD:refs/pull/123/head [new reference] - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/pull/123/head Z + > remote: # post-receive hook Z + > remote: post-receive< refs/pull/123/head Z + > To + > * HEAD:refs/pull/123/head [new reference] + > Done EOF test_cmp expect actual ' @@ -81,19 +81,19 @@ test_expect_success "proc-receive: report option refname and forced-update ($PRO HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/pull/123/head - remote: proc-receive> option forced-update - remote: # post-receive hook - remote: post-receive< refs/pull/123/head - To - * HEAD:refs/pull/123/head [new reference] - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/pull/123/head Z + > remote: proc-receive> option forced-update Z + > remote: # post-receive hook Z + > remote: post-receive< refs/pull/123/head Z + > To + > * HEAD:refs/pull/123/head [new reference] + > Done EOF test_cmp expect actual ' @@ -116,19 +116,19 @@ test_expect_success "proc-receive: report option refname and old-oid ($PROTOCOL/ HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/pull/123/head - remote: proc-receive> option old-oid - remote: # post-receive hook - remote: post-receive< refs/pull/123/head - To - HEAD:refs/pull/123/head .. - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/pull/123/head Z + > remote: proc-receive> option old-oid Z + > remote: # post-receive hook Z + > remote: post-receive< refs/pull/123/head Z + > To + > HEAD:refs/pull/123/head .. + > Done EOF test_cmp expect actual ' @@ -150,18 +150,18 @@ test_expect_success "proc-receive: report option old-oid ($PROTOCOL/porcelain)" HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option old-oid - remote: # post-receive hook - remote: post-receive< refs/for/main/topic - To - HEAD:refs/for/main/topic .. - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option old-oid Z + > remote: # post-receive hook Z + > remote: post-receive< refs/for/main/topic Z + > To + > HEAD:refs/for/main/topic .. + > Done EOF test_cmp expect actual ' @@ -184,19 +184,19 @@ test_expect_success "proc-receive: report option old-oid and new-oid ($PROTOCOL/ HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: # post-receive hook - remote: post-receive< refs/for/main/topic - To - HEAD:refs/for/main/topic .. - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: # post-receive hook Z + > remote: post-receive< refs/for/main/topic Z + > To + > HEAD:refs/for/main/topic .. + > Done EOF test_cmp expect actual ' @@ -227,32 +227,32 @@ test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL/porc HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/next/topic - remote: pre-receive< refs/for/a/b/c/topic - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/next/topic - remote: proc-receive< refs/for/a/b/c/topic - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/a/b/c/topic - remote: proc-receive> ok refs/for/next/topic - remote: proc-receive> option refname refs/pull/123/head - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/pull/124/head - remote: proc-receive> option old-oid - remote: proc-receive> option forced-update - remote: proc-receive> option new-oid - remote: # post-receive hook - remote: post-receive< refs/pull/123/head - remote: post-receive< refs/for/a/b/c/topic - remote: post-receive< refs/pull/124/head - To - * HEAD:refs/pull/123/head [new reference] - * HEAD:refs/for/a/b/c/topic [new reference] - + HEAD:refs/pull/124/head ... (forced update) - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/next/topic Z + > remote: pre-receive< refs/for/a/b/c/topic Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/next/topic Z + > remote: proc-receive< refs/for/a/b/c/topic Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/a/b/c/topic Z + > remote: proc-receive> ok refs/for/next/topic Z + > remote: proc-receive> option refname refs/pull/123/head Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/pull/124/head Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option forced-update Z + > remote: proc-receive> option new-oid Z + > remote: # post-receive hook Z + > remote: post-receive< refs/pull/123/head Z + > remote: post-receive< refs/for/a/b/c/topic Z + > remote: post-receive< refs/pull/124/head Z + > To + > * HEAD:refs/pull/123/head [new reference] + > * HEAD:refs/for/a/b/c/topic [new reference] + > + HEAD:refs/pull/124/head ... (forced update) + > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0034-report-ft.sh b/t/t5411/test-0034-report-ft.sh index 6e0d08b327..73a47d1ffd 100644 --- a/t/t5411/test-0034-report-ft.sh +++ b/t/t5411/test-0034-report-ft.sh @@ -15,17 +15,17 @@ test_expect_success "proc-receive: fall throught, let receive-pack to execute ($ $B:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option fall-through - remote: # post-receive hook - remote: post-receive< refs/for/main/topic - To - * [new reference] -> refs/for/main/topic + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option fall-through Z + > remote: # post-receive hook Z + > remote: post-receive< refs/for/main/topic Z + > To + > * [new reference] -> refs/for/main/topic EOF test_cmp expect actual && diff --git a/t/t5411/test-0035-report-ft--porcelain.sh b/t/t5411/test-0035-report-ft--porcelain.sh index 81bae9f2ec..c350201107 100644 --- a/t/t5411/test-0035-report-ft--porcelain.sh +++ b/t/t5411/test-0035-report-ft--porcelain.sh @@ -15,18 +15,18 @@ test_expect_success "proc-receive: fall throught, let receive-pack to execute ($ $B:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option fall-through - remote: # post-receive hook - remote: post-receive< refs/for/main/topic - To - * :refs/for/main/topic [new reference] - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option fall-through Z + > remote: # post-receive hook Z + > remote: post-receive< refs/for/main/topic Z + > To + > * :refs/for/main/topic [new reference] + > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh b/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh index be9b18b2b6..e3f456ca5a 100644 --- a/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh +++ b/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh @@ -39,30 +39,30 @@ test_expect_success "proc-receive: multiple rewrite for one ref, no refname for HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/changes/24/124/1 - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/changes/25/125/1 - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: # post-receive hook - remote: post-receive< refs/for/main/topic - remote: post-receive< refs/changes/24/124/1 - remote: post-receive< refs/changes/25/125/1 - To - .. HEAD -> refs/for/main/topic - * [new reference] HEAD -> refs/changes/24/124/1 - .. HEAD -> refs/changes/25/125/1 + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/changes/24/124/1 Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/changes/25/125/1 Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: # post-receive hook Z + > remote: post-receive< refs/for/main/topic Z + > remote: post-receive< refs/changes/24/124/1 Z + > remote: post-receive< refs/changes/25/125/1 Z + > To + > .. HEAD -> refs/for/main/topic + > * [new reference] HEAD -> refs/changes/24/124/1 + > .. HEAD -> refs/changes/25/125/1 EOF test_cmp expect actual && @@ -113,31 +113,31 @@ test_expect_success "proc-receive: multiple rewrites for one ref, no refname for HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/changes/24/124/1 - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/changes/25/125/1 - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: proc-receive> option forced-update - remote: # post-receive hook - remote: post-receive< refs/changes/24/124/1 - remote: post-receive< refs/for/main/topic - remote: post-receive< refs/changes/25/125/1 - To - * [new reference] HEAD -> refs/changes/24/124/1 - .. HEAD -> refs/for/main/topic - + ... HEAD -> refs/changes/25/125/1 (forced update) + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/changes/24/124/1 Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/changes/25/125/1 Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: proc-receive> option forced-update Z + > remote: # post-receive hook Z + > remote: post-receive< refs/changes/24/124/1 Z + > remote: post-receive< refs/for/main/topic Z + > remote: post-receive< refs/changes/25/125/1 Z + > To + > * [new reference] HEAD -> refs/changes/24/124/1 + > .. HEAD -> refs/for/main/topic + > + ... HEAD -> refs/changes/25/125/1 (forced update) EOF test_cmp expect actual && @@ -182,23 +182,23 @@ test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL)" ' HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/changes/23/123/1 - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/changes/24/124/2 - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: # post-receive hook - remote: post-receive< refs/changes/23/123/1 - remote: post-receive< refs/changes/24/124/2 - To - * [new reference] HEAD -> refs/changes/23/123/1 - .. HEAD -> refs/changes/24/124/2 + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/changes/23/123/1 Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/changes/24/124/2 Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: # post-receive hook Z + > remote: post-receive< refs/changes/23/123/1 Z + > remote: post-receive< refs/changes/24/124/2 Z + > To + > * [new reference] HEAD -> refs/changes/23/123/1 + > .. HEAD -> refs/changes/24/124/2 EOF test_cmp expect actual && diff --git a/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh b/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh index 95fb89c031..7786079ba5 100644 --- a/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh +++ b/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh @@ -24,31 +24,31 @@ test_expect_success "proc-receive: multiple rewrite for one ref, no refname for HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/changes/24/124/1 - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/changes/25/125/1 - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: # post-receive hook - remote: post-receive< refs/for/main/topic - remote: post-receive< refs/changes/24/124/1 - remote: post-receive< refs/changes/25/125/1 - To - HEAD:refs/for/main/topic .. - * HEAD:refs/changes/24/124/1 [new reference] - HEAD:refs/changes/25/125/1 .. - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/changes/24/124/1 Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/changes/25/125/1 Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: # post-receive hook Z + > remote: post-receive< refs/for/main/topic Z + > remote: post-receive< refs/changes/24/124/1 Z + > remote: post-receive< refs/changes/25/125/1 Z + > To + > HEAD:refs/for/main/topic .. + > * HEAD:refs/changes/24/124/1 [new reference] + > HEAD:refs/changes/25/125/1 .. + > Done EOF test_cmp expect actual && @@ -84,32 +84,32 @@ test_expect_success "proc-receive: multiple rewrites for one ref, no refname for HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/changes/24/124/1 - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/changes/25/125/1 - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: proc-receive> option forced-update - remote: # post-receive hook - remote: post-receive< refs/changes/24/124/1 - remote: post-receive< refs/for/main/topic - remote: post-receive< refs/changes/25/125/1 - To - * HEAD:refs/changes/24/124/1 [new reference] - HEAD:refs/for/main/topic .. - + HEAD:refs/changes/25/125/1 ... (forced update) - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/changes/24/124/1 Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/changes/25/125/1 Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: proc-receive> option forced-update Z + > remote: # post-receive hook Z + > remote: post-receive< refs/changes/24/124/1 Z + > remote: post-receive< refs/for/main/topic Z + > remote: post-receive< refs/changes/25/125/1 Z + > To + > * HEAD:refs/changes/24/124/1 [new reference] + > HEAD:refs/for/main/topic .. + > + HEAD:refs/changes/25/125/1 ... (forced update) + > Done EOF test_cmp expect actual && @@ -139,24 +139,24 @@ test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL/porc HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< refs/for/main/topic - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/changes/23/123/1 - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/changes/24/124/2 - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: # post-receive hook - remote: post-receive< refs/changes/23/123/1 - remote: post-receive< refs/changes/24/124/2 - To - * HEAD:refs/changes/23/123/1 [new reference] - HEAD:refs/changes/24/124/2 .. - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/changes/23/123/1 Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/changes/24/124/2 Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: # post-receive hook Z + > remote: post-receive< refs/changes/23/123/1 Z + > remote: post-receive< refs/changes/24/124/2 Z + > To + > * HEAD:refs/changes/23/123/1 [new reference] + > HEAD:refs/changes/24/124/2 .. + > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0038-report-mixed-refs.sh b/t/t5411/test-0038-report-mixed-refs.sh index 5e005299cc..0990a3f76a 100644 --- a/t/t5411/test-0038-report-mixed-refs.sh +++ b/t/t5411/test-0038-report-mixed-refs.sh @@ -26,43 +26,43 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL)" ' HEAD:refs/for/next/topic3 \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/main - remote: pre-receive< refs/heads/bar - remote: pre-receive< refs/heads/baz - remote: pre-receive< refs/for/next/topic2 - remote: pre-receive< refs/for/next/topic1 - remote: pre-receive< refs/heads/foo - remote: pre-receive< refs/for/main/topic - remote: pre-receive< refs/for/next/topic3 - remote: # proc-receive hook - remote: proc-receive< refs/for/next/topic2 - remote: proc-receive< refs/for/next/topic1 - remote: proc-receive< refs/for/main/topic - remote: proc-receive< refs/for/next/topic3 - remote: proc-receive> ok refs/for/next/topic2 - remote: proc-receive> ng refs/for/next/topic1 fail to call Web API - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/for/main/topic - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: # post-receive hook - remote: post-receive< refs/heads/main - remote: post-receive< refs/heads/bar - remote: post-receive< refs/heads/baz - remote: post-receive< refs/for/next/topic2 - remote: post-receive< refs/heads/foo - remote: post-receive< refs/for/main/topic - To - .. -> main - * [new branch] HEAD -> bar - * [new branch] HEAD -> baz - * [new reference] HEAD -> refs/for/next/topic2 - * [new branch] HEAD -> foo - .. HEAD -> refs/for/main/topic - ! [remote rejected] HEAD -> refs/for/next/topic1 (fail to call Web API) - ! [remote rejected] HEAD -> refs/for/next/topic3 (proc-receive failed to report status) + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/main Z + > remote: pre-receive< refs/heads/bar Z + > remote: pre-receive< refs/heads/baz Z + > remote: pre-receive< refs/for/next/topic2 Z + > remote: pre-receive< refs/for/next/topic1 Z + > remote: pre-receive< refs/heads/foo Z + > remote: pre-receive< refs/for/main/topic Z + > remote: pre-receive< refs/for/next/topic3 Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/next/topic2 Z + > remote: proc-receive< refs/for/next/topic1 Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive< refs/for/next/topic3 Z + > remote: proc-receive> ok refs/for/next/topic2 Z + > remote: proc-receive> ng refs/for/next/topic1 fail to call Web API Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/for/main/topic Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/main Z + > remote: post-receive< refs/heads/bar Z + > remote: post-receive< refs/heads/baz Z + > remote: post-receive< refs/for/next/topic2 Z + > remote: post-receive< refs/heads/foo Z + > remote: post-receive< refs/for/main/topic Z + > To + > .. -> main + > * [new branch] HEAD -> bar + > * [new branch] HEAD -> baz + > * [new reference] HEAD -> refs/for/next/topic2 + > * [new branch] HEAD -> foo + > .. HEAD -> refs/for/main/topic + > ! [remote rejected] HEAD -> refs/for/next/topic1 (fail to call Web API) + > ! [remote rejected] HEAD -> refs/for/next/topic3 (proc-receive failed to report status) EOF test_cmp expect actual && diff --git a/t/t5411/test-0039-report-mixed-refs--porcelain.sh b/t/t5411/test-0039-report-mixed-refs--porcelain.sh index 8f891c5385..7e4d08a939 100644 --- a/t/t5411/test-0039-report-mixed-refs--porcelain.sh +++ b/t/t5411/test-0039-report-mixed-refs--porcelain.sh @@ -26,44 +26,44 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL/porcel HEAD:refs/for/next/topic3 \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/main - remote: pre-receive< refs/heads/bar - remote: pre-receive< refs/heads/baz - remote: pre-receive< refs/for/next/topic2 - remote: pre-receive< refs/for/next/topic1 - remote: pre-receive< refs/heads/foo - remote: pre-receive< refs/for/main/topic - remote: pre-receive< refs/for/next/topic3 - remote: # proc-receive hook - remote: proc-receive< refs/for/next/topic2 - remote: proc-receive< refs/for/next/topic1 - remote: proc-receive< refs/for/main/topic - remote: proc-receive< refs/for/next/topic3 - remote: proc-receive> ok refs/for/next/topic2 - remote: proc-receive> ng refs/for/next/topic1 fail to call Web API - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/for/main/topic - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: # post-receive hook - remote: post-receive< refs/heads/main - remote: post-receive< refs/heads/bar - remote: post-receive< refs/heads/baz - remote: post-receive< refs/for/next/topic2 - remote: post-receive< refs/heads/foo - remote: post-receive< refs/for/main/topic - To - :refs/heads/main .. - * HEAD:refs/heads/bar [new branch] - * HEAD:refs/heads/baz [new branch] - * HEAD:refs/for/next/topic2 [new reference] - * HEAD:refs/heads/foo [new branch] - HEAD:refs/for/main/topic .. - ! HEAD:refs/for/next/topic1 [remote rejected] (fail to call Web API) - ! HEAD:refs/for/next/topic3 [remote rejected] (proc-receive failed to report status) - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/main Z + > remote: pre-receive< refs/heads/bar Z + > remote: pre-receive< refs/heads/baz Z + > remote: pre-receive< refs/for/next/topic2 Z + > remote: pre-receive< refs/for/next/topic1 Z + > remote: pre-receive< refs/heads/foo Z + > remote: pre-receive< refs/for/main/topic Z + > remote: pre-receive< refs/for/next/topic3 Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/next/topic2 Z + > remote: proc-receive< refs/for/next/topic1 Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive< refs/for/next/topic3 Z + > remote: proc-receive> ok refs/for/next/topic2 Z + > remote: proc-receive> ng refs/for/next/topic1 fail to call Web API Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/for/main/topic Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/main Z + > remote: post-receive< refs/heads/bar Z + > remote: post-receive< refs/heads/baz Z + > remote: post-receive< refs/for/next/topic2 Z + > remote: post-receive< refs/heads/foo Z + > remote: post-receive< refs/for/main/topic Z + > To + > :refs/heads/main .. + > * HEAD:refs/heads/bar [new branch] + > * HEAD:refs/heads/baz [new branch] + > * HEAD:refs/for/next/topic2 [new reference] + > * HEAD:refs/heads/foo [new branch] + > HEAD:refs/for/main/topic .. + > ! HEAD:refs/for/next/topic1 [remote rejected] (fail to call Web API) + > ! HEAD:refs/for/next/topic3 [remote rejected] (proc-receive failed to report status) + > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0040-process-all-refs.sh b/t/t5411/test-0040-process-all-refs.sh index fdcdcc7c2e..f67cb2a7b3 100644 --- a/t/t5411/test-0040-process-all-refs.sh +++ b/t/t5411/test-0040-process-all-refs.sh @@ -50,46 +50,46 @@ test_expect_success "proc-receive: process all refs ($PROTOCOL)" ' HEAD:refs/for/next/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/bar - remote: pre-receive< refs/heads/foo - remote: pre-receive< refs/heads/main - remote: pre-receive< refs/for/main/topic - remote: pre-receive< refs/for/next/topic - remote: # proc-receive hook - remote: proc-receive< refs/heads/bar - remote: proc-receive< refs/heads/foo - remote: proc-receive< refs/heads/main - remote: proc-receive< refs/for/main/topic - remote: proc-receive< refs/for/next/topic - remote: proc-receive> ok refs/heads/main - remote: proc-receive> option fall-through - remote: proc-receive> ok refs/heads/foo - remote: proc-receive> option fall-through - remote: proc-receive> ok refs/heads/bar - remote: proc-receive> option fall-through - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/pull/123/head - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: proc-receive> ok refs/for/next/topic - remote: proc-receive> option refname refs/pull/124/head - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: proc-receive> option forced-update - remote: # post-receive hook - remote: post-receive< refs/heads/bar - remote: post-receive< refs/heads/foo - remote: post-receive< refs/heads/main - remote: post-receive< refs/pull/123/head - remote: post-receive< refs/pull/124/head - To - .. -> bar - - [deleted] foo - + ... HEAD -> main (forced update) - .. HEAD -> refs/pull/123/head - + ... HEAD -> refs/pull/124/head (forced update) + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/bar Z + > remote: pre-receive< refs/heads/foo Z + > remote: pre-receive< refs/heads/main Z + > remote: pre-receive< refs/for/main/topic Z + > remote: pre-receive< refs/for/next/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/heads/bar Z + > remote: proc-receive< refs/heads/foo Z + > remote: proc-receive< refs/heads/main Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive< refs/for/next/topic Z + > remote: proc-receive> ok refs/heads/main Z + > remote: proc-receive> option fall-through Z + > remote: proc-receive> ok refs/heads/foo Z + > remote: proc-receive> option fall-through Z + > remote: proc-receive> ok refs/heads/bar Z + > remote: proc-receive> option fall-through Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/pull/123/head Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: proc-receive> ok refs/for/next/topic Z + > remote: proc-receive> option refname refs/pull/124/head Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: proc-receive> option forced-update Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/bar Z + > remote: post-receive< refs/heads/foo Z + > remote: post-receive< refs/heads/main Z + > remote: post-receive< refs/pull/123/head Z + > remote: post-receive< refs/pull/124/head Z + > To + > .. -> bar + > - [deleted] foo + > + ... HEAD -> main (forced update) + > .. HEAD -> refs/pull/123/head + > + ... HEAD -> refs/pull/124/head (forced update) EOF test_cmp expect actual && diff --git a/t/t5411/test-0041-process-all-refs--porcelain.sh b/t/t5411/test-0041-process-all-refs--porcelain.sh index 73b35fe0aa..7d1a99d3a2 100644 --- a/t/t5411/test-0041-process-all-refs--porcelain.sh +++ b/t/t5411/test-0041-process-all-refs--porcelain.sh @@ -50,47 +50,47 @@ test_expect_success "proc-receive: process all refs ($PROTOCOL/porcelain)" ' HEAD:refs/for/next/topic \ >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/bar - remote: pre-receive< refs/heads/foo - remote: pre-receive< refs/heads/main - remote: pre-receive< refs/for/main/topic - remote: pre-receive< refs/for/next/topic - remote: # proc-receive hook - remote: proc-receive< refs/heads/bar - remote: proc-receive< refs/heads/foo - remote: proc-receive< refs/heads/main - remote: proc-receive< refs/for/main/topic - remote: proc-receive< refs/for/next/topic - remote: proc-receive> ok refs/heads/main - remote: proc-receive> option fall-through - remote: proc-receive> ok refs/heads/foo - remote: proc-receive> option fall-through - remote: proc-receive> ok refs/heads/bar - remote: proc-receive> option fall-through - remote: proc-receive> ok refs/for/main/topic - remote: proc-receive> option refname refs/pull/123/head - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: proc-receive> ok refs/for/next/topic - remote: proc-receive> option refname refs/pull/124/head - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: proc-receive> option forced-update - remote: # post-receive hook - remote: post-receive< refs/heads/bar - remote: post-receive< refs/heads/foo - remote: post-receive< refs/heads/main - remote: post-receive< refs/pull/123/head - remote: post-receive< refs/pull/124/head - To - :refs/heads/bar .. - - :refs/heads/foo [deleted] - + HEAD:refs/heads/main ... (forced update) - HEAD:refs/pull/123/head .. - + HEAD:refs/pull/124/head ... (forced update) - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/bar Z + > remote: pre-receive< refs/heads/foo Z + > remote: pre-receive< refs/heads/main Z + > remote: pre-receive< refs/for/main/topic Z + > remote: pre-receive< refs/for/next/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/heads/bar Z + > remote: proc-receive< refs/heads/foo Z + > remote: proc-receive< refs/heads/main Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive< refs/for/next/topic Z + > remote: proc-receive> ok refs/heads/main Z + > remote: proc-receive> option fall-through Z + > remote: proc-receive> ok refs/heads/foo Z + > remote: proc-receive> option fall-through Z + > remote: proc-receive> ok refs/heads/bar Z + > remote: proc-receive> option fall-through Z + > remote: proc-receive> ok refs/for/main/topic Z + > remote: proc-receive> option refname refs/pull/123/head Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: proc-receive> ok refs/for/next/topic Z + > remote: proc-receive> option refname refs/pull/124/head Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: proc-receive> option forced-update Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/bar Z + > remote: post-receive< refs/heads/foo Z + > remote: post-receive< refs/heads/main Z + > remote: post-receive< refs/pull/123/head Z + > remote: post-receive< refs/pull/124/head Z + > To + > :refs/heads/bar .. + > - :refs/heads/foo [deleted] + > + HEAD:refs/heads/main ... (forced update) + > HEAD:refs/pull/123/head .. + > + HEAD:refs/pull/124/head ... (forced update) + > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0050-proc-receive-refs-with-modifiers.sh b/t/t5411/test-0050-proc-receive-refs-with-modifiers.sh index 7214647ada..dba544162c 100644 --- a/t/t5411/test-0050-proc-receive-refs-with-modifiers.sh +++ b/t/t5411/test-0050-proc-receive-refs-with-modifiers.sh @@ -29,25 +29,25 @@ test_expect_success "proc-receive: update branch and new tag ($PROTOCOL)" ' $B:refs/heads/main \ v123 >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/main - remote: pre-receive< refs/tags/v123 - remote: # proc-receive hook - remote: proc-receive< refs/heads/main - remote: proc-receive< refs/tags/v123 - remote: proc-receive> ok refs/heads/main - remote: proc-receive> option refname refs/pull/123/head - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: proc-receive> ok refs/tags/v123 - remote: proc-receive> option refname refs/pull/124/head - remote: # post-receive hook - remote: post-receive< refs/pull/123/head - remote: post-receive< refs/pull/124/head - To - .. -> refs/pull/123/head - * [new reference] v123 -> refs/pull/124/head + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/main Z + > remote: pre-receive< refs/tags/v123 Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/heads/main Z + > remote: proc-receive< refs/tags/v123 Z + > remote: proc-receive> ok refs/heads/main Z + > remote: proc-receive> option refname refs/pull/123/head Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: proc-receive> ok refs/tags/v123 Z + > remote: proc-receive> option refname refs/pull/124/head Z + > remote: # post-receive hook Z + > remote: post-receive< refs/pull/123/head Z + > remote: post-receive< refs/pull/124/head Z + > To + > .. -> refs/pull/123/head + > * [new reference] v123 -> refs/pull/124/head EOF test_cmp expect actual && @@ -93,32 +93,32 @@ test_expect_success "proc-receive: create/delete branch, and delete tag ($PROTOC $A:refs/heads/next \ :refs/tags/v123 >out 2>&1 && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< refs/heads/main - remote: pre-receive< refs/heads/topic - remote: pre-receive< refs/tags/v123 - remote: pre-receive< refs/heads/next - remote: # proc-receive hook - remote: proc-receive< refs/heads/main - remote: proc-receive< refs/heads/next - remote: proc-receive> ok refs/heads/main - remote: proc-receive> option refname refs/pull/123/head - remote: proc-receive> option old-oid - remote: proc-receive> option new-oid - remote: proc-receive> ok refs/heads/next - remote: proc-receive> option refname refs/pull/124/head - remote: proc-receive> option new-oid - remote: # post-receive hook - remote: post-receive< refs/pull/123/head - remote: post-receive< refs/heads/topic - remote: post-receive< refs/tags/v123 - remote: post-receive< refs/pull/124/head - To - - [deleted] refs/pull/123/head - .. -> topic - - [deleted] v123 - * [new reference] -> refs/pull/124/head + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/main Z + > remote: pre-receive< refs/heads/topic Z + > remote: pre-receive< refs/tags/v123 Z + > remote: pre-receive< refs/heads/next Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/heads/main Z + > remote: proc-receive< refs/heads/next Z + > remote: proc-receive> ok refs/heads/main Z + > remote: proc-receive> option refname refs/pull/123/head Z + > remote: proc-receive> option old-oid Z + > remote: proc-receive> option new-oid Z + > remote: proc-receive> ok refs/heads/next Z + > remote: proc-receive> option refname refs/pull/124/head Z + > remote: proc-receive> option new-oid Z + > remote: # post-receive hook Z + > remote: post-receive< refs/pull/123/head Z + > remote: post-receive< refs/heads/topic Z + > remote: post-receive< refs/tags/v123 Z + > remote: post-receive< refs/pull/124/head Z + > To + > - [deleted] refs/pull/123/head + > .. -> topic + > - [deleted] v123 + > * [new reference] -> refs/pull/124/head EOF test_cmp expect actual && diff --git a/t/t5548-push-porcelain.sh b/t/t5548-push-porcelain.sh index 5a761f3642..2ab7c3cf5a 100755 --- a/t/t5548-push-porcelain.sh +++ b/t/t5548-push-porcelain.sh @@ -45,9 +45,6 @@ create_commits_in () { # of the output. make_user_friendly_and_stable_output () { sed \ - -e "s/ *\$//" \ - -e "s/ */ /g" \ - -e "s/ / /g" \ -e "s/$A//g" \ -e "s/$B//g" \ -e "s/$ZERO_OID//g" \ @@ -56,6 +53,10 @@ make_user_friendly_and_stable_output () { -e "s#To $URL_PREFIX/upstream.git#To #" } +format_and_save_expect () { + sed -e 's/^> //' -e 's/Z$//' >expect +} + setup_upstream_and_workbench () { # Upstream after setup : main(B) foo(A) bar(A) baz(A) # Workbench after setup : main(A) @@ -111,14 +112,14 @@ run_git_push_porcelain_output_test() { next ) >out && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && - To - = refs/heads/baz:refs/heads/baz [up to date] - :refs/heads/bar .. - - :refs/heads/foo [deleted] - + refs/heads/main:refs/heads/main ... (forced update) - * refs/heads/next:refs/heads/next [new branch] - Done + format_and_save_expect <<-EOF && + > To + > = refs/heads/baz:refs/heads/baz [up to date] + > :refs/heads/bar .. + > - :refs/heads/foo [deleted] + > + refs/heads/main:refs/heads/main ... (forced update) + > * refs/heads/next:refs/heads/next [new branch] + > Done EOF test_cmp expect actual && @@ -148,12 +149,12 @@ run_git_push_porcelain_output_test() { next ) >out && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && + format_and_save_expect <<-EOF && To - = refs/heads/next:refs/heads/next [up to date] - ! refs/heads/bar:refs/heads/bar [rejected] (non-fast-forward) - ! (delete):refs/heads/baz [rejected] (atomic push failed) - ! refs/heads/main:refs/heads/main [rejected] (atomic push failed) + > = refs/heads/next:refs/heads/next [up to date] + > ! refs/heads/bar:refs/heads/bar [rejected] (non-fast-forward) + > ! (delete):refs/heads/baz [rejected] (atomic push failed) + > ! refs/heads/main:refs/heads/main [rejected] (atomic push failed) Done EOF test_cmp expect actual && @@ -168,6 +169,7 @@ run_git_push_porcelain_output_test() { EOF test_cmp expect actual ' + test_expect_success "prepare pre-receive hook ($PROTOCOL)" ' write_script "$upstream/hooks/pre-receive" <<-EOF exit 1 @@ -189,12 +191,12 @@ run_git_push_porcelain_output_test() { next ) >out && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && + format_and_save_expect <<-EOF && To - = refs/heads/next:refs/heads/next [up to date] - ! refs/heads/bar:refs/heads/bar [remote rejected] (pre-receive hook declined) - ! :refs/heads/baz [remote rejected] (pre-receive hook declined) - ! refs/heads/main:refs/heads/main [remote rejected] (pre-receive hook declined) + > = refs/heads/next:refs/heads/next [up to date] + > ! refs/heads/bar:refs/heads/bar [remote rejected] (pre-receive hook declined) + > ! :refs/heads/baz [remote rejected] (pre-receive hook declined) + > ! refs/heads/main:refs/heads/main [remote rejected] (pre-receive hook declined) Done EOF test_cmp expect actual && @@ -227,12 +229,12 @@ run_git_push_porcelain_output_test() { next ) >out && make_user_friendly_and_stable_output actual && - cat >expect <<-EOF && + format_and_save_expect <<-EOF && To - = refs/heads/next:refs/heads/next [up to date] - - :refs/heads/baz [deleted] - refs/heads/main:refs/heads/main .. - ! refs/heads/bar:refs/heads/bar [rejected] (non-fast-forward) + > = refs/heads/next:refs/heads/next [up to date] + > - :refs/heads/baz [deleted] + > refs/heads/main:refs/heads/main .. + > ! refs/heads/bar:refs/heads/bar [rejected] (non-fast-forward) Done EOF test_cmp expect actual && diff --git a/t/t6020-bundle-misc.sh b/t/t6020-bundle-misc.sh index 881f72fd44..cf13bcc3c8 100755 --- a/t/t6020-bundle-misc.sh +++ b/t/t6020-bundle-misc.sh @@ -82,7 +82,7 @@ test_commit_setvar () { # Format the output of git commands to make a user-friendly and stable # text. We can easily prepare the expect text without having to worry -# about future changes of the commit ID and spaces of the output. +# about future changes of the commit ID. make_user_friendly_and_stable_output () { sed \ -e "s/${A%${A#???????}}[0-9a-f]*//g" \ @@ -103,8 +103,11 @@ make_user_friendly_and_stable_output () { -e "s/${P%${P#???????}}[0-9a-f]*//g" \ -e "s/${TAG1%${TAG1#???????}}[0-9a-f]*//g" \ -e "s/${TAG2%${TAG2#???????}}[0-9a-f]*//g" \ - -e "s/${TAG3%${TAG3#???????}}[0-9a-f]*//g" \ - -e "s/ *\$//" + -e "s/${TAG3%${TAG3#???????}}[0-9a-f]*//g" +} + +format_and_save_expect () { + sed -e 's/Z$//' >expect } # (C) (D, pull/1/head, topic/1) @@ -179,11 +182,11 @@ test_expect_success 'create bundle from special rev: main^!' ' git bundle verify special-rev.bdl | make_user_friendly_and_stable_output >actual && - cat >expect <<-\EOF && + format_and_save_expect <<-\EOF && The bundle contains this ref: refs/heads/main The bundle requires this ref: - + Z EOF test_cmp expect actual && @@ -200,12 +203,12 @@ test_expect_success 'create bundle with --max-count option' ' git bundle verify max-count.bdl | make_user_friendly_and_stable_output >actual && - cat >expect <<-\EOF && + format_and_save_expect <<-\EOF && The bundle contains these 2 refs: refs/heads/main refs/tags/v1 The bundle requires this ref: - + Z EOF test_cmp expect actual && @@ -225,7 +228,7 @@ test_expect_success 'create bundle with --since option' ' git bundle verify since.bdl | make_user_friendly_and_stable_output >actual && - cat >expect <<-\EOF && + format_and_save_expect <<-\EOF && The bundle contains these 5 refs: refs/heads/main refs/heads/release @@ -233,8 +236,8 @@ test_expect_success 'create bundle with --since option' ' refs/tags/v3 HEAD The bundle requires these 2 refs: - - + Z + Z EOF test_cmp expect actual && @@ -293,13 +296,13 @@ test_expect_success 'create bundle 2 - has prerequisites' ' --stdin \ release expect <<-\EOF && + format_and_save_expect <<-\EOF && The bundle contains this ref: refs/heads/release The bundle requires these 3 refs: - - - + Z + Z + Z EOF git bundle verify 2.bdl | @@ -317,11 +320,11 @@ test_expect_success 'create bundle 2 - has prerequisites' ' test_expect_success 'fail to verify bundle without prerequisites' ' git init --bare test1.git && - cat >expect <<-\EOF && + format_and_save_expect <<-\EOF && error: Repository lacks these prerequisite commits: - error: - error: - error: + error: Z + error: Z + error: Z EOF test_must_fail git -C test1.git bundle verify ../2.bdl 2>&1 | @@ -352,13 +355,13 @@ test_expect_success 'create bundle 3 - two refs, same object' ' --stdin \ main HEAD expect <<-\EOF && + format_and_save_expect <<-\EOF && The bundle contains these 2 refs: refs/heads/main HEAD The bundle requires these 2 refs: - - + Z + Z EOF git bundle verify 3.bdl | From patchwork Thu Jun 17 03:17:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 12326419 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0697CC49361 for ; Thu, 17 Jun 2021 03:17:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9474613E2 for ; Thu, 17 Jun 2021 03:17:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbhFQDTs (ORCPT ); Wed, 16 Jun 2021 23:19:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229686AbhFQDTq (ORCPT ); Wed, 16 Jun 2021 23:19:46 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 391DCC061767 for ; Wed, 16 Jun 2021 20:17:38 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id ei4so2949099pjb.3 for ; Wed, 16 Jun 2021 20:17:38 -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=vLHUByq7aB6vq4b3hZES/YJJjEiOxy8V8jot7W8FeYY=; b=rmi6mSclmN2d94S+7N3WVc6Zvdd3OWqm2VqM05WpEOdvT5SAwJ4P7XTN0uUl2yAtxE mDUVSLTHyt8sGe9Gfvr4cilcJBRRJzBAdakEZ2oy3VeSrbvtdk8r52k03dxp48RBVOwz 4bEVK1czom7oN9cIBbBwjReZCCrlc2JLz5qYZpLAPmF9FSOlnD04DRQREIRxv7MF2bok NSppKB9HoC/KsFvOS8C7DZ8V5v5qP3lVaaV9zunrPhDPwvcNT3j2jIxjJVGC2+748CQk xJ2ly1ZjMTDN2YgkKOsL5q3m/9WkGQHDTUluLCtglAto2vuPqavexwu3MVuIdHyQrssg gtPg== 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=vLHUByq7aB6vq4b3hZES/YJJjEiOxy8V8jot7W8FeYY=; b=tQMbovUcCXat/sTmNEzn0Dl/67EXRDKB8DtPueH5cbGD9Q98pU1XTy9U5Iezg/NLVH wQRZ8cfwTLYDVJGj7bGF223ktyvhbQM8C5AW+hCE0p1WTIs3Q3wEiubC9UphwzZM1heR xoTM9Q+c/NuCUjvyQebJV/LOa/6MTF3yEG1Olg29xxHYa1ZIssOxeZ/KWv7SJNmvcHUj mc/cn2QzkuX4oSgSAvVBf7RHuq0HWC8IN92arqtsjYDbMgfpb1PbeIEJLnseYfWHP1TX CVz19BwL/gBg+bVhx3QqzNxd44Oqv0zK1WnNzrwSjCpW4LFg7SS1vxnK9wqHi0xy/NTi vZoA== X-Gm-Message-State: AOAM531sdEph7oo/FAzMgRdphGmbFPRfG6AMC6k+GhdVfCak5GyiD69U MtZgh3mktCIWNHyH6hxUVAs= X-Google-Smtp-Source: ABdhPJwpPEsjOJMfDyinx4TfqiSppPORJJ315pVMXXZDwl7NLRcBLPpJRx5cyXYqDhd/+bAzF3I1CA== X-Received: by 2002:a17:902:8309:b029:115:c2f3:2aed with SMTP id bd9-20020a1709028309b0290115c2f32aedmr2492488plb.57.1623899857718; Wed, 16 Jun 2021 20:17:37 -0700 (PDT) Received: from localhost.localdomain ([47.246.98.151]) by smtp.gmail.com with ESMTPSA id ei10sm3301726pjb.8.2021.06.16.20.17.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jun 2021 20:17:37 -0700 (PDT) From: Jiang Xin X-Google-Original-From: Jiang Xin To: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= , Junio C Hamano , Git List , Nicolas Pitre Cc: Jiang Xin Subject: [PATCH 3/4] test: refactor to use "test_commit" to create commits Date: Thu, 17 Jun 2021 11:17:26 +0800 Message-Id: <20210617031727.81105-3-zhiyou.jx@alibaba-inc.com> X-Mailer: git-send-email 2.32.0.rc0.27.g7b1e85181b In-Reply-To: <20210617031727.81105-1-zhiyou.jx@alibaba-inc.com> References: <20210617031727.81105-1-zhiyou.jx@alibaba-inc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Refactor function "create_commits_in" to use "test_commit" to create commit. Signed-off-by: Jiang Xin --- t/t5411/common-functions.sh | 25 ++++++------------------- t/t5548-push-porcelain.sh | 25 ++++++------------------- 2 files changed, 12 insertions(+), 38 deletions(-) diff --git a/t/t5411/common-functions.sh b/t/t5411/common-functions.sh index 6c347b4caa..b9c6adecf5 100644 --- a/t/t5411/common-functions.sh +++ b/t/t5411/common-functions.sh @@ -6,29 +6,16 @@ # NOTE: Never calling this function from a subshell since variable # assignments will disappear when subshell exits. create_commits_in () { - repo="$1" && - if ! parent=$(git -C "$repo" rev-parse HEAD^{} --) - then - parent= - fi && - T=$(git -C "$repo" write-tree) && + repo="$1" && test -d "$repo" || + error "Repository $repo does not exist." shift && while test $# -gt 0 do name=$1 && - test_tick && - if test -z "$parent" - then - oid=$(echo $name | git -C "$repo" commit-tree $T) - else - oid=$(echo $name | git -C "$repo" commit-tree -p $parent $T) - fi && - eval $name=$oid && - parent=$oid && - shift || - return 1 - done && - git -C "$repo" update-ref refs/heads/main $oid + shift && + test_commit -C "$repo" --no-tag "$name" && + eval $name=$(git -C "$repo" rev-parse HEAD) + done } # Format the output of git-push, git-show-ref and other commands to make a diff --git a/t/t5548-push-porcelain.sh b/t/t5548-push-porcelain.sh index 2ab7c3cf5a..c8f18a7a12 100755 --- a/t/t5548-push-porcelain.sh +++ b/t/t5548-push-porcelain.sh @@ -14,29 +14,16 @@ test_description='Test git push porcelain output' # NOTE: Never calling this function from a subshell since variable # assignments will disappear when subshell exits. create_commits_in () { - repo="$1" && - if ! parent=$(git -C "$repo" rev-parse HEAD^{} --) - then - parent= - fi && - T=$(git -C "$repo" write-tree) && + repo="$1" && test -d "$repo" || + error "Repository $repo does not exist." shift && while test $# -gt 0 do name=$1 && - test_tick && - if test -z "$parent" - then - oid=$(echo $name | git -C "$repo" commit-tree $T) - else - oid=$(echo $name | git -C "$repo" commit-tree -p $parent $T) - fi && - eval $name=$oid && - parent=$oid && - shift || - return 1 - done && - git -C "$repo" update-ref refs/heads/main $oid + shift && + test_commit -C "$repo" --no-tag "$name" && + eval $name=$(git -C "$repo" rev-parse HEAD) + done } # Format the output of git-push, git-show-ref and other commands to make a From patchwork Thu Jun 17 03:17:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 12326423 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A05AEC48BE8 for ; Thu, 17 Jun 2021 03:17:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7924A613E2 for ; Thu, 17 Jun 2021 03:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229943AbhFQDTy (ORCPT ); Wed, 16 Jun 2021 23:19:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229716AbhFQDTs (ORCPT ); Wed, 16 Jun 2021 23:19:48 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63DC2C061574 for ; Wed, 16 Jun 2021 20:17:40 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id ei4so2949132pjb.3 for ; Wed, 16 Jun 2021 20:17:40 -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=gw3mfJrR95P+h8qXdZ1/ozeAbnpCw/KfFGAcxe614+M=; b=UXRRFJThSLeobLl8Mdq0o0T0kE5xYxP8wHnIe6DV7eclJkHC1AXsM2cEHsnZuhoiYn P8wjrdEVJ3TJ5UPwNGDKjaKUJJIksSMhV56Yh1KO3x6H3X2nPH3JI9V0QQMEPwDDf7aj KGrkCtavW6357zYJQ910AvF1zAMyf7SeRi7VK32RT+xvYzB+yxzeAS8cgB82PPLCEK8P RxMbUIGAeQPnCg/cPaaOsplUlZyZN8dyz3Q67n1kVxbU1C3BSGokxQtja4YR71m1hIMA RFT+Zep8P4HIm6k5GcGky44Us+YP3gcwAwzkOnXaO9+RPfqGMaZW2T/TY5NSpQ42kJ3q lDkw== 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=gw3mfJrR95P+h8qXdZ1/ozeAbnpCw/KfFGAcxe614+M=; b=gLLdlrRiGBlO0cs+ehi6ARYY6Num7QrbHks5LVm/rZKgy0w4+Ojlm+mPObIB6CdxW+ QWdkMsfUBMG/3KSHFZfiKuYFYGdWVDOxXVfllA8kdkEWNV66X0Q4QydQ7YoeqUAs4ccd kLz4hEQllf8xBEmm17Ulur7dq6mMcyFgoLV349OYaiyqSnUGSTSCERqGWbCvWXYlSlBN CVVjvhLD8MPlVcoJ2LmnBS7wG7Ckvzgps86uT6WwH98+W4s3lOMu8pp8xqrnKCstViD5 8luPCYbmT++fxS4AHsN51ZokMjJq4YgLH2QfW9EI2d6K1NDa/JbfhPrNF1CV40mt13B+ aS2g== X-Gm-Message-State: AOAM53053YtbgtJfTmuhXy1q/0WOyh/CKtxYiO4VQFWXsq+dccKwr6xe dYgqa5Ul2utLnzZg97ntkcg= X-Google-Smtp-Source: ABdhPJxGjAyNwQSYmoq5lbTh9751+4v7XBkxaSFNZa80rM8t4RsMa9uPWZrt9N2ssc6W//TemcdqCw== X-Received: by 2002:a17:902:6904:b029:fb:42b6:e952 with SMTP id j4-20020a1709026904b02900fb42b6e952mr2621480plk.16.1623899859681; Wed, 16 Jun 2021 20:17:39 -0700 (PDT) Received: from localhost.localdomain ([47.246.98.151]) by smtp.gmail.com with ESMTPSA id ei10sm3301726pjb.8.2021.06.16.20.17.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jun 2021 20:17:39 -0700 (PDT) From: Jiang Xin X-Google-Original-From: Jiang Xin To: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= , Junio C Hamano , Git List , Nicolas Pitre Cc: Jiang Xin Subject: [PATCH 4/4] test: refactor to use "get_abbrev_oid" to get abbrev oid Date: Thu, 17 Jun 2021 11:17:27 +0800 Message-Id: <20210617031727.81105-4-zhiyou.jx@alibaba-inc.com> X-Mailer: git-send-email 2.32.0.rc0.27.g7b1e85181b In-Reply-To: <20210617031727.81105-1-zhiyou.jx@alibaba-inc.com> References: <20210617031727.81105-1-zhiyou.jx@alibaba-inc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add new function "get_abbrev_oid" to get abbrev object ID. This function has a default value which helps to prepare a nonempty replace pattern for sed command. An empty replace pattern may cause sed fail to allocate memory. Refactor function "make_user_friendly_and_stable_output" to use "get_abbrev_oid" to get abbrev object ID. Signed-off-by: Jiang Xin --- t/t5411/common-functions.sh | 20 ++++++++++++---- t/t5411/test-0000-standard-git-push.sh | 6 ++--- .../test-0001-standard-git-push--porcelain.sh | 6 ++--- t/t5411/test-0022-report-unexpect-ref.sh | 2 +- ...est-0023-report-unexpect-ref--porcelain.sh | 2 +- t/t5411/test-0032-report-with-options.sh | 8 +++---- ...est-0033-report-with-options--porcelain.sh | 8 +++---- ...t-0036-report-multi-rewrite-for-one-ref.sh | 10 ++++---- ...rt-multi-rewrite-for-one-ref--porcelain.sh | 10 ++++---- t/t5411/test-0038-report-mixed-refs.sh | 4 ++-- .../test-0039-report-mixed-refs--porcelain.sh | 4 ++-- t/t5411/test-0040-process-all-refs.sh | 8 +++---- .../test-0041-process-all-refs--porcelain.sh | 8 +++---- ...t-0050-proc-receive-refs-with-modifiers.sh | 4 ++-- t/t5548-push-porcelain.sh | 24 +++++++++++++------ 15 files changed, 72 insertions(+), 52 deletions(-) diff --git a/t/t5411/common-functions.sh b/t/t5411/common-functions.sh index b9c6adecf5..3c747782c1 100644 --- a/t/t5411/common-functions.sh +++ b/t/t5411/common-functions.sh @@ -18,6 +18,18 @@ create_commits_in () { done } +get_abbrev_oid () { + oid=$1 && + suffix=${oid#???????} && + oid=${oid%$suffix} && + if test -n "$oid" + then + echo "$oid" + else + echo "undefined-oid" + fi +} + # Format the output of git-push, git-show-ref and other commands to make a # user-friendly and stable text. We can easily prepare the expect text # without having to worry about changes of the commit ID (full or abbrev.) @@ -28,12 +40,10 @@ create_commits_in () { make_user_friendly_and_stable_output () { sed \ -e "s/'/\"/g" \ - -e "s/$A//g" \ - -e "s/$B//g" \ - -e "s/$TAG//g" \ + -e "s/$(get_abbrev_oid $A)[0-9a-f]*//g" \ + -e "s/$(get_abbrev_oid $B)[0-9a-f]*//g" \ + -e "s/$(get_abbrev_oid $TAG)[0-9a-f]*//g" \ -e "s/$ZERO_OID//g" \ - -e "s/$(echo $A | cut -c1-7)[0-9a-f]*//g" \ - -e "s/$(echo $B | cut -c1-7)[0-9a-f]*//g" \ -e "s#To $URL_PREFIX/upstream.git#To #" \ -e "/^error: / d" } diff --git a/t/t5411/test-0000-standard-git-push.sh b/t/t5411/test-0000-standard-git-push.sh index d8aafc235c..ce64bb660b 100644 --- a/t/t5411/test-0000-standard-git-push.sh +++ b/t/t5411/test-0000-standard-git-push.sh @@ -15,7 +15,7 @@ test_expect_success "git-push ($PROTOCOL)" ' > remote: post-receive< refs/heads/main Z > remote: post-receive< refs/heads/next Z > To - > .. -> main + > .. -> main > * [new branch] HEAD -> next EOF test_cmp expect actual && @@ -69,7 +69,7 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL)" ' > remote: # post-receive hook Z > remote: post-receive< refs/heads/next Z > To - > .. -> next + > .. -> next > ! [rejected] main -> main (non-fast-forward) EOF test_cmp expect actual && @@ -106,7 +106,7 @@ test_expect_success "git-push -f ($PROTOCOL)" ' > remote: post-receive< refs/review/main/topic Z > remote: post-receive< refs/heads/a/b/c Z > To - > + ... main -> main (forced update) + > + ... main -> main (forced update) > - [deleted] next > * [new tag] v123 -> v123 > * [new reference] main -> refs/review/main/topic diff --git a/t/t5411/test-0001-standard-git-push--porcelain.sh b/t/t5411/test-0001-standard-git-push--porcelain.sh index 2078d0a027..373ec3d865 100644 --- a/t/t5411/test-0001-standard-git-push--porcelain.sh +++ b/t/t5411/test-0001-standard-git-push--porcelain.sh @@ -15,7 +15,7 @@ test_expect_success "git-push ($PROTOCOL/porcelain)" ' > remote: post-receive< refs/heads/main Z > remote: post-receive< refs/heads/next Z > To - > :refs/heads/main .. + > :refs/heads/main .. > * HEAD:refs/heads/next [new branch] > Done EOF @@ -71,7 +71,7 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL/porcelain)" ' > remote: # post-receive hook Z > remote: post-receive< refs/heads/next Z > To - > :refs/heads/next .. + > :refs/heads/next .. > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) > Done EOF @@ -109,7 +109,7 @@ test_expect_success "git-push -f ($PROTOCOL/porcelain)" ' > remote: post-receive< refs/review/main/topic Z > remote: post-receive< refs/heads/a/b/c Z > To - > + refs/heads/main:refs/heads/main ... (forced update) + > + refs/heads/main:refs/heads/main ... (forced update) > - :refs/heads/next [deleted] > * refs/tags/v123:refs/tags/v123 [new tag] > * refs/heads/main:refs/review/main/topic [new reference] diff --git a/t/t5411/test-0022-report-unexpect-ref.sh b/t/t5411/test-0022-report-unexpect-ref.sh index a2ce7ebdf6..f7a494bdb9 100644 --- a/t/t5411/test-0022-report-unexpect-ref.sh +++ b/t/t5411/test-0022-report-unexpect-ref.sh @@ -26,7 +26,7 @@ test_expect_success "proc-receive: report unexpected ref ($PROTOCOL)" ' > remote: # post-receive hook Z > remote: post-receive< refs/heads/main Z > To - > .. -> main + > .. -> main > ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) EOF test_cmp expect actual && diff --git a/t/t5411/test-0023-report-unexpect-ref--porcelain.sh b/t/t5411/test-0023-report-unexpect-ref--porcelain.sh index 4e56b163f8..63c479e975 100644 --- a/t/t5411/test-0023-report-unexpect-ref--porcelain.sh +++ b/t/t5411/test-0023-report-unexpect-ref--porcelain.sh @@ -26,7 +26,7 @@ test_expect_success "proc-receive: report unexpected ref ($PROTOCOL/porcelain)" > remote: # post-receive hook Z > remote: post-receive< refs/heads/main Z > To - > :refs/heads/main .. + > :refs/heads/main .. > ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) > Done EOF diff --git a/t/t5411/test-0032-report-with-options.sh b/t/t5411/test-0032-report-with-options.sh index cd4f213a7d..988a4302a6 100644 --- a/t/t5411/test-0032-report-with-options.sh +++ b/t/t5411/test-0032-report-with-options.sh @@ -123,7 +123,7 @@ test_expect_success "proc-receive: report option refname and old-oid ($PROTOCOL) > remote: # post-receive hook Z > remote: post-receive< refs/pull/123/head Z > To - > .. HEAD -> refs/pull/123/head + > .. HEAD -> refs/pull/123/head EOF test_cmp expect actual ' @@ -155,7 +155,7 @@ test_expect_success "proc-receive: report option old-oid ($PROTOCOL)" ' > remote: # post-receive hook Z > remote: post-receive< refs/for/main/topic Z > To - > .. HEAD -> refs/for/main/topic + > .. HEAD -> refs/for/main/topic EOF test_cmp expect actual ' @@ -189,7 +189,7 @@ test_expect_success "proc-receive: report option old-oid and new-oid ($PROTOCOL) > remote: # post-receive hook Z > remote: post-receive< refs/for/main/topic Z > To - > .. HEAD -> refs/for/main/topic + > .. HEAD -> refs/for/main/topic EOF test_cmp expect actual ' @@ -243,7 +243,7 @@ test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL)" ' > To > * [new reference] HEAD -> refs/pull/123/head > * [new reference] HEAD -> refs/for/a/b/c/topic - > + ... HEAD -> refs/pull/124/head (forced update) + > + ... HEAD -> refs/pull/124/head (forced update) EOF test_cmp expect actual && diff --git a/t/t5411/test-0033-report-with-options--porcelain.sh b/t/t5411/test-0033-report-with-options--porcelain.sh index 7433870e40..daacb3d69d 100644 --- a/t/t5411/test-0033-report-with-options--porcelain.sh +++ b/t/t5411/test-0033-report-with-options--porcelain.sh @@ -127,7 +127,7 @@ test_expect_success "proc-receive: report option refname and old-oid ($PROTOCOL/ > remote: # post-receive hook Z > remote: post-receive< refs/pull/123/head Z > To - > HEAD:refs/pull/123/head .. + > HEAD:refs/pull/123/head .. > Done EOF test_cmp expect actual @@ -160,7 +160,7 @@ test_expect_success "proc-receive: report option old-oid ($PROTOCOL/porcelain)" > remote: # post-receive hook Z > remote: post-receive< refs/for/main/topic Z > To - > HEAD:refs/for/main/topic .. + > HEAD:refs/for/main/topic .. > Done EOF test_cmp expect actual @@ -195,7 +195,7 @@ test_expect_success "proc-receive: report option old-oid and new-oid ($PROTOCOL/ > remote: # post-receive hook Z > remote: post-receive< refs/for/main/topic Z > To - > HEAD:refs/for/main/topic .. + > HEAD:refs/for/main/topic .. > Done EOF test_cmp expect actual @@ -251,7 +251,7 @@ test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL/porc > To > * HEAD:refs/pull/123/head [new reference] > * HEAD:refs/for/a/b/c/topic [new reference] - > + HEAD:refs/pull/124/head ... (forced update) + > + HEAD:refs/pull/124/head ... (forced update) > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh b/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh index e3f456ca5a..8c8a6c16e1 100644 --- a/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh +++ b/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh @@ -60,9 +60,9 @@ test_expect_success "proc-receive: multiple rewrite for one ref, no refname for > remote: post-receive< refs/changes/24/124/1 Z > remote: post-receive< refs/changes/25/125/1 Z > To - > .. HEAD -> refs/for/main/topic + > .. HEAD -> refs/for/main/topic > * [new reference] HEAD -> refs/changes/24/124/1 - > .. HEAD -> refs/changes/25/125/1 + > .. HEAD -> refs/changes/25/125/1 EOF test_cmp expect actual && @@ -136,8 +136,8 @@ test_expect_success "proc-receive: multiple rewrites for one ref, no refname for > remote: post-receive< refs/changes/25/125/1 Z > To > * [new reference] HEAD -> refs/changes/24/124/1 - > .. HEAD -> refs/for/main/topic - > + ... HEAD -> refs/changes/25/125/1 (forced update) + > .. HEAD -> refs/for/main/topic + > + ... HEAD -> refs/changes/25/125/1 (forced update) EOF test_cmp expect actual && @@ -198,7 +198,7 @@ test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL)" ' > remote: post-receive< refs/changes/24/124/2 Z > To > * [new reference] HEAD -> refs/changes/23/123/1 - > .. HEAD -> refs/changes/24/124/2 + > .. HEAD -> refs/changes/24/124/2 EOF test_cmp expect actual && diff --git a/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh b/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh index 7786079ba5..bc44810f33 100644 --- a/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh +++ b/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh @@ -45,9 +45,9 @@ test_expect_success "proc-receive: multiple rewrite for one ref, no refname for > remote: post-receive< refs/changes/24/124/1 Z > remote: post-receive< refs/changes/25/125/1 Z > To - > HEAD:refs/for/main/topic .. + > HEAD:refs/for/main/topic .. > * HEAD:refs/changes/24/124/1 [new reference] - > HEAD:refs/changes/25/125/1 .. + > HEAD:refs/changes/25/125/1 .. > Done EOF test_cmp expect actual && @@ -107,8 +107,8 @@ test_expect_success "proc-receive: multiple rewrites for one ref, no refname for > remote: post-receive< refs/changes/25/125/1 Z > To > * HEAD:refs/changes/24/124/1 [new reference] - > HEAD:refs/for/main/topic .. - > + HEAD:refs/changes/25/125/1 ... (forced update) + > HEAD:refs/for/main/topic .. + > + HEAD:refs/changes/25/125/1 ... (forced update) > Done EOF test_cmp expect actual && @@ -155,7 +155,7 @@ test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL/porc > remote: post-receive< refs/changes/24/124/2 Z > To > * HEAD:refs/changes/23/123/1 [new reference] - > HEAD:refs/changes/24/124/2 .. + > HEAD:refs/changes/24/124/2 .. > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0038-report-mixed-refs.sh b/t/t5411/test-0038-report-mixed-refs.sh index 0990a3f76a..e63fe7ba11 100644 --- a/t/t5411/test-0038-report-mixed-refs.sh +++ b/t/t5411/test-0038-report-mixed-refs.sh @@ -55,12 +55,12 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL)" ' > remote: post-receive< refs/heads/foo Z > remote: post-receive< refs/for/main/topic Z > To - > .. -> main + > .. -> main > * [new branch] HEAD -> bar > * [new branch] HEAD -> baz > * [new reference] HEAD -> refs/for/next/topic2 > * [new branch] HEAD -> foo - > .. HEAD -> refs/for/main/topic + > .. HEAD -> refs/for/main/topic > ! [remote rejected] HEAD -> refs/for/next/topic1 (fail to call Web API) > ! [remote rejected] HEAD -> refs/for/next/topic3 (proc-receive failed to report status) EOF diff --git a/t/t5411/test-0039-report-mixed-refs--porcelain.sh b/t/t5411/test-0039-report-mixed-refs--porcelain.sh index 7e4d08a939..99d17b73af 100644 --- a/t/t5411/test-0039-report-mixed-refs--porcelain.sh +++ b/t/t5411/test-0039-report-mixed-refs--porcelain.sh @@ -55,12 +55,12 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL/porcel > remote: post-receive< refs/heads/foo Z > remote: post-receive< refs/for/main/topic Z > To - > :refs/heads/main .. + > :refs/heads/main .. > * HEAD:refs/heads/bar [new branch] > * HEAD:refs/heads/baz [new branch] > * HEAD:refs/for/next/topic2 [new reference] > * HEAD:refs/heads/foo [new branch] - > HEAD:refs/for/main/topic .. + > HEAD:refs/for/main/topic .. > ! HEAD:refs/for/next/topic1 [remote rejected] (fail to call Web API) > ! HEAD:refs/for/next/topic3 [remote rejected] (proc-receive failed to report status) > Done diff --git a/t/t5411/test-0040-process-all-refs.sh b/t/t5411/test-0040-process-all-refs.sh index f67cb2a7b3..2f405adefa 100644 --- a/t/t5411/test-0040-process-all-refs.sh +++ b/t/t5411/test-0040-process-all-refs.sh @@ -85,11 +85,11 @@ test_expect_success "proc-receive: process all refs ($PROTOCOL)" ' > remote: post-receive< refs/pull/123/head Z > remote: post-receive< refs/pull/124/head Z > To - > .. -> bar + > .. -> bar > - [deleted] foo - > + ... HEAD -> main (forced update) - > .. HEAD -> refs/pull/123/head - > + ... HEAD -> refs/pull/124/head (forced update) + > + ... HEAD -> main (forced update) + > .. HEAD -> refs/pull/123/head + > + ... HEAD -> refs/pull/124/head (forced update) EOF test_cmp expect actual && diff --git a/t/t5411/test-0041-process-all-refs--porcelain.sh b/t/t5411/test-0041-process-all-refs--porcelain.sh index 7d1a99d3a2..c88405792e 100644 --- a/t/t5411/test-0041-process-all-refs--porcelain.sh +++ b/t/t5411/test-0041-process-all-refs--porcelain.sh @@ -85,11 +85,11 @@ test_expect_success "proc-receive: process all refs ($PROTOCOL/porcelain)" ' > remote: post-receive< refs/pull/123/head Z > remote: post-receive< refs/pull/124/head Z > To - > :refs/heads/bar .. + > :refs/heads/bar .. > - :refs/heads/foo [deleted] - > + HEAD:refs/heads/main ... (forced update) - > HEAD:refs/pull/123/head .. - > + HEAD:refs/pull/124/head ... (forced update) + > + HEAD:refs/heads/main ... (forced update) + > HEAD:refs/pull/123/head .. + > + HEAD:refs/pull/124/head ... (forced update) > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0050-proc-receive-refs-with-modifiers.sh b/t/t5411/test-0050-proc-receive-refs-with-modifiers.sh index dba544162c..31989f0185 100644 --- a/t/t5411/test-0050-proc-receive-refs-with-modifiers.sh +++ b/t/t5411/test-0050-proc-receive-refs-with-modifiers.sh @@ -46,7 +46,7 @@ test_expect_success "proc-receive: update branch and new tag ($PROTOCOL)" ' > remote: post-receive< refs/pull/123/head Z > remote: post-receive< refs/pull/124/head Z > To - > .. -> refs/pull/123/head + > .. -> refs/pull/123/head > * [new reference] v123 -> refs/pull/124/head EOF test_cmp expect actual && @@ -116,7 +116,7 @@ test_expect_success "proc-receive: create/delete branch, and delete tag ($PROTOC > remote: post-receive< refs/pull/124/head Z > To > - [deleted] refs/pull/123/head - > .. -> topic + > .. -> topic > - [deleted] v123 > * [new reference] -> refs/pull/124/head EOF diff --git a/t/t5548-push-porcelain.sh b/t/t5548-push-porcelain.sh index c8f18a7a12..f11ff57e54 100755 --- a/t/t5548-push-porcelain.sh +++ b/t/t5548-push-porcelain.sh @@ -26,17 +26,27 @@ create_commits_in () { done } +get_abbrev_oid () { + oid=$1 && + suffix=${oid#???????} && + oid=${oid%$suffix} && + if test -n "$oid" + then + echo "$oid" + else + echo "undefined-oid" + fi +} + # Format the output of git-push, git-show-ref and other commands to make a # user-friendly and stable text. We can easily prepare the expect text # without having to worry about future changes of the commit ID and spaces # of the output. make_user_friendly_and_stable_output () { sed \ - -e "s/$A//g" \ - -e "s/$B//g" \ + -e "s/$(get_abbrev_oid $A)[0-9a-f]*//g" \ + -e "s/$(get_abbrev_oid $B)[0-9a-f]*//g" \ -e "s/$ZERO_OID//g" \ - -e "s/$(echo $A | cut -c1-7)[0-9a-f]*//g" \ - -e "s/$(echo $B | cut -c1-7)[0-9a-f]*//g" \ -e "s#To $URL_PREFIX/upstream.git#To #" } @@ -102,9 +112,9 @@ run_git_push_porcelain_output_test() { format_and_save_expect <<-EOF && > To > = refs/heads/baz:refs/heads/baz [up to date] - > :refs/heads/bar .. + > :refs/heads/bar .. > - :refs/heads/foo [deleted] - > + refs/heads/main:refs/heads/main ... (forced update) + > + refs/heads/main:refs/heads/main ... (forced update) > * refs/heads/next:refs/heads/next [new branch] > Done EOF @@ -220,7 +230,7 @@ run_git_push_porcelain_output_test() { To > = refs/heads/next:refs/heads/next [up to date] > - :refs/heads/baz [deleted] - > refs/heads/main:refs/heads/main .. + > refs/heads/main:refs/heads/main .. > ! refs/heads/bar:refs/heads/bar [rejected] (non-fast-forward) Done EOF