summaryrefslogtreecommitdiff
path: root/t/t4014-format-patch.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2013-09-20 10:16:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-09-20 18:09:51 (GMT)
commit662cc30cd048f2ccd7ba8d1540e0768ae264c0dd (patch)
treed05ea629e93ae982f0bb6941e5c052a8b4f9f348 /t/t4014-format-patch.sh
parenta90804752f6ab2b911882d47fafb6c2b78f447c3 (diff)
downloadgit-662cc30cd048f2ccd7ba8d1540e0768ae264c0dd.zip
git-662cc30cd048f2ccd7ba8d1540e0768ae264c0dd.tar.gz
git-662cc30cd048f2ccd7ba8d1540e0768ae264c0dd.tar.bz2
format-patch: print in-body "From" only when needed
Commit a908047 taught format-patch the "--from" option, which places the author ident into an in-body from header, and uses the committer ident in the rfc822 from header. The documentation claims that it will omit the in-body header when it is the same as the rfc822 header, but the code never implemented that behavior. This patch completes the feature by comparing the two idents and doing nothing when they are the same (this is the same as simply omitting the in-body header, as the two are by definition indistinguishable in this case). This makes it reasonable to turn on "--from" all the time (if it matches your particular workflow), rather than only using it when exporting other people's patches. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4014-format-patch.sh')
-rwxr-xr-xt/t4014-format-patch.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 668933b..8f272bc 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -1000,6 +1000,16 @@ test_expect_success '--from uses committer ident' '
test_cmp expect patch.head
'
+test_expect_success '--from omits redundant in-body header' '
+ git format-patch -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' '
GIT_AUTHOR_NAME="éxötìc" test_commit exotic &&
test_when_finished "git reset --hard HEAD^" &&