Skip to content

Commit fd1062e

Browse files
torvaldsgitster
authored andcommitted
mailinfo: fix in-body header continuations
An empty line should stop any pending in-body headers, and start the actual body parsing. This also modifies the original test for the in-body headers to actually have a real commit body that starts with spaces, and changes the test to check that the long line matches _exactly_, and doesn't get extra data from the body. Fixes:6b4b013f1884 ("mailinfo: handle in-body header continuations") Cc: Jonathan Tan <[email protected]> Cc: Jeff King <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4cff50b commit fd1062e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

mailinfo.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,13 @@ static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
674674
assert(!mi->filter_stage);
675675

676676
if (mi->header_stage) {
677-
if (!line->len || (line->len == 1 && line->buf[0] == '\n'))
677+
if (!line->len || (line->len == 1 && line->buf[0] == '\n')) {
678+
if (mi->inbody_header_accum.len) {
679+
flush_inbody_header_accum(mi);
680+
mi->header_stage = 0;
681+
}
678682
return 0;
683+
}
679684
}
680685

681686
if (mi->use_inbody_headers && mi->header_stage) {

t/t4150-am.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,9 @@ test_expect_success 'am works with multi-line in-body headers' '
983983
rm -fr .git/rebase-apply &&
984984
git checkout -f first &&
985985
echo one >> file &&
986-
git commit -am "$LONG" --author="$LONG <[email protected]>" &&
986+
git commit -am "$LONG
987+
988+
Body test" --author="$LONG <[email protected]>" &&
987989
git format-patch --stdout -1 >patch &&
988990
# bump from, date, and subject down to in-body header
989991
perl -lpe "
@@ -997,7 +999,7 @@ test_expect_success 'am works with multi-line in-body headers' '
997999
git am msg &&
9981000
# Ensure that the author and full message are present
9991001
git cat-file commit HEAD | grep "^author.*[email protected]" &&
1000-
git cat-file commit HEAD | grep "^$LONG"
1002+
git cat-file commit HEAD | grep "^$LONG$"
10011003
'
10021004

10031005
test_done

0 commit comments

Comments
 (0)