From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH v2 3/3] format-patch: learn format.forceInBodyFrom configuration variable
Date: Mon, 29 Aug 2022 14:38:37 -0700 [thread overview]
Message-ID: <20220829213837.13849-4-gitster@pobox.com> (raw)
In-Reply-To: <20220829213837.13849-1-gitster@pobox.com>
As the need to use the "--force-in-body-from" option primarily is
tied to which mailing list the mails go to (and get their From:
address mangled), it is likely that a user who needs to use this
option once to interact with their upstream project needs to use it
for all patches they send out.
Add a configuration variable, suitable for setting in the local
configuration file per repository, for this.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Documentation/config/format.txt | 4 ++++
Documentation/git-format-patch.txt | 2 ++
builtin/log.c | 4 ++++
t/t4014-format-patch.sh | 24 ++++++++++++++++++++++++
4 files changed, 34 insertions(+)
diff --git a/Documentation/config/format.txt b/Documentation/config/format.txt
index fdbc06a4d2..c7303d8d9f 100644
--- a/Documentation/config/format.txt
+++ b/Documentation/config/format.txt
@@ -15,6 +15,10 @@ format.from::
different. If set to a non-boolean value, format-patch uses that
value instead of your committer identity. Defaults to false.
+format.forceInBodyFrom::
+ Provides the default value for the `--[no-]force-in-body-from`
+ option to format-patch. Defaults to false.
+
format.numbered::
A boolean which can enable or disable sequence numbers in patch
subjects. It defaults to "auto" which enables it only if there
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index 7c7f244e57..dfcc7da4c2 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -283,6 +283,8 @@ feeding the result to `git send-email`.
the in-body "From:" is added even when the sender and the
author have the same name and address, which may help if the
mailing list software mangles the sender's identity.
+ Defaults to the value of the `format.forceInBodyFrom`
+ configuration variable.
--add-header=<header>::
Add an arbitrary header to the email headers. This is in addition
diff --git a/builtin/log.c b/builtin/log.c
index 78ccd37bd9..776bc9afdb 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1007,6 +1007,10 @@ static int git_format_config(const char *var, const char *value, void *cb)
from = NULL;
return 0;
}
+ if (!strcmp(var, "format.forceinbodyfrom")) {
+ force_in_body_from = git_config_bool(var, value);
+ return 0;
+ }
if (!strcmp(var, "format.notes")) {
int b = git_parse_maybe_bool(value);
if (b < 0)
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 347f7f7f35..ad5c029279 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -1413,6 +1413,30 @@ test_expect_success 'with --force-in-body-from, redundant in-body from is kept'
test_cmp expect patch.head
'
+test_expect_success 'format.forceInBodyFrom, equivalent to --force-in-body-from' '
+ git -c format.forceInBodyFrom=yes format-patch \
+ -1 --stdout --from="A U Thor <author@example.com>" >patch &&
+ cat >expect <<-\EOF &&
+ From: A U Thor <author@example.com>
+
+ From: A U Thor <author@example.com>
+
+ EOF
+ sed -ne "/^From:/p; /^$/p; /^---$/q" patch >patch.head &&
+ test_cmp expect patch.head
+'
+
+test_expect_success 'format.forceInBodyFrom, equivalent to --force-in-body-from' '
+ git -c format.forceInBodyFrom=yes format-patch --no-force-in-body-from \
+ -1 --stdout --from="A U Thor <author@example.com>" >patch &&
+ cat >expect <<-\EOF &&
+ From: A U Thor <author@example.com>
+
+ EOF
+ sed -ne "/^From:/p; /^$/p; /^---$/q" patch >patch.head &&
+ test_cmp expect patch.head
+'
+
test_expect_success 'in-body headers trigger content encoding' '
test_env GIT_AUTHOR_NAME="éxötìc" test_commit exotic &&
test_when_finished "git reset --hard HEAD^" &&
--
2.37.2-621-gd3a800faf0
prev parent reply other threads:[~2022-08-29 21:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-26 21:32 [PATCH 0/2] format-patch --force-inbody-from Junio C Hamano
2022-08-26 21:32 ` [PATCH 1/2] pretty: separate out the logic to decide the use of in-body from Junio C Hamano
2022-08-29 11:32 ` Johannes Schindelin
2022-08-29 17:29 ` Junio C Hamano
2022-08-26 21:32 ` [PATCH 2/2] format-patch: allow forcing the use of in-body From: header Junio C Hamano
2022-08-29 11:48 ` Johannes Schindelin
2022-08-29 17:41 ` Junio C Hamano
2022-08-29 21:38 ` [PATCH v2 0/3] format-patch --force-in-body-from Junio C Hamano
2022-08-29 21:38 ` [PATCH v2 1/3] pretty: separate out the logic to decide the use of in-body from Junio C Hamano
2022-08-29 21:38 ` [PATCH v2 2/3] format-patch: allow forcing the use of in-body From: header Junio C Hamano
2022-08-30 20:07 ` Jeff King
2022-08-30 20:14 ` Jeff King
2022-08-29 21:38 ` Junio C Hamano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220829213837.13849-4-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).