Skip to content

Commit e83d57e

Browse files
committed
Merge branch 'ew/format-patch-mboxrd'
"git format-patch" learned to honor format.mboxrd even when sending patches to the standard output stream, * ew/format-patch-mboxrd: format-patch: support format.mboxrd with --stdout
2 parents 0903d8b + 4810946 commit e83d57e

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

Documentation/config/format.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,7 @@ For example,
139139
------------
140140
+
141141
will only show notes from `refs/notes/bar`.
142+
143+
format.mboxrd::
144+
A boolean value which enables the robust "mboxrd" format when
145+
`--stdout` is in use to escape "^>+From " lines.

builtin/log.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static int decoration_style;
5252
static int decoration_given;
5353
static int use_mailmap_config = 1;
5454
static unsigned int force_in_body_from;
55+
static int stdout_mboxrd;
5556
static const char *fmt_patch_subject_prefix = "PATCH";
5657
static int fmt_patch_name_max = FORMAT_PATCH_NAME_MAX_DEFAULT;
5758
static const char *fmt_pretty;
@@ -1077,6 +1078,10 @@ static int git_format_config(const char *var, const char *value, void *cb)
10771078
cover_from_description_mode = parse_cover_from_description(value);
10781079
return 0;
10791080
}
1081+
if (!strcmp(var, "format.mboxrd")) {
1082+
stdout_mboxrd = git_config_bool(var, value);
1083+
return 0;
1084+
}
10801085

10811086
return git_log_config(var, value, cb);
10821087
}
@@ -2105,6 +2110,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
21052110
rev.diffopt.close_file, "--output",
21062111
!!output_directory, "--output-directory");
21072112

2113+
if (use_stdout && stdout_mboxrd)
2114+
rev.commit_format = CMIT_FMT_MBOXRD;
2115+
21082116
if (use_stdout) {
21092117
setup_pager();
21102118
} else if (!rev.diffopt.close_file) {

t/t4014-format-patch.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,7 +2281,7 @@ test_expect_success 'format-patch --attach cover-letter only is non-multipart' '
22812281
test_line_count = 1 output
22822282
'
22832283

2284-
test_expect_success 'format-patch --pretty=mboxrd' '
2284+
test_expect_success '-c format.mboxrd format-patch' '
22852285
sp=" " &&
22862286
cat >msg <<-INPUT_END &&
22872287
mboxrd should escape the body
@@ -2316,7 +2316,9 @@ test_expect_success 'format-patch --pretty=mboxrd' '
23162316
INPUT_END
23172317
23182318
C=$(git commit-tree HEAD^^{tree} -p HEAD <msg) &&
2319-
git format-patch --pretty=mboxrd --stdout -1 $C~1..$C >patch &&
2319+
git -c format.mboxrd format-patch --stdout -1 $C~1..$C >patch &&
2320+
git format-patch --pretty=mboxrd --stdout -1 $C~1..$C >compat &&
2321+
test_cmp patch compat &&
23202322
git grep -h --no-index -A11 \
23212323
"^>From could trip up a loose mbox parser" patch >actual &&
23222324
test_cmp expect actual

t/t4150-am.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ test_expect_success 'am --patch-format=mboxrd handles mboxrd' '
10331033
>From extra escape for reversibility
10341034
INPUT_END
10351035
git commit -F msg &&
1036-
git format-patch --pretty=mboxrd --stdout -1 >mboxrd1 &&
1036+
git -c format.mboxrd format-patch --stdout -1 >mboxrd1 &&
10371037
grep "^>From could trip up a loose mbox parser" mboxrd1 &&
10381038
git checkout -f first &&
10391039
git am --patch-format=mboxrd mboxrd1 &&

0 commit comments

Comments
 (0)