Skip to content

Commit d5fc07d

Browse files
committed
format-patch: learn format.forceInBodyFrom configuration variable
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 <[email protected]>
1 parent 34bc1b1 commit d5fc07d

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

Documentation/config/format.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ format.from::
1515
different. If set to a non-boolean value, format-patch uses that
1616
value instead of your committer identity. Defaults to false.
1717

18+
format.forceInBodyFrom::
19+
Provides the default value for the `--[no-]force-in-body-from`
20+
option to format-patch. Defaults to false.
21+
1822
format.numbered::
1923
A boolean which can enable or disable sequence numbers in patch
2024
subjects. It defaults to "auto" which enables it only if there

Documentation/git-format-patch.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ feeding the result to `git send-email`.
283283
the in-body "From:" is added even when the sender and the
284284
author have the same name and address, which may help if the
285285
mailing list software mangles the sender's identity.
286+
Defaults to the value of the `format.forceInBodyFrom`
287+
configuration variable.
286288

287289
--add-header=<header>::
288290
Add an arbitrary header to the email headers. This is in addition

builtin/log.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,10 @@ static int git_format_config(const char *var, const char *value, void *cb)
10071007
from = NULL;
10081008
return 0;
10091009
}
1010+
if (!strcmp(var, "format.forceinbodyfrom")) {
1011+
force_in_body_from = git_config_bool(var, value);
1012+
return 0;
1013+
}
10101014
if (!strcmp(var, "format.notes")) {
10111015
int b = git_parse_maybe_bool(value);
10121016
if (b < 0)

t/t4014-format-patch.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,30 @@ test_expect_success 'with --force-in-body-from, redundant in-body from is kept'
14131413
test_cmp expect patch.head
14141414
'
14151415

1416+
test_expect_success 'format.forceInBodyFrom, equivalent to --force-in-body-from' '
1417+
git -c format.forceInBodyFrom=yes format-patch \
1418+
-1 --stdout --from="A U Thor <[email protected]>" >patch &&
1419+
cat >expect <<-\EOF &&
1420+
From: A U Thor <[email protected]>
1421+
1422+
From: A U Thor <[email protected]>
1423+
1424+
EOF
1425+
sed -ne "/^From:/p; /^$/p; /^---$/q" patch >patch.head &&
1426+
test_cmp expect patch.head
1427+
'
1428+
1429+
test_expect_success 'format.forceInBodyFrom, equivalent to --force-in-body-from' '
1430+
git -c format.forceInBodyFrom=yes format-patch --no-force-in-body-from \
1431+
-1 --stdout --from="A U Thor <[email protected]>" >patch &&
1432+
cat >expect <<-\EOF &&
1433+
From: A U Thor <[email protected]>
1434+
1435+
EOF
1436+
sed -ne "/^From:/p; /^$/p; /^---$/q" patch >patch.head &&
1437+
test_cmp expect patch.head
1438+
'
1439+
14161440
test_expect_success 'in-body headers trigger content encoding' '
14171441
test_env GIT_AUTHOR_NAME="éxötìc" test_commit exotic &&
14181442
test_when_finished "git reset --hard HEAD^" &&

0 commit comments

Comments
 (0)