From patchwork Sun May 5 16:24:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10930313 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 05DEF912 for ; Sun, 5 May 2019 16:24:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE2952793A for ; Sun, 5 May 2019 16:24:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1D702862C; Sun, 5 May 2019 16:24:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D33C52793A for ; Sun, 5 May 2019 16:24:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727539AbfEEQYf (ORCPT ); Sun, 5 May 2019 12:24:35 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:40215 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726524AbfEEQYf (ORCPT ); Sun, 5 May 2019 12:24:35 -0400 Received: by mail-io1-f68.google.com with SMTP id m9so9171058iok.7 for ; Sun, 05 May 2019 09:24:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=kACkI2bVx7KxCL34Mvrm5fQ9J7/73VtOEVVgcWiFI3k=; b=XUNvd4+WiZBZWt5EX9DossidrJEyOU85/fp1SJCR/jFmZuCQMpcFwhRPxHR5xWsYNK oO3Kn+eKMyf4OeyYlXE9Kny1CgzZDQGB/uJYzQnHrOfWYDxwsLpmN/y6YDN4mWWX/tCH 0n8vACbuiXMk0+HcesI3UI+d4k9DI2UfTSUt8+iV1uD0xoRVvnjvsYnYUIie4SHi4PgN GKhwICeQf6eIkfCCcQfKPTABhqjiixB0DxryUHdxk9SeDsBi23+2OjPxK/QP/l42Jg3+ zIgco3X5e1puBXdcSVH6YUo1+StdqYJm7RbqtFiiJPbGh5UBE/eTED+iD1AKUixu4F/L mABg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=kACkI2bVx7KxCL34Mvrm5fQ9J7/73VtOEVVgcWiFI3k=; b=cludDg9N80hjhopMJ3uDgs6Cm319cpmjueH4RnepMMAre9rzzZ+aRHfyqY++4uOlpP mtfjW/77icSKFLdzsZfF6u4VCPTl0FvB3Rkyc928W+t1EzoDcb6HXtRcqiejJSMdBp7u Jex6cDpbaEs0IEg4HMWF4daINL+eSD3mnS2gF1dishPBRwZQ4hpBeKWb3HCI5NZy3anc aXuvgvxsgVXljhzddGwiEMY/RSf6nsrRXOuz4RIfvWmDxXhhJHHq809vPDQUrJbDgBic +mDPeNE/6Ucf+f1/TsnDSqVlnJCMCQ/XcDWwh4Kp6aVeGdvwfXSqn6n1bUSb0XB2BgU4 5rfg== X-Gm-Message-State: APjAAAVQxI+MEAidcgMPNudw95UrTu6qSqVFT9a9NXjUeC1AamjGFFkf vgDVUoHcNVchvs7+FWGp9B6h8TbX X-Google-Smtp-Source: APXvYqx2UOeskV73DvCX4NpGDlVf1WjivJ8wOjXqaCVBq2aHxckJ5JVFT7Ff5OS+RbU/vm8/W9h49Q== X-Received: by 2002:a5d:93c1:: with SMTP id j1mr14429049ioo.227.1557073472978; Sun, 05 May 2019 09:24:32 -0700 (PDT) Received: from archbookpro.localdomain ([199.119.233.193]) by smtp.gmail.com with ESMTPSA id t67sm3817642ita.35.2019.05.05.09.24.31 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 05 May 2019 09:24:32 -0700 (PDT) Date: Sun, 5 May 2019 12:24:29 -0400 From: Denton Liu To: Git Mailing List Subject: [PATCH 1/7] t4014: clean up style Message-ID: <08685a241e36989cde0cecc17ac9ff941998142c.1557072929.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In Git's tests, there is typically no space between the redirection operator and the filename. Remove these spaces. Since output is silenced when running without `-v` and debugging output is useful with `-v`, remove redirections to /dev/null. Change here-docs from `<<\EOF` to `<<-\EOF` so that they can be indented along with the rest of the test case. Finally, refactor to remove Git commands upstream of pipe. This way, if an invocation of a Git command fails, the return code won't be lost. Keep upstream non-Git commands since we have to assume a base level of sanity. Signed-off-by: Denton Liu --- t/t4014-format-patch.sh | 614 +++++++++++++++++++++------------------- 1 file changed, 319 insertions(+), 295 deletions(-) diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 909c743c13..d05cd256c7 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -34,7 +34,8 @@ test_expect_success setup ' git commit -m "Side changes #3 with \\n backslash-n in it." && git checkout master && - git diff-tree -p C2 | git apply --index && + git diff-tree -p C2 >patch && + git apply --index patch && grep "^From " patch | wc -l) && test $cnt = 3 ' @@ -85,21 +86,22 @@ test_expect_success "format-patch result applies" ' git checkout -b rebuild-0 master && git am -3 patch0 && - cnt=$(git rev-list master.. | wc -l) && - test $cnt = 2 + git rev-list master.. >list && + test_line_count = 2 list ' test_expect_success "format-patch --ignore-if-in-upstream result applies" ' git checkout -b rebuild-1 master && git am -3 patch1 && - cnt=$(git rev-list master.. | wc -l) && - test $cnt = 2 + git rev-list master.. >list && + test_line_count = 2 list ' test_expect_success 'commit did not screw up the log message' ' - git cat-file commit side | grep "^Side .* with .* backslash-n" + git cat-file commit side >actual && + grep "^Side .* with .* backslash-n" actual ' @@ -112,7 +114,8 @@ test_expect_success 'format-patch did not screw up the log message' ' test_expect_success 'replay did not screw up the log message' ' - git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n" + git cat-file commit rebuild-1 >actual && + grep "^Side .* with .* backslash-n" actual ' @@ -122,8 +125,8 @@ test_expect_success 'extra headers' ' " && git config --add format.headers "Cc: S E Cipient " && - git format-patch --stdout master..side > patch2 && - sed -e "/^\$/q" patch2 > hdrs2 && + git format-patch --stdout master..side >patch2 && + sed -e "/^\$/q" patch2 >hdrs2 && grep "^To: R E Cipient \$" hdrs2 && grep "^Cc: S E Cipient \$" hdrs2 @@ -134,7 +137,7 @@ test_expect_success 'extra headers without newlines' ' git config --replace-all format.headers "To: R E Cipient " && git config --add format.headers "Cc: S E Cipient " && git format-patch --stdout master..side >patch3 && - sed -e "/^\$/q" patch3 > hdrs3 && + sed -e "/^\$/q" patch3 >hdrs3 && grep "^To: R E Cipient \$" hdrs3 && grep "^Cc: S E Cipient \$" hdrs3 @@ -144,8 +147,8 @@ test_expect_success 'extra headers with multiple To:s' ' git config --replace-all format.headers "To: R E Cipient " && git config --add format.headers "To: S E Cipient " && - git format-patch --stdout master..side > patch4 && - sed -e "/^\$/q" patch4 > hdrs4 && + git format-patch --stdout master..side >patch4 && + sed -e "/^\$/q" patch4 >hdrs4 && grep "^To: R E Cipient ,\$" hdrs4 && grep "^ *S E Cipient \$" hdrs4 ' @@ -153,72 +156,82 @@ test_expect_success 'extra headers with multiple To:s' ' test_expect_success 'additional command line cc (ascii)' ' git config --replace-all format.headers "Cc: R E Cipient " && - git format-patch --cc="S E Cipient " --stdout master..side | sed -e "/^\$/q" >patch5 && - grep "^Cc: R E Cipient ,\$" patch5 && - grep "^ *S E Cipient \$" patch5 + git format-patch --cc="S E Cipient " --stdout master..side >patch5 && + sed -e "/^\$/q" patch5 >hdrs5 && + grep "^Cc: R E Cipient ,\$" hdrs5 && + grep "^ *S E Cipient \$" hdrs5 ' test_expect_failure 'additional command line cc (rfc822)' ' git config --replace-all format.headers "Cc: R E Cipient " && - git format-patch --cc="S. E. Cipient " --stdout master..side | sed -e "/^\$/q" >patch5 && - grep "^Cc: R E Cipient ,\$" patch5 && - grep "^ *\"S. E. Cipient\" \$" patch5 + git format-patch --cc="S. E. Cipient " --stdout master..side >patch5 && + sed -e "/^\$/q" patch5 >hdrs5 && + grep "^Cc: R E Cipient ,\$" hdrs5 && + grep "^ *\"S. E. Cipient\" \$" hdrs5 ' test_expect_success 'command line headers' ' git config --unset-all format.headers && - git format-patch --add-header="Cc: R E Cipient " --stdout master..side | sed -e "/^\$/q" >patch6 && - grep "^Cc: R E Cipient \$" patch6 + git format-patch --add-header="Cc: R E Cipient " --stdout master..side >patch6 && + sed -e "/^\$/q" patch6 >hdrs6 && + grep "^Cc: R E Cipient \$" hdrs6 ' test_expect_success 'configuration headers and command line headers' ' git config --replace-all format.headers "Cc: R E Cipient " && - git format-patch --add-header="Cc: S E Cipient " --stdout master..side | sed -e "/^\$/q" >patch7 && - grep "^Cc: R E Cipient ,\$" patch7 && - grep "^ *S E Cipient \$" patch7 + git format-patch --add-header="Cc: S E Cipient " --stdout master..side >patch7 && + sed -e "/^\$/q" patch7 >hdrs7 && + grep "^Cc: R E Cipient ,\$" hdrs7 && + grep "^ *S E Cipient \$" hdrs7 ' test_expect_success 'command line To: header (ascii)' ' git config --unset-all format.headers && - git format-patch --to="R E Cipient " --stdout master..side | sed -e "/^\$/q" >patch8 && - grep "^To: R E Cipient \$" patch8 + git format-patch --to="R E Cipient " --stdout master..side >patch8 && + sed -e "/^\$/q" patch8 >hdrs8 && + grep "^To: R E Cipient \$" hdrs8 ' test_expect_failure 'command line To: header (rfc822)' ' - git format-patch --to="R. E. Cipient " --stdout master..side | sed -e "/^\$/q" >patch8 && - grep "^To: \"R. E. Cipient\" \$" patch8 + git format-patch --to="R. E. Cipient " --stdout master..side >patch8 && + sed -e "/^\$/q" patch8 >hdrs8 && + grep "^To: \"R. E. Cipient\" \$" hdrs8 ' test_expect_failure 'command line To: header (rfc2047)' ' - git format-patch --to="R Ä Cipient " --stdout master..side | sed -e "/^\$/q" >patch8 && - grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= \$" patch8 + git format-patch --to="R Ä Cipient " --stdout master..side >patch8 && + sed -e "/^\$/q" patch8 >hdrs8 && + grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= \$" hdrs8 ' test_expect_success 'configuration To: header (ascii)' ' git config format.to "R E Cipient " && - git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 && - grep "^To: R E Cipient \$" patch9 + git format-patch --stdout master..side >patch9 && + sed -e "/^\$/q" patch9 >hdrs9 && + grep "^To: R E Cipient \$" hdrs9 ' test_expect_failure 'configuration To: header (rfc822)' ' git config format.to "R. E. Cipient " && - git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 && - grep "^To: \"R. E. Cipient\" \$" patch9 + git format-patch --stdout master..side >patch9 && + sed -e "/^\$/q" patch9 >hdrs9 && + grep "^To: \"R. E. Cipient\" \$" hdrs9 ' test_expect_failure 'configuration To: header (rfc2047)' ' git config format.to "R Ä Cipient " && - git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 && - grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= \$" patch9 + git format-patch --stdout master..side >patch9 && + sed -e "/^\$/q" patch9 >hdrs9 && + grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= \$" hdrs9 ' # check_patch : Verify that looks like a half-sane @@ -231,52 +244,52 @@ check_patch () { test_expect_success 'format.from=false' ' - git -c format.from=false format-patch --stdout master..side | - sed -e "/^\$/q" >patch && + git -c format.from=false format-patch --stdout master..side >patch && + sed -e "/^\$/q" patch >hdrs && check_patch patch && - ! grep "^From: C O Mitter \$" patch + ! grep "^From: C O Mitter \$" hdrs ' test_expect_success 'format.from=true' ' - git -c format.from=true format-patch --stdout master..side | - sed -e "/^\$/q" >patch && - check_patch patch && - grep "^From: C O Mitter \$" patch + git -c format.from=true format-patch --stdout master..side >patch && + sed -e "/^\$/q" patch >hdrs && + check_patch hdrs && + grep "^From: C O Mitter \$" hdrs ' test_expect_success 'format.from with address' ' - git -c format.from="F R Om " format-patch --stdout master..side | - sed -e "/^\$/q" >patch && - check_patch patch && - grep "^From: F R Om \$" patch + git -c format.from="F R Om " format-patch --stdout master..side >patch && + sed -e "/^\$/q" patch >hdrs && + check_patch hdrs && + grep "^From: F R Om \$" hdrs ' test_expect_success '--no-from overrides format.from' ' - git -c format.from="F R Om " format-patch --no-from --stdout master..side | - sed -e "/^\$/q" >patch && - check_patch patch && - ! grep "^From: F R Om \$" patch + git -c format.from="F R Om " format-patch --no-from --stdout master..side >patch && + sed -e "/^\$/q" patch >hdrs && + check_patch hdrs && + ! grep "^From: F R Om \$" hdrs ' test_expect_success '--from overrides format.from' ' - git -c format.from="F R Om " format-patch --from --stdout master..side | - sed -e "/^\$/q" >patch && - check_patch patch && - ! grep "^From: F R Om \$" patch + git -c format.from="F R Om " format-patch --from --stdout master..side >patch && + sed -e "/^\$/q" patch >hdrs && + check_patch hdrs && + ! grep "^From: F R Om \$" hdrs ' test_expect_success '--no-to overrides config.to' ' git config --replace-all format.to \ "R E Cipient " && - git format-patch --no-to --stdout master..side | - sed -e "/^\$/q" >patch10 && - check_patch patch10 && - ! grep "^To: R E Cipient \$" patch10 + git format-patch --no-to --stdout master..side >patch10 && + sed -e "/^\$/q" patch10 >hdrs10 && + check_patch hdrs10 && + ! grep "^To: R E Cipient \$" hdrs10 ' test_expect_success '--no-to and --to replaces config.to' ' @@ -284,31 +297,31 @@ test_expect_success '--no-to and --to replaces config.to' ' git config --replace-all format.to \ "Someone " && git format-patch --no-to --to="Someone Else " \ - --stdout master..side | - sed -e "/^\$/q" >patch11 && - check_patch patch11 && - ! grep "^To: Someone \$" patch11 && - grep "^To: Someone Else \$" patch11 + --stdout master..side >patch11 && + sed -e "/^\$/q" patch11 >hdrs11 && + check_patch hdrs11 && + ! grep "^To: Someone \$" hdrs11 && + grep "^To: Someone Else \$" hdrs11 ' test_expect_success '--no-cc overrides config.cc' ' git config --replace-all format.cc \ "C E Cipient " && - git format-patch --no-cc --stdout master..side | - sed -e "/^\$/q" >patch12 && - check_patch patch12 && - ! grep "^Cc: C E Cipient \$" patch12 + git format-patch --no-cc --stdout master..side >patch12 && + sed -e "/^\$/q" patch12 >hdrs12 && + check_patch hdrs12 && + ! grep "^Cc: C E Cipient \$" hdrs12 ' test_expect_success '--no-add-header overrides config.headers' ' git config --replace-all format.headers \ "Header1: B E Cipient " && - git format-patch --no-add-header --stdout master..side | - sed -e "/^\$/q" >patch13 && - check_patch patch13 && - ! grep "^Header1: B E Cipient \$" patch13 + git format-patch --no-add-header --stdout master..side >patch13 && + sed -e "/^\$/q" patch13 >hdrs13 && + check_patch hdrs13 && + ! grep "^Header1: B E Cipient \$" hdrs13 ' test_expect_success 'multiple files' ' @@ -338,7 +351,7 @@ test_expect_success 'reroll count (-v)' ' check_threading () { expect="$1" && shift && - (git format-patch --stdout "$@"; echo $? > status.out) | + (git format-patch --stdout "$@"; echo $? >status.out) | # Prints everything between the Message-ID and In-Reply-To, # and replaces all Message-ID-lookalikes by a sequence number perl -ne ' @@ -353,12 +366,12 @@ check_threading () { print; } print "---\n" if /^From /i; - ' > actual && + ' >actual && test 0 = "$(cat status.out)" && test_cmp "$expect" actual } -cat >> expect.no-threading <>expect.no-threading < expect.thread <expect.thread < --- @@ -386,7 +399,7 @@ test_expect_success 'thread' ' check_threading expect.thread --thread master ' -cat > expect.in-reply-to <expect.in-reply-to < In-Reply-To: <1> @@ -406,7 +419,7 @@ test_expect_success 'thread in-reply-to' ' --thread master ' -cat > expect.cover-letter <expect.cover-letter < --- @@ -427,7 +440,7 @@ test_expect_success 'thread cover-letter' ' check_threading expect.cover-letter --cover-letter --thread master ' -cat > expect.cl-irt <expect.cl-irt < In-Reply-To: <1> @@ -459,7 +472,7 @@ test_expect_success 'thread explicit shallow' ' --in-reply-to="" --thread=shallow master ' -cat > expect.deep <expect.deep < --- @@ -477,7 +490,7 @@ test_expect_success 'thread deep' ' check_threading expect.deep --thread=deep master ' -cat > expect.deep-irt <expect.deep-irt < In-Reply-To: <1> @@ -500,7 +513,7 @@ test_expect_success 'thread deep in-reply-to' ' --in-reply-to="" master ' -cat > expect.deep-cl <expect.deep-cl < --- @@ -524,7 +537,7 @@ test_expect_success 'thread deep cover-letter' ' check_threading expect.deep-cl --cover-letter --thread=deep master ' -cat > expect.deep-cl-irt <expect.deep-cl-irt < In-Reply-To: <1> @@ -600,7 +613,7 @@ test_expect_success 'cover-letter inherits diff options' ' ' -cat > expect << EOF +cat >expect < output && + sed -e "1,/A U Thor/d" -e "/^\$/q" <0000-cover-letter.patch >output && test_cmp expect output ' -cat > expect << EOF +cat >expect < expect << EOF +cat >expect < output && + sed -e "1,/^\$/d" -e "/^+5/q" <0001-This-is-an-excessively-long-subject-line-for-a-messa.patch >output && test_cmp expect output ' @@ -711,7 +724,7 @@ test_expect_success 'format-patch from a subdirectory (3)' ' ' test_expect_success 'format-patch --in-reply-to' ' - git format-patch -1 --stdout --in-reply-to "baz@foo.bar" > patch8 && + git format-patch -1 --stdout --in-reply-to "baz@foo.bar" >patch8 && grep "^In-Reply-To: " patch8 && grep "^References: " patch8 ' @@ -732,20 +745,20 @@ test_expect_success 'format-patch --notes --signoff' ' sed "1,/^---$/d" out | grep "test message" ' -echo "fatal: --name-only does not make sense" > expect.name-only -echo "fatal: --name-status does not make sense" > expect.name-status -echo "fatal: --check does not make sense" > expect.check +echo "fatal: --name-only does not make sense" >expect.name-only +echo "fatal: --name-status does not make sense" >expect.name-status +echo "fatal: --check does not make sense" >expect.check test_expect_success 'options no longer allowed for format-patch' ' - test_must_fail git format-patch --name-only 2> output && + test_must_fail git format-patch --name-only 2>output && test_i18ncmp expect.name-only output && - test_must_fail git format-patch --name-status 2> output && + test_must_fail git format-patch --name-status 2>output && test_i18ncmp expect.name-status output && - test_must_fail git format-patch --check 2> output && + test_must_fail git format-patch --check 2>output && test_i18ncmp expect.check output' test_expect_success 'format-patch --numstat should produce a patch' ' - git format-patch --numstat --stdout master..side > output && + git format-patch --numstat --stdout master..side >output && test 5 = $(grep "^diff --git a/" output | wc -l)' test_expect_success 'format-patch -- ' ' @@ -757,20 +770,22 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' ' git format-patch --ignore-if-in-upstream HEAD ' -git_version="$(git --version | sed "s/.* //")" +git_version="$(git --version >version && sed "s/.* //" version)" signature() { printf "%s\n%s\n\n" "-- " "${1:-$git_version}" } test_expect_success 'format-patch default signature' ' - git format-patch --stdout -1 | tail -n 3 >output && + git format-patch --stdout -1 >patch && + tail -n 3 patch >output && signature >expect && test_cmp expect output ' test_expect_success 'format-patch --signature' ' - git format-patch --stdout --signature="my sig" -1 | tail -n 3 >output && + git format-patch --stdout --signature="my sig" -1 >patch && + tail -n 3 patch >output && signature "my sig" >expect && test_cmp expect output ' @@ -1161,282 +1176,282 @@ append_signoff() test_expect_success 'signoff: commit with no body' ' append_signoff actual && - cat <<\EOF | sed "s/EOL$//" >expected && -4:Subject: [PATCH] EOL -8: -9:Signed-off-by: C O Mitter -EOF + cat <<-\EOF | sed "s/EOL$//" >expected && + 4:Subject: [PATCH] EOL + 8: + 9:Signed-off-by: C O Mitter + EOF test_cmp expected actual ' test_expect_success 'signoff: commit with only subject' ' echo subject | append_signoff >actual && - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -9:Signed-off-by: C O Mitter -EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 9:Signed-off-by: C O Mitter + EOF test_cmp expected actual ' test_expect_success 'signoff: commit with only subject that does not end with NL' ' printf subject | append_signoff >actual && - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -9:Signed-off-by: C O Mitter -EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 9:Signed-off-by: C O Mitter + EOF test_cmp expected actual ' test_expect_success 'signoff: no existing signoffs' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -body -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10: -11:Signed-off-by: C O Mitter -EOF + body + EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 11:Signed-off-by: C O Mitter + EOF test_cmp expected actual ' test_expect_success 'signoff: no existing signoffs and no trailing NL' ' printf "subject\n\nbody" | append_signoff >actual && - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10: -11:Signed-off-by: C O Mitter -EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 11:Signed-off-by: C O Mitter + EOF test_cmp expected actual ' test_expect_success 'signoff: some random signoff' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -body + body -Signed-off-by: my@house -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10: -11:Signed-off-by: my@house -12:Signed-off-by: C O Mitter -EOF + Signed-off-by: my@house + EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 11:Signed-off-by: my@house + 12:Signed-off-by: C O Mitter + EOF test_cmp expected actual ' test_expect_success 'signoff: misc conforming footer elements' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -body + body -Signed-off-by: my@house -(cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709) -Tested-by: Some One -Bug: 1234 -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10: -11:Signed-off-by: my@house -15:Signed-off-by: C O Mitter -EOF + Signed-off-by: my@house + (cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709) + Tested-by: Some One + Bug: 1234 + EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 11:Signed-off-by: my@house + 15:Signed-off-by: C O Mitter + EOF test_cmp expected actual ' test_expect_success 'signoff: some random signoff-alike' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -body -Fooled-by-me: my@house -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -11: -12:Signed-off-by: C O Mitter -EOF + body + Fooled-by-me: my@house + EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 11: + 12:Signed-off-by: C O Mitter + EOF test_cmp expected actual ' test_expect_success 'signoff: not really a signoff' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -I want to mention about Signed-off-by: here. -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -9:I want to mention about Signed-off-by: here. -10: -11:Signed-off-by: C O Mitter -EOF + I want to mention about Signed-off-by: here. + EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 9:I want to mention about Signed-off-by: here. + 10: + 11:Signed-off-by: C O Mitter + EOF test_cmp expected actual ' test_expect_success 'signoff: not really a signoff (2)' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -My unfortunate -Signed-off-by: example happens to be wrapped here. -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10:Signed-off-by: example happens to be wrapped here. -11:Signed-off-by: C O Mitter -EOF + My unfortunate + Signed-off-by: example happens to be wrapped here. + EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10:Signed-off-by: example happens to be wrapped here. + 11:Signed-off-by: C O Mitter + EOF test_cmp expected actual ' test_expect_success 'signoff: valid S-o-b paragraph in the middle' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -Signed-off-by: my@house -Signed-off-by: your@house + Signed-off-by: my@house + Signed-off-by: your@house -A lot of houses. -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -9:Signed-off-by: my@house -10:Signed-off-by: your@house -11: -13: -14:Signed-off-by: C O Mitter -EOF + A lot of houses. + EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 9:Signed-off-by: my@house + 10:Signed-off-by: your@house + 11: + 13: + 14:Signed-off-by: C O Mitter + EOF test_cmp expected actual ' test_expect_success 'signoff: the same signoff at the end' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -body + body -Signed-off-by: C O Mitter -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10: -11:Signed-off-by: C O Mitter -EOF + Signed-off-by: C O Mitter + EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 11:Signed-off-by: C O Mitter + EOF test_cmp expected actual ' test_expect_success 'signoff: the same signoff at the end, no trailing NL' ' printf "subject\n\nSigned-off-by: C O Mitter " | append_signoff >actual && - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -9:Signed-off-by: C O Mitter -EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 9:Signed-off-by: C O Mitter + EOF test_cmp expected actual ' test_expect_success 'signoff: the same signoff NOT at the end' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -body + body -Signed-off-by: C O Mitter -Signed-off-by: my@house -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10: -11:Signed-off-by: C O Mitter -12:Signed-off-by: my@house -EOF + Signed-off-by: C O Mitter + Signed-off-by: my@house + EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 11:Signed-off-by: C O Mitter + 12:Signed-off-by: my@house + EOF test_cmp expected actual ' test_expect_success 'signoff: tolerate garbage in conforming footer' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -body + body -Tested-by: my@house -Some Trash -Signed-off-by: C O Mitter -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10: -13:Signed-off-by: C O Mitter -EOF + Tested-by: my@house + Some Trash + Signed-off-by: C O Mitter + EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 13:Signed-off-by: C O Mitter + EOF test_cmp expected actual ' test_expect_success 'signoff: respect trailer config' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -Myfooter: x -Some Trash -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -11: -12:Signed-off-by: C O Mitter -EOF + Myfooter: x + Some Trash + EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 11: + 12:Signed-off-by: C O Mitter + EOF test_cmp expected actual && test_config trailer.Myfooter.ifexists add && - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -Myfooter: x -Some Trash -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -11:Signed-off-by: C O Mitter -EOF + Myfooter: x + Some Trash + EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 11:Signed-off-by: C O Mitter + EOF test_cmp expected actual ' test_expect_success 'signoff: footer begins with non-signoff without @ sign' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -body + body -Reviewed-id: Noone -Tested-by: my@house -Change-id: Ideadbeef -Signed-off-by: C O Mitter -Bug: 1234 -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10: -14:Signed-off-by: C O Mitter -EOF + Reviewed-id: Noone + Tested-by: my@house + Change-id: Ideadbeef + Signed-off-by: C O Mitter + Bug: 1234 + EOF + cat >expected <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 14:Signed-off-by: C O Mitter + EOF test_cmp expected actual ' @@ -1452,42 +1467,42 @@ test_expect_success 'cover letter using branch description (1)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter master >actual && - grep hello actual >/dev/null + grep hello actual ' test_expect_success 'cover letter using branch description (2)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter rebuild-1~2..rebuild-1 >actual && - grep hello actual >/dev/null + grep hello actual ' test_expect_success 'cover letter using branch description (3)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter ^master rebuild-1 >actual && - grep hello actual >/dev/null + grep hello actual ' test_expect_success 'cover letter using branch description (4)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter master.. >actual && - grep hello actual >/dev/null + grep hello actual ' test_expect_success 'cover letter using branch description (5)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter -2 HEAD >actual && - grep hello actual >/dev/null + grep hello actual ' test_expect_success 'cover letter using branch description (6)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter -2 >actual && - grep hello actual >/dev/null + grep hello actual ' test_expect_success 'cover letter with nothing' ' @@ -1541,7 +1556,8 @@ test_expect_success 'format-patch format.outputDirectory option' ' test_config format.outputDirectory patches && rm -fr patches && git format-patch master..side && - test $(git rev-list master..side | wc -l) -eq $(ls patches | wc -l) + git rev-list master..side >list && + test_line_count = $(ls patches | wc -l) list ' test_expect_success 'format-patch -o overrides format.outputDirectory' ' @@ -1554,13 +1570,21 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' ' test_expect_success 'format-patch --base' ' git checkout side && - git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 && - git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 && + git format-patch --stdout --base=HEAD~3 -1 >patch && + tail -n 7 patch >actual1 && + git format-patch --stdout --base=HEAD~3 HEAD~.. >patch && + tail -n 7 patch >actual2 && echo >expected && echo "base-commit: $(git rev-parse HEAD~3)" >>expected && - echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected && - echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected && - signature >> expected && + git show --patch HEAD~2 >patch && + git patch-id --stable patch.id.raw && + awk "{print \$1}" patch.id && + echo "prerequisite-patch-id: $(cat patch.id)" >>expected && + git show --patch HEAD~1 >patch && + git patch-id --stable patch.id.raw && + awk "{print \$1}" patch.id && + echo "prerequisite-patch-id: $(cat patch.id)" >>expected && + signature >>expected && test_cmp expected actual1 && test_cmp expected actual2 ' From patchwork Sun May 5 16:24:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10930311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7D8C912 for ; Sun, 5 May 2019 16:24:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94B4828628 for ; Sun, 5 May 2019 16:24:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86BFB2863D; Sun, 5 May 2019 16:24:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F46A28628 for ; Sun, 5 May 2019 16:24:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727719AbfEEQYi (ORCPT ); Sun, 5 May 2019 12:24:38 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:45485 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726524AbfEEQYh (ORCPT ); Sun, 5 May 2019 12:24:37 -0400 Received: by mail-io1-f68.google.com with SMTP id b3so3452579iob.12 for ; Sun, 05 May 2019 09:24:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=CnrW+La4eX3HzQvomWyUA7+FYmydTRAfymlwknQqwvg=; b=MevF5D4+k4wF0Unh3vJBy/b7CIwyA3MDnzJ8dWJD9EDO+work6bndjhBnyurltAVZR p2RnTH3ryOaxK8L74qnCKS6nCQFpss/E/XxT1CbomFeyjDJ9U2U6zdmxwwQxFWlkxyFg ZALzZzuk/XNdsqpcm0qgZ/S352hnmgMTvyGNPa1fbPVsVW9H5WbGPECCkUCSh0k0EE0A HsTDi5oe94PN2QtTNF3UuCi17M5s+HXzaj/YlUtHNSaoq/kqGl+4gAGaDGfVCdPhWlRq eu5MWO7Ld7Q6bZpoANyyz12V9wEXv5++boA/aV5rpAMxgHfvyvW40dbRfdBaKBl05oNl LDdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=CnrW+La4eX3HzQvomWyUA7+FYmydTRAfymlwknQqwvg=; b=piHJk6AQlFCFHItj36dlI/nvX/vFy/Jp0MHHG5Mwb8gpjofQgXICOMV0jqUb3AYWeD Ud3BrXrypiCr5gsXwEHFt7quKuqk8KGONNrjLOKteKZUY2pr135KKrrErAEFjwQFEo/o bT9P0xcXHXe5/qv3QRjTLWUP2/GeZedG64oQRK/YjV0a/XuGGfq+fkrq0Khkw2VM1Egq hqGSxhjwXLceBgHuyor5Nfe8ePDsVzSfNvoCUHf/Lr8wfkmKNKLMMBk3DIXCP4bePu26 lUGdl+CSkw6mmYe2e8b9iNZgytkCo4XSka8UhFFhfkzM9eAEANB1tPCOtsFgVVftusNT pGTw== X-Gm-Message-State: APjAAAVG4v7OLtd2JvPyOLH5zSSecdlYm6Ld1I+fWFTgxyqO2ULDohcS NTfUReY9O++bgOY3ClDX3MSQB9Ui X-Google-Smtp-Source: APXvYqyxEAzljjUkv71Uc8dIM0Uy0VbronHjB2V3y7LizmuR2wda+CskkMmkrHoev7JL1Ew5butYng== X-Received: by 2002:a6b:bb82:: with SMTP id l124mr14923830iof.252.1557073476693; Sun, 05 May 2019 09:24:36 -0700 (PDT) Received: from archbookpro.localdomain ([199.119.233.193]) by smtp.gmail.com with ESMTPSA id n199sm3156314iod.54.2019.05.05.09.24.35 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 05 May 2019 09:24:35 -0700 (PDT) Date: Sun, 5 May 2019 12:24:33 -0400 From: Denton Liu To: Git Mailing List Subject: [PATCH 2/7] Doc: add more detail for git-format-patch Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In git-format-patch.txt, we were missing some key user information. First of all, using the `--to` and `--cc` options don't override `format.to` and `format.cc` variables, respectively. They add on to each other. Document this. In addition, document the special value of `--base=auto`. Finally, while we're at it, surround option arguments with <>. Signed-off-by: Denton Liu --- Documentation/git-format-patch.txt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index 1af85d404f..7b71d4e2ed 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -17,9 +17,9 @@ SYNOPSIS [--signature-file=] [-n | --numbered | -N | --no-numbered] [--start-number ] [--numbered-files] - [--in-reply-to=Message-Id] [--suffix=.] + [--in-reply-to=] [--suffix=.] [--ignore-if-in-upstream] - [--rfc] [--subject-prefix=Subject-Prefix] + [--rfc] [--subject-prefix=] [(--reroll-count|-v) ] [--to=] [--cc=] [--[no-]cover-letter] [--quiet] [--notes[=]] @@ -158,7 +158,7 @@ Beware that the default for 'git send-email' is to thread emails itself. If you want `git format-patch` to take care of threading, you will want to ensure that threading is disabled for `git send-email`. ---in-reply-to=Message-Id:: +--in-reply-to=:: Make the first mail (or all the mails with `--no-thread`) appear as a reply to the given Message-Id, which avoids breaking threads to provide a new patch series. @@ -192,13 +192,17 @@ will want to ensure that threading is disabled for `git send-email`. --to=:: Add a `To:` header to the email headers. This is in addition - to any configured headers, and may be used multiple times. + to any configured headers, and may be used multiple times. The + emails given will be used along with any emails given by + `format.to` configurations. The negated form `--no-to` discards all `To:` headers added so far (from config or command line). --cc=:: Add a `Cc:` header to the email headers. This is in addition - to any configured headers, and may be used multiple times. + to any configured headers, and may be used multiple times. The + emails given will be used along with any emails given by + `format.cc` configurations. The negated form `--no-cc` discards all `Cc:` headers added so far (from config or command line). @@ -309,7 +313,8 @@ you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`. --base=:: Record the base tree information to identify the state the patch series applies to. See the BASE TREE INFORMATION section - below for details. + below for details. If is equal to "auto", a base commit + is automatically chosen. --root:: Treat the revision argument as a , even if it From patchwork Sun May 5 16:24:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10930315 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2FC9933 for ; Sun, 5 May 2019 16:24:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F1362793A for ; Sun, 5 May 2019 16:24:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 836632862C; Sun, 5 May 2019 16:24:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25EA62793A for ; Sun, 5 May 2019 16:24:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727784AbfEEQYl (ORCPT ); Sun, 5 May 2019 12:24:41 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:55692 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726524AbfEEQYl (ORCPT ); Sun, 5 May 2019 12:24:41 -0400 Received: by mail-it1-f194.google.com with SMTP id q132so1492033itc.5 for ; Sun, 05 May 2019 09:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=PGGbmUB+G/tIuGZqsfh+tnjADx1mP+6dxKcQVPV44F8=; b=NbfuLpW0R08F4oibo/gpsUNmK9jYVDsJjQIQAqQoT4TRrgSECL4Te1GJ3LZBZbO6YL K0jX/8NxLUeoJCeu1PvaznkCuxtpTXqAjv7ZSD+S/9nF7YVCsXL5r5QQKlTlJRHpxvgw LTFitd+dr+mk2JPgzkxS8i1/Eio0hWuAWLsRPUMS7qTR836WWamYMK0FyFgZoQUX0Hlp TvZ0Y21/klL9gOo5GxHsvr52M851luXrWIxY5qkzUAQy4Yo4kq67x+ed6RGQY4g9FGcN JbcXKCuBrvtTxnJ6bWRE3KDHsfeC13eXZT3G/G+Oc+ImMommpW+fKV5+LjJ8Sqzmh/+K wkBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=PGGbmUB+G/tIuGZqsfh+tnjADx1mP+6dxKcQVPV44F8=; b=iDT5sWZnaadOftsh5bsEdPVaZOerV4/hq9Yd7elxrG7+P1ufWgmaeGgqNS0mrWeTQ1 HtNQ0Guc2YVU2kaAFTPI0Dpvw0aWUHRmPcmvrxaLkuZklMiYaVD+FgkBZAfx8Rn5lDKB o1abW046lqH3Pt8wSGuiuzqwel5k96QVThW/W5NAbg5DqI8e6O5dc27IEuVGMP+zSgb4 4CC1fj6HwzRVt9FKuKmiijznJAkSAvsE25U7qyzFuG5r+giwB3EES/CKcDQbLMGYazTA MKWjU5kaMRKF4fL4Qql56lavpESByNiNimvpRSAVB339/t7pdQEtevzCK+8Ofq5iMowb fIJA== X-Gm-Message-State: APjAAAUq0vpjEIO7Kh30Z7OE56edUfJAkh/Xu4nP7QQINtPFQLjEKUwC k0e95AAlq2bt5UfQqy84RZlkncLh X-Google-Smtp-Source: APXvYqwALNpshkyW6VYuEUz0gn8juBwzud49vPMxwlIzLZTSXBJP7HaLehKf9MCON26tN04AUrC+DQ== X-Received: by 2002:a02:c8da:: with SMTP id q26mr5705343jao.0.1557073480329; Sun, 05 May 2019 09:24:40 -0700 (PDT) Received: from archbookpro.localdomain ([199.119.233.193]) by smtp.gmail.com with ESMTPSA id x187sm3826599itb.39.2019.05.05.09.24.39 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 05 May 2019 09:24:39 -0700 (PDT) Date: Sun, 5 May 2019 12:24:36 -0400 From: Denton Liu To: Git Mailing List Subject: [PATCH 3/7] branch.c: extract read_branch_config function Message-ID: <5318dab19abbe2593bd24c6aaff8e6254a39a4e6.1557072929.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the future, we'll need to use `read_branch_config` as a generic base for other branch-config reading functions. Extract it from `read_branch_desc` so that it can be reused later. Signed-off-by: Denton Liu --- branch.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/branch.c b/branch.c index 28b81a7e02..4b49976924 100644 --- a/branch.c +++ b/branch.c @@ -162,11 +162,11 @@ static void setup_tracking(const char *new_ref, const char *orig_ref, free(tracking.src); } -int read_branch_desc(struct strbuf *buf, const char *branch_name) +static int read_branch_config(struct strbuf *buf, const char *branch_name, const char *key) { char *v = NULL; struct strbuf name = STRBUF_INIT; - strbuf_addf(&name, "branch.%s.description", branch_name); + strbuf_addf(&name, "branch.%s.%s", branch_name, key); if (git_config_get_string(name.buf, &v)) { strbuf_release(&name); return -1; @@ -177,6 +177,11 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name) return 0; } +int read_branch_desc(struct strbuf *buf, const char *branch_name) +{ + return read_branch_config(buf, branch_name, "description"); +} + /* * Check if 'name' can be a valid name for a branch; die otherwise. * Return 1 if the named branch already exists; return 0 otherwise. From patchwork Sun May 5 16:24:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10930317 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 297C2912 for ; Sun, 5 May 2019 16:24:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1480D2793A for ; Sun, 5 May 2019 16:24:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 091132862C; Sun, 5 May 2019 16:24:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41E5A2793A for ; Sun, 5 May 2019 16:24:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727814AbfEEQYp (ORCPT ); Sun, 5 May 2019 12:24:45 -0400 Received: from mail-it1-f193.google.com ([209.85.166.193]:51325 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726524AbfEEQYo (ORCPT ); Sun, 5 May 2019 12:24:44 -0400 Received: by mail-it1-f193.google.com with SMTP id s3so4512776itk.1 for ; Sun, 05 May 2019 09:24:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=+0n8bicQLL8n2uG5RKj3zBGWDg1+/H12Ckm87843CcA=; b=Hunfw8utRLxb77YHZlMzjcCLQ06QTH+gIQHXJ8l6KAmE3RYHhGlQOF+ZZEutLjbtH7 OsNO5EXAADLFKNxottKk6tD7AFIMC16QKuJ7mGcHfB+q874mkNwas+cmBfNXdcwGX32z bPlU/dwG/7ncCN+n+BSizd5BMAwXE6zjv1vVl5XBiwn5AJ0373jn/a71J/KGmYMwWjYL lg3Ay4IIp0LybBlTUPx/ME4v1p13m1rfHl7R9cTEAFPtNfvgn80KFLwXT/ZEIr2AIom4 Gejd2Ondc701USYIqz2qYm0Ymo7hA326rLxYjXqk/NOXEhBPniYnmwwXbs6G9cgDweV9 19IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=+0n8bicQLL8n2uG5RKj3zBGWDg1+/H12Ckm87843CcA=; b=Y6yRrzuswmrc03gvi+MI7fywOvfVAPHQo2ycny1fpGGp8on7tn+ZEOULG5EMb/AjLB 3ZFx8TuKEDcnLRcolqGQKfHyTl+bI1poScmot6ck3MJ2HXfqEH3DhaNVpJ1k/h0KGAev r54uaXGyZvHIZ52NHW5vDJThB2M71QwTlIsxLurkDf4kUeSKs32H3OIYZXieO6bXzg7u ot4gAC+HvjAF2rqWOHa7gX3rmryynvLlIwbd01bT0TzBR+zrMZOZ8gZ8qI4vXJ+m4q19 /kzGvx3Xi/BmQ9RkLA+r/PA8q2X8jkbEYaIOn/U1QzwS4ViuMcp5BEwPhsCvpYchl0++ 5aAA== X-Gm-Message-State: APjAAAUOS9W/Fv6T/OrX+UbJdi9lDG2QF3R6ScN4xCd1dQ11JFICUPSn TFgzyrOaeR7HJ2YMKX0wNNVVaauJ X-Google-Smtp-Source: APXvYqwjuXENuZI5Khf39+UAIifowQeMs0qHOl1QUe0Ud9g59WXthtDy1n3rny/+B6uJCWL7B9RGYg== X-Received: by 2002:a02:694f:: with SMTP id e76mr15659982jac.111.1557073483816; Sun, 05 May 2019 09:24:43 -0700 (PDT) Received: from archbookpro.localdomain ([199.119.233.193]) by smtp.gmail.com with ESMTPSA id c7sm2670253ioc.63.2019.05.05.09.24.42 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 05 May 2019 09:24:43 -0700 (PDT) Date: Sun, 5 May 2019 12:24:40 -0400 From: Denton Liu To: Git Mailing List Subject: [PATCH 4/7] format-patch: make cover letter subject configurable Message-ID: <0f62e4dcb977f3a5d407ff6ae4f11f464558b051.1557072929.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We used to populate the subject of the cover letter generated by git-format-patch with "*** SUBJECT HERE ***". However, if a user submits multiple patchsets, they may want to keep a consistent subject between rerolls. If git-format-patch is run on a branch that has `branch..coverSubject` defined, make the cover letter's subject be that value instead of the generic "*** SUBJECT HERE ***". In addition, add the `--cover-subject` option to override this setting. Signed-off-by: Denton Liu --- Documentation/config/branch.txt | 4 ++++ Documentation/git-format-patch.txt | 12 ++++++++++++ branch.c | 5 +++++ branch.h | 5 +++++ builtin/log.c | 26 +++++++++++++++++++------- t/t4014-format-patch.sh | 20 ++++++++++++++++++++ t/t9902-completion.sh | 5 ++++- 7 files changed, 69 insertions(+), 8 deletions(-) diff --git a/Documentation/config/branch.txt b/Documentation/config/branch.txt index 019d60ede2..2bff738982 100644 --- a/Documentation/config/branch.txt +++ b/Documentation/config/branch.txt @@ -100,3 +100,7 @@ branch..description:: `git branch --edit-description`. Branch description is automatically added in the format-patch cover letter or request-pull summary. + +branch..coverSubject:: + When format-patch generates a cover letter, use the specified + subject for the cover letter instead of the generic template. diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index 7b71d4e2ed..af7883acbe 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -19,6 +19,7 @@ SYNOPSIS [--start-number ] [--numbered-files] [--in-reply-to=] [--suffix=.] [--ignore-if-in-upstream] + [--cover-subject=] [--rfc] [--subject-prefix=] [(--reroll-count|-v) ] [--to=] [--cc=] @@ -170,6 +171,10 @@ will want to ensure that threading is disabled for `git send-email`. patches being generated, and any patch that matches is ignored. +--cover-subject=:: + Instead of using the default "*** SUBJECT HERE ***" subject for + the cover letter, use the given . + --subject-prefix=:: Instead of the standard '[PATCH]' prefix in the subject line, instead use '[]'. This @@ -346,6 +351,13 @@ attachments, and sign off patches with configuration variables. coverletter = auto ------------ +In addition, for a specific branch, you can specify a custom cover +letter subject. + +------------ +[branch "branch-name"] + coverSubject = "subject for branch-name only" +------------ DISCUSSION ---------- diff --git a/branch.c b/branch.c index 4b49976924..40d30b8fa7 100644 --- a/branch.c +++ b/branch.c @@ -182,6 +182,11 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name) return read_branch_config(buf, branch_name, "description"); } +int read_branch_subject(struct strbuf *buf, const char *branch_name) +{ + return read_branch_config(buf, branch_name, "coversubject"); +} + /* * Check if 'name' can be a valid name for a branch; die otherwise. * Return 1 if the named branch already exists; return 0 otherwise. diff --git a/branch.h b/branch.h index 29c1afa4d0..6a8936bbc8 100644 --- a/branch.h +++ b/branch.h @@ -79,6 +79,11 @@ extern int install_branch_config(int flag, const char *local, const char *origin */ extern int read_branch_desc(struct strbuf *, const char *branch_name); +/* + * Read branch subject + */ +extern int read_branch_subject(struct strbuf *, const char *branch_name); + /* * Check if a branch is checked out in the main worktree or any linked * worktree and die (with a message describing its checkout location) if diff --git a/builtin/log.c b/builtin/log.c index ab859f5904..6f19326aea 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1034,13 +1034,14 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout, struct commit *origin, int nr, struct commit **list, const char *branch_name, + const char *subject, int quiet) { const char *committer; - const char *body = "*** SUBJECT HERE ***\n\n*** BLURB HERE ***\n"; - const char *msg; + const char *body = "*** BLURB HERE ***"; struct shortlog log; struct strbuf sb = STRBUF_INIT; + struct strbuf subject_sb = STRBUF_INIT; int i; const char *encoding = "UTF-8"; int need_8bit_cte = 0; @@ -1068,17 +1069,24 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout, if (!branch_name) branch_name = find_branch_name(rev); - msg = body; + if (!subject) { + if (branch_name && *branch_name && !read_branch_subject(&subject_sb, branch_name)) + subject = subject_sb.buf; + else + subject = "*** SUBJECT HERE ***"; + } + pp.fmt = CMIT_FMT_EMAIL; pp.date_mode.type = DATE_RFC2822; pp.rev = rev; pp.print_email_subject = 1; pp_user_info(&pp, NULL, &sb, committer, encoding); - pp_title_line(&pp, &msg, &sb, encoding, need_8bit_cte); - pp_remainder(&pp, &msg, &sb, 0); + pp_title_line(&pp, &subject, &sb, encoding, need_8bit_cte); + pp_remainder(&pp, &body, &sb, 0); add_branch_description(&sb, branch_name); fprintf(rev->diffopt.file, "%s\n", sb.buf); + strbuf_release(&subject_sb); strbuf_release(&sb); shortlog_init(&log); @@ -1512,6 +1520,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) int no_binary_diff = 0; int zero_commit = 0; struct commit *origin = NULL; + const char *cover_subject = NULL; const char *in_reply_to = NULL; struct patch_ids ids; struct strbuf buf = STRBUF_INIT; @@ -1554,6 +1563,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) { OPTION_CALLBACK, 0, "rfc", &rev, NULL, N_("Use [RFC PATCH] instead of [PATCH]"), PARSE_OPT_NOARG | PARSE_OPT_NONEG, rfc_callback }, + OPT_STRING(0, "cover-subject", &cover_subject, N_("subject"), + N_("the subject for the cover letter")), { OPTION_CALLBACK, 0, "subject-prefix", &rev, N_("prefix"), N_("Use [] instead of [PATCH]"), PARSE_OPT_NONEG, subject_prefix_callback }, @@ -1617,8 +1628,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) extra_to.strdup_strings = 1; extra_cc.strdup_strings = 1; init_log_defaults(); - git_config(git_format_config, NULL); repo_init_revisions(the_repository, &rev, prefix); + + git_config(git_format_config, NULL); rev.commit_format = CMIT_FMT_EMAIL; rev.expand_tabs_in_log_default = 0; rev.verbose_header = 1; @@ -1893,7 +1905,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) if (thread) gen_message_id(&rev, "cover"); make_cover_letter(&rev, use_stdout, - origin, nr, list, branch_name, quiet); + origin, nr, list, branch_name, cover_subject, quiet); print_bases(&bases, rev.diffopt.file); print_signature(rev.diffopt.file); total++; diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index d05cd256c7..1cf4dfbce2 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -1463,6 +1463,26 @@ test_expect_success 'format patch ignores color.ui' ' test_cmp expect actual ' +test_expect_success 'cover letter with config subject' ' + test_config branch.rebuild-1.coverSubject "config subject" && + git checkout rebuild-1 && + git format-patch --stdout --cover-letter master >actual && + grep "Subject: \[PATCH 0/2\] config subject" actual +' + +test_expect_success 'cover letter with command-line subject' ' + git checkout rebuild-1 && + git format-patch --stdout --cover-letter --cover-subject "command-line subject" master >actual && + grep "Subject: \[PATCH 0/2\] command-line subject" actual +' + +test_expect_success 'cover letter with command-line subject overrides config' ' + test_config branch.rebuild-1.coverSubject "config subject" && + git checkout rebuild-1 && + git format-patch --stdout --cover-letter --cover-subject "command-line subject" master >actual && + grep "Subject: \[PATCH 0/2\] command-line subject" actual +' + test_expect_success 'cover letter using branch description (1)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index f5e21bf970..0da92179da 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -1542,7 +1542,10 @@ test_expect_success 'complete tree filename with metacharacters' ' ' test_expect_success PERL 'send-email' ' - test_completion "git send-email --cov" "--cover-letter " && + test_completion "git send-email --cov" <<-\EOF && + --cover-letter Z + --cover-subject=Z + EOF test_completion "git send-email ma" "master " ' From patchwork Sun May 5 16:24:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10930319 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F28A4912 for ; Sun, 5 May 2019 16:24:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFD9D2793A for ; Sun, 5 May 2019 16:24:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D46DD2862C; Sun, 5 May 2019 16:24:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 754092793A for ; Sun, 5 May 2019 16:24:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727824AbfEEQYs (ORCPT ); Sun, 5 May 2019 12:24:48 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:35746 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726524AbfEEQYs (ORCPT ); Sun, 5 May 2019 12:24:48 -0400 Received: by mail-it1-f194.google.com with SMTP id l140so16484883itb.0 for ; Sun, 05 May 2019 09:24:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/Sp1xMBv9vXcJm5TOSj/GGmWCsYTgPGEu0knDjTbctw=; b=He26XxaiUipVnu/vZ5DtZN/PtHAlWob78hHxGZ+wGX5QbzZaJi847mJgQZpTVzM/9P aWdQE1ig5EpGOvOPp7AMUdEdvmU4t4YETKBSNNktSqJoiDMxo0jaPpEgjg8288UHW8Hh L9/KJsyyuMH8Pqhpg3KfntYIcgOoYeEeiO32vWW/fzfJbN3iNOuuSDTNmLIEpONlwvT4 3UdWuRqRs7p4e9P+XrXZekOrc328Ba7Mv7eE28MdEJ1k+EmQYdRtAj9+ai2h1N1W5FGu vPHRzppkyRJ7Mpn7nj1AavPS7nVUKdP+mzz9A+cqkf/iCHUUaJR5lsi5Xq6Lc+Vi7PmR Ftqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/Sp1xMBv9vXcJm5TOSj/GGmWCsYTgPGEu0knDjTbctw=; b=hBsFuQPLkwbD0+KYu7vBJdw1xFj2LDyUmIc+nQ0NBScaXt1USjdRyQDvynSzdGHK/D GtnKrr6ha5TCDkLge5y+jtztrlswMYvkHi8FHn1W7fz3333P4I1SDmipuLTRWWD8mYum E11qWwZGrlR2wbPPKyIABQ9EutvEyi6uVFChUj4jnxHqM0iSYtbSLY5QZ9198fOTmMGl ycp2s0Zg+AakcS6LXmgBohQJvbhf1ZUZjn+UNXi8zBupGPWcIOGStHQ96sH9UVwI9hoj jLfCD6aSAcJXQ8FvrlMnYXQEb/t7kixPy4jYp5DWHlGMHwMqHjqenKhRoXagZWATbnDO pUaw== X-Gm-Message-State: APjAAAUatGO+UUmgF84V7ngch4JDC4s2/BozP6KWSLjCtgmGKFl8RQ/u z3lvjF6tzTGNr3LDnU+qlk1WHiKH X-Google-Smtp-Source: APXvYqwuBZ8alOHpHlrBwQgmsCZxUP80Mz/6ScD8CpBugL16/aO2q07MKrhyNbP45gpEyrjCi3tPcg== X-Received: by 2002:a24:7d0a:: with SMTP id b10mr16526226itc.54.1557073486874; Sun, 05 May 2019 09:24:46 -0700 (PDT) Received: from archbookpro.localdomain ([199.119.233.193]) by smtp.gmail.com with ESMTPSA id q207sm3659321itc.37.2019.05.05.09.24.45 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 05 May 2019 09:24:46 -0700 (PDT) Date: Sun, 5 May 2019 12:24:44 -0400 From: Denton Liu To: Git Mailing List Subject: [PATCH 5/7] format-patch: move extra_headers logic later Message-ID: <5ee43bc0b9c349042b60c918b2dda8ed6a7b0a6e.1557072929.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In a future patch, we need to perform the addition of To: and Cc: to extra_headers after the branch_name logic. Simply transpose this logic later in the function so that this happens. (This patch is best viewed with `git diff --color-moved`.) Note that this logic only depends on the `git_config` and `repo_init_revisions` and is depended on by the patch creation logic which is directly below it so this move is effectively a no-op as no dependencies being reordered. Signed-off-by: Denton Liu --- builtin/log.c | 58 +++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/builtin/log.c b/builtin/log.c index 6f19326aea..685e319078 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1665,35 +1665,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) rev.subject_prefix = strbuf_detach(&sprefix, NULL); } - for (i = 0; i < extra_hdr.nr; i++) { - strbuf_addstr(&buf, extra_hdr.items[i].string); - strbuf_addch(&buf, '\n'); - } - - if (extra_to.nr) - strbuf_addstr(&buf, "To: "); - for (i = 0; i < extra_to.nr; i++) { - if (i) - strbuf_addstr(&buf, " "); - strbuf_addstr(&buf, extra_to.items[i].string); - if (i + 1 < extra_to.nr) - strbuf_addch(&buf, ','); - strbuf_addch(&buf, '\n'); - } - - if (extra_cc.nr) - strbuf_addstr(&buf, "Cc: "); - for (i = 0; i < extra_cc.nr; i++) { - if (i) - strbuf_addstr(&buf, " "); - strbuf_addstr(&buf, extra_cc.items[i].string); - if (i + 1 < extra_cc.nr) - strbuf_addch(&buf, ','); - strbuf_addch(&buf, '\n'); - } - - rev.extra_headers = strbuf_detach(&buf, NULL); - if (from) { if (split_ident_line(&rev.from_ident, from, strlen(from))) die(_("invalid ident line: %s"), from); @@ -1796,6 +1767,35 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) } } + for (i = 0; i < extra_hdr.nr; i++) { + strbuf_addstr(&buf, extra_hdr.items[i].string); + strbuf_addch(&buf, '\n'); + } + + if (extra_to.nr) + strbuf_addstr(&buf, "To: "); + for (i = 0; i < extra_to.nr; i++) { + if (i) + strbuf_addstr(&buf, " "); + strbuf_addstr(&buf, extra_to.items[i].string); + if (i + 1 < extra_to.nr) + strbuf_addch(&buf, ','); + strbuf_addch(&buf, '\n'); + } + + if (extra_cc.nr) + strbuf_addstr(&buf, "Cc: "); + for (i = 0; i < extra_cc.nr; i++) { + if (i) + strbuf_addstr(&buf, " "); + strbuf_addstr(&buf, extra_cc.items[i].string); + if (i + 1 < extra_cc.nr) + strbuf_addch(&buf, ','); + strbuf_addch(&buf, '\n'); + } + + rev.extra_headers = strbuf_detach(&buf, NULL); + /* * We cannot move this anywhere earlier because we do want to * know if --root was given explicitly from the command line. From patchwork Sun May 5 16:24:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10930321 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DB09912 for ; Sun, 5 May 2019 16:24:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A9C02793A for ; Sun, 5 May 2019 16:24:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F4C32862C; Sun, 5 May 2019 16:24:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA7582793A for ; Sun, 5 May 2019 16:24:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727847AbfEEQYv (ORCPT ); Sun, 5 May 2019 12:24:51 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:51076 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727825AbfEEQYv (ORCPT ); Sun, 5 May 2019 12:24:51 -0400 Received: by mail-it1-f194.google.com with SMTP id q14so16772847itk.0 for ; Sun, 05 May 2019 09:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=zvI5qgrs56hUr5MH02wrtUaLY6NJWP/VG8VlvmB2X+A=; b=XbdFwZvfYSiXkR2THLr7uwleGKqm2FbKUmxYNKhQV4t9+BPllMay2eSQ6NRcSLMPXZ Mrg2XAPl7h3WmRv3FT7+nLTcmr/9tyMH8S8Dy3y+y7qEuLiahDGOPitRQExx7PlFX1qN //RkuUmJf9KADVTb7JIiZJw/coGRdbW/qMagF63bwvFAu3H4dLw64e3QN+XHrB+k7ALx hHUHZpk3yP4MY4BDFdPQHLCuEKnWfCQ7bMgeKby9kdBV+hwRGwB99x4mEN81xpDo74bw AAsZBYh9vlMW0YnkiZfexr5T1aaNBIu0pl8MOhUvTPsqKcBdMmlqZ+jI+DsUYc1Vf5q0 sIwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=zvI5qgrs56hUr5MH02wrtUaLY6NJWP/VG8VlvmB2X+A=; b=R+M7hkMcl/C8iqdQsHtQNZTfcawfJVUiS2rfEIdA9p5sFtigPLhu8f2DbvnD07EyT/ DxFgRFPyeYYA66vjFDRDEwbKMt+Bc00aeaNpF6nZeOPJq5y0vOl6TT0KuBd4IxSLAefr zYVfW2kLkfD79YNkeOON8obf4XnHG9DbPLm26q1sJ5uyJPzivm338SR65X3JPRkjesXu QUvzukjsahl9Sl8Ia+54mOMU9E2HL0MM2vuS+++j4y1QEQsrTTYaiaFf0eN3ic320iiQ vXhr4WteHwhgU15EHIv8/FVzPlFbrUkimCLT6v5EmO7RvRbZhiWEbq5NvNE2u9IzHud1 5Jlw== X-Gm-Message-State: APjAAAV5V2lV8F10e3ezyR4u2dhWTZ1AoCXkfouUdRwRra6t2Eo8Ab/D XPnGI1aFFET3vTqpjglBE4GgYJIJ X-Google-Smtp-Source: APXvYqyKLfUHAzciwSi4raDGtSXjooAKTIVAu+yv4eq9OFPBCDUSeOjJvbJE11Q62mbIeLNtAgNULQ== X-Received: by 2002:a24:2f42:: with SMTP id j63mr15015810itj.108.1557073489726; Sun, 05 May 2019 09:24:49 -0700 (PDT) Received: from archbookpro.localdomain ([199.119.233.193]) by smtp.gmail.com with ESMTPSA id p23sm2713698iob.79.2019.05.05.09.24.48 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 05 May 2019 09:24:49 -0700 (PDT) Date: Sun, 5 May 2019 12:24:47 -0400 From: Denton Liu To: Git Mailing List Subject: [PATCH 6/7] string-list: create string_list_append_all Message-ID: <5f487f65e88569f38650efe9055b8f6391621c7a.1557072929.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In a future patch, we'll need to take one string_list and append it to the end of another. Create the `string_list_append_all` function which does this. Signed-off-by: Denton Liu --- string-list.c | 9 +++++++++ string-list.h | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/string-list.c b/string-list.c index a917955fbd..e63d58fbd2 100644 --- a/string-list.c +++ b/string-list.c @@ -215,6 +215,15 @@ struct string_list_item *string_list_append(struct string_list *list, list->strdup_strings ? xstrdup(string) : (char *)string); } +void string_list_append_all(struct string_list *list, + const struct string_list *append_list) +{ + struct string_list_item *item; + ALLOC_GROW(list->items, list->nr + append_list->nr, list->alloc); + for_each_string_list_item(item, append_list) + string_list_append(list, item->string); +} + /* * Encapsulate the compare function pointer because ISO C99 forbids * casting from void * to a function pointer and vice versa. diff --git a/string-list.h b/string-list.h index 18c718c12c..32e0c4b47f 100644 --- a/string-list.h +++ b/string-list.h @@ -208,6 +208,13 @@ struct string_list_item *string_list_append(struct string_list *list, const char */ struct string_list_item *string_list_append_nodup(struct string_list *list, char *string); +/** + * Add all strings in append_list to list. If list->strdup_string is + * set, then each string is copied; otherwise the new string_list_entry + * refers to the entry in the append_list. + */ +void string_list_append_all(struct string_list *list, const struct string_list *append_list); + /** * Sort the list's entries by string value in `strcmp()` order. */ From patchwork Sun May 5 16:24:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10930323 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AECC0933 for ; Sun, 5 May 2019 16:24:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97A3F2793A for ; Sun, 5 May 2019 16:24:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B144281DB; Sun, 5 May 2019 16:24:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D14712793A for ; Sun, 5 May 2019 16:24:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727861AbfEEQYy (ORCPT ); Sun, 5 May 2019 12:24:54 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:42068 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727825AbfEEQYy (ORCPT ); Sun, 5 May 2019 12:24:54 -0400 Received: by mail-io1-f67.google.com with SMTP id c24so9105790iom.9 for ; Sun, 05 May 2019 09:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=QwX7VAYhuUVcR2HyKAVEOQPOp/lIvhZUrmzk2hFAoTg=; b=eWBqA/UeCiGaFAcaRStpDjC9qPrddsijQrZlxabEWba99T8zx/nU0PMGGnVP6477kZ hEjUzRrzXwVo5+bSEErgpM3dxfX/KWgjdxBRNXzOCMkQUk9wyNPqpa3ZrXSUs38r5rho 3ntmz0zzIaDhG3s9GqmDWKm0gviAFvIZKniAhbnwNVvsYlyesIkOKYMWWO5eotZ8c+JR fwVs4JVLv+m8yBMHvfGnoQjoBOKK9+jvUUKySB57j9ELl+Xprch8vonewqjiGPV+eqR7 u5x+CgxH1bgfScyJCsz1CjVHQbTd4ymA9yq+TUZ1Qe82vbevWq3GMC/w7ju4vw6q4VJB J84w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=QwX7VAYhuUVcR2HyKAVEOQPOp/lIvhZUrmzk2hFAoTg=; b=hhSpN0aL8fDWCREYLWI1qNV8+COnnCXgbF4H1LZuufPtTbNtqW9sPUS4t7964fKTlv ngPDFzoz6p8xDCR2ufZs8kSPSp0IAMgdXVrR7ha5ImgZtuWyXqesfvU5ma8wwyNmyxf7 2n/8mpydwWYf2iLyuxbtvNRcyvWGQL5bNKN9dF8ZYnqp3Xon7GwnJ3CUgU15pxBAilOv q/M/RMaZgFX1aOEvdoG/IZYFI3cAMuZInPbK61g762LwM5VkCxmnOJcQeLn0gzpbekwc G25i0US+oTvHUPRWHL8rlcWJtJRkgq94/V6fIQkUT+4qhGWjJYeERTls10fxfVSpDzo9 xZLA== X-Gm-Message-State: APjAAAUEzoYNvz+kLdQSytRb+MIpqJZ1hT0HntFa0ABo1h8erPYQvKwq CUuisQPlQzvnOeWJ0fJLjYRLtDvP X-Google-Smtp-Source: APXvYqx0g3nwMKzTVICeTdlyzM4LF0/gbP/1gbcrcz6pCWw7vXB5ZJdD3PDhwZr2r1RZT1rpmsz3dg== X-Received: by 2002:a05:6602:21d7:: with SMTP id c23mr2997677ioc.66.1557073493226; Sun, 05 May 2019 09:24:53 -0700 (PDT) Received: from archbookpro.localdomain ([199.119.233.193]) by smtp.gmail.com with ESMTPSA id v187sm9107503ita.0.2019.05.05.09.24.51 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 05 May 2019 09:24:52 -0700 (PDT) Date: Sun, 5 May 2019 12:24:49 -0400 From: Denton Liu To: Git Mailing List Subject: [PATCH 7/7] format-patch: read branch-specific To: and Cc: headers Message-ID: <7e625b688883c0528348f77d181bc28195d8ab92.1557072929.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If a user wishes to keep track of whom to Cc: on individual patchsets, they must manually keep track of each recipient and fill it in with the `--cc` option on git-format-patch each time. However, on the Git mailing list, Cc:'s are typically never dropped. As a result, it would be nice to have a method to keep track of recipients on a per-branch basis. Currently, git-format-patch gets its To: headers from the `--to` options and the `format.to` config variable. The Cc: header is derived similarly. In addition to the above, read To: and Cc: headers from `branch..to` and `branch..cc` so that users can have branch-specific configuration options. Signed-off-by: Denton Liu --- Documentation/config/branch.txt | 6 ++ Documentation/git-format-patch.txt | 10 +-- builtin/log.c | 63 +++++++++++++++-- t/t4014-format-patch.sh | 108 +++++++++++++++++++++++------ 4 files changed, 159 insertions(+), 28 deletions(-) diff --git a/Documentation/config/branch.txt b/Documentation/config/branch.txt index 2bff738982..22b9bf3d0d 100644 --- a/Documentation/config/branch.txt +++ b/Documentation/config/branch.txt @@ -104,3 +104,9 @@ branch..description:: branch..coverSubject:: When format-patch generates a cover letter, use the specified subject for the cover letter instead of the generic template. + +branch..to:: +branch..cc:: + Additional recipients to include in a patch to be submitted + by mail. See the --to and --cc options in + linkgit:git-format-patch[1]. diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index af7883acbe..1c972f683a 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -199,7 +199,7 @@ will want to ensure that threading is disabled for `git send-email`. Add a `To:` header to the email headers. This is in addition to any configured headers, and may be used multiple times. The emails given will be used along with any emails given by - `format.to` configurations. + `format.to` and `branch..to` configurations. The negated form `--no-to` discards all `To:` headers added so far (from config or command line). @@ -207,7 +207,7 @@ will want to ensure that threading is disabled for `git send-email`. Add a `Cc:` header to the email headers. This is in addition to any configured headers, and may be used multiple times. The emails given will be used along with any emails given by - `format.cc` configurations. + `format.cc` and `branch..cc` configurations. The negated form `--no-cc` discards all `Cc:` headers added so far (from config or command line). @@ -335,7 +335,7 @@ CONFIGURATION ------------- You can specify extra mail header lines to be added to each message, defaults for the subject prefix and file suffix, number patches when -outputting more than one patch, add "To" or "Cc:" headers, configure +outputting more than one patch, add "To:" or "Cc:" headers, configure attachments, and sign off patches with configuration variables. ------------ @@ -352,11 +352,13 @@ attachments, and sign off patches with configuration variables. ------------ In addition, for a specific branch, you can specify a custom cover -letter subject. +letter subject, and add additional "To:" or "Cc:" headers. ------------ [branch "branch-name"] coverSubject = "subject for branch-name only" + to = + cc = ------------ DISCUSSION diff --git a/builtin/log.c b/builtin/log.c index 685e319078..6825d95c5f 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -738,6 +738,8 @@ static char *default_attach = NULL; static struct string_list extra_hdr = STRING_LIST_INIT_NODUP; static struct string_list extra_to = STRING_LIST_INIT_NODUP; static struct string_list extra_cc = STRING_LIST_INIT_NODUP; +int to_cleared; +int cc_cleared; static void add_header(const char *value) { @@ -1030,6 +1032,55 @@ static void show_diffstat(struct rev_info *rev, fprintf(rev->diffopt.file, "\n"); } +static void add_branch_headers(struct rev_info *rev, const char *branch_name) +{ + struct strbuf buf = STRBUF_INIT; + const struct string_list *values; + + if (!branch_name) + branch_name = find_branch_name(rev); + + if (!branch_name || !*branch_name) + return; + + /* + * HACK: We only use branch-specific recipients iff the list has not + * been cleared by an earlier --no-{to,cc} option on the command-line. + * + * When we get format.{to,cc} options, they can be cleared by + * --no-{to,cc} options since the `git_config` call comes before the + * `parse_options` call. + * + * However, in the case of branch..{to,cc}, this function needs + * to be called after `setup_revisions`, which must be called after + * `parse_options`. However, in order for the --no-{to,cc} logic to + * clear the extra_{to,cc} string_list, this function should actually + * be called _before_ `parse_options`. As a result, we have a circular + * dependency. + * + * The {to,cc}_cleared flag lets us workaround this by just no + * including branch-specific recipients iff --no-{to,cc} has been + * specified on the command-line. + */ + + if (!to_cleared) { + strbuf_addf(&buf, "branch.%s.to", branch_name); + values = git_config_get_value_multi(buf.buf); + if (values) + string_list_append_all(&extra_to, values); + } + + if (!cc_cleared) { + strbuf_reset(&buf); + strbuf_addf(&buf, "branch.%s.cc", branch_name); + values = git_config_get_value_multi(buf.buf); + if (values) + string_list_append_all(&extra_cc, values); + } + + strbuf_release(&buf); +} + static void make_cover_letter(struct rev_info *rev, int use_stdout, struct commit *origin, int nr, struct commit **list, @@ -1289,18 +1340,20 @@ static int header_callback(const struct option *opt, const char *arg, int unset) static int to_callback(const struct option *opt, const char *arg, int unset) { - if (unset) + if (unset) { + to_cleared = 1; string_list_clear(&extra_to, 0); - else + } else string_list_append(&extra_to, arg); return 0; } static int cc_callback(const struct option *opt, const char *arg, int unset) { - if (unset) + if (unset) { + cc_cleared = 1; string_list_clear(&extra_cc, 0); - else + } else string_list_append(&extra_cc, arg); return 0; } @@ -1767,6 +1820,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) } } + add_branch_headers(&rev, branch_name); + for (i = 0; i < extra_hdr.nr; i++) { strbuf_addstr(&buf, extra_hdr.items[i].string); strbuf_addch(&buf, '\n'); diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 1cf4dfbce2..6578e6b433 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -234,6 +234,65 @@ test_expect_failure 'configuration To: header (rfc2047)' ' grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= \$" hdrs9 ' +test_expect_success 'branch-specific configuration To: header (ascii)' ' + + test_unconfig format.to && + git config branch.side.to "R E Cipient " && + git format-patch --stdout master..side >patch10 && + sed -e "/^\$/q" patch10 >hdrs10 && + grep "^To: R E Cipient \$" hdrs10 +' + +test_expect_failure 'branch-specific configuration To: header (rfc822)' ' + + git config branch.side.to "R. E. Cipient " && + git format-patch --stdout master..side >patch10 && + sed -e "/^\$/q" patch10 >hdrs10 && + grep "^To: \"R. E. Cipient\" \$" hdrs10 +' + +test_expect_failure 'branch-specific configuration To: header (rfc2047)' ' + + git config branch.side.to "R Ä Cipient " && + git format-patch --stdout master..side >patch10 && + sed -e "/^\$/q" patch10 >hdrs10 && + grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= \$" hdrs10 +' + +test_expect_success 'all recipients included from all sources' ' + + git config format.to "Format To1 " && + git config --add format.to "Format To2 " && + git config format.cc "Format Cc1 " && + git config --add format.cc "Format Cc2 " && + git config branch.side.to "Branch To1 " && + git config --add branch.side.to "Branch To2 " && + git config branch.side.cc "Branch Cc1 " && + git config --add branch.side.cc "Branch Cc2 " && + cat <<-\EOF >expect && + To: Format To1 , + Format To2 , + Command-line To1 , + Command-line To2 , + Branch To1 , + Branch To2 + Cc: Format Cc1 , + Format Cc2 , + Command-line Cc1 , + Command-line Cc2 , + Branch Cc1 , + Branch Cc2 + + EOF + git format-patch --stdout \ + --to="Command-line To1 " \ + --to="Command-line To2 " \ + --cc="Command-line Cc1 " \ + --cc="Command-line Cc2 " \ + master..side | sed -ne "/^To:/,/^$/p;/^$/q" >patch10 && + test_cmp expect patch10 +' + # check_patch : Verify that looks like a half-sane # patch email to avoid a false positive with !grep check_patch () { @@ -286,42 +345,51 @@ test_expect_success '--no-to overrides config.to' ' git config --replace-all format.to \ "R E Cipient " && - git format-patch --no-to --stdout master..side >patch10 && - sed -e "/^\$/q" patch10 >hdrs10 && - check_patch hdrs10 && - ! grep "^To: R E Cipient \$" hdrs10 + git config --replace-all branch.side.to \ + "B R Anch " && + git format-patch --no-to --stdout master..side >patch11 && + sed -e "/^\$/q" patch11 >hdrs11 && + check_patch hdrs11 && + ! grep "R E Cipient " hdrs11 && + ! grep "B R Anch " hdrs11 ' test_expect_success '--no-to and --to replaces config.to' ' git config --replace-all format.to \ "Someone " && + git config --replace-all branch.side.to \ + "B R Anch2 " && git format-patch --no-to --to="Someone Else " \ - --stdout master..side >patch11 && - sed -e "/^\$/q" patch11 >hdrs11 && - check_patch hdrs11 && - ! grep "^To: Someone \$" hdrs11 && - grep "^To: Someone Else \$" hdrs11 + --stdout master..side >patch12 && + sed -e "/^\$/q" patch12 >hdrs12 && + check_patch hdrs12 && + ! grep "Someone " hdrs12 && + ! grep "B R Anch2 " hdrs12 && + grep "^To: Someone Else \$" hdrs12 ' test_expect_success '--no-cc overrides config.cc' ' git config --replace-all format.cc \ "C E Cipient " && - git format-patch --no-cc --stdout master..side >patch12 && - sed -e "/^\$/q" patch12 >hdrs12 && - check_patch hdrs12 && - ! grep "^Cc: C E Cipient \$" hdrs12 + git config --replace-all branch.side.cc \ + "B R Anch3 " && + git format-patch --no-cc --stdout master..side >patch13 && + sed -e "/^\$/q" patch13 >hdrs13 && + check_patch hdrs13 && + ! grep "C E Cipient " hdrs13 && + ! grep "B R Anch3 " hdrs13 ' test_expect_success '--no-add-header overrides config.headers' ' git config --replace-all format.headers \ "Header1: B E Cipient " && - git format-patch --no-add-header --stdout master..side >patch13 && - sed -e "/^\$/q" patch13 >hdrs13 && - check_patch hdrs13 && - ! grep "^Header1: B E Cipient \$" hdrs13 + git format-patch --no-add-header --stdout master..side >patch14 && + sed -e "/^\$/q" patch14 >hdrs14 && + check_patch hdrs14 && + ! grep "^Header1: B E Cipient \$" hdrs14 ' test_expect_success 'multiple files' ' @@ -957,7 +1025,7 @@ test_expect_success 'format-patch wraps extremely long subject (ascii)' ' git add file && git commit -m "$M512" && git format-patch --stdout -1 >patch && - sed -n "/^Subject/p; /^ /p; /^$/q" subject && + sed -n "/^Subject/p; /^ /p; /^Header1:/q" subject && test_cmp expect subject ' @@ -996,7 +1064,7 @@ test_expect_success 'format-patch wraps extremely long subject (rfc2047)' ' git add file && git commit -m "$M512" && git format-patch --stdout -1 >patch && - sed -n "/^Subject/p; /^ /p; /^$/q" subject && + sed -n "/^Subject/p; /^ /p; /^Header1:/q" subject && test_cmp expect subject ' @@ -1005,7 +1073,7 @@ check_author() { git add file && GIT_AUTHOR_NAME=$1 git commit -m author-check && git format-patch --stdout -1 >patch && - sed -n "/^From: /p; /^ /p; /^$/q" actual && + sed -n "/^From: /p; /^ /p; /^Date:/q" actual && test_cmp expect actual }