-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
format-patch: generate MIME header as needed even when there is forma…
…t.header Earlier, the callchain from pretty_print_commit() down to pp_title_line() had an unwarranted assumption that the presense of "after_subject" parameter, means the caller has already output MIME headers for attachments. The parameter's primary purpose is to give extra header lines the caller wants to place after pp_title_line() generates the "Subject: " line. This assumption does not hold when the user used the format.header configuration variable to pass extra headers, and caused a message with non-ASCII character to lack proper MIME headers (e.g. 8-bit CTE header). The earlier logic also failed to suppress duplicated MIME headers when "format-patch -s --attach" is asked for and the signer's name demanded 8-bit clean transport. This patch fixes the logic by introducing a separate need_8bit_cte parameter passed down the callchain. This can have one of these values: -1 : we've already done MIME crap and we do not want to add extra header to say this is 8bit in pp_title_line(); 0 : we haven't done MIME and we have not seen anything that is 8bit yet; 1 : we haven't done MIME and we have seen something that is 8bit; pp_title_line() must add MIME header. It adds two tests by Jeff King who independently diagnosed this issue. Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
Junio C Hamano
committed
Mar 15, 2008
1 parent
a0b54e7
commit 6bf4f1b
Showing
5 changed files
with
57 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
|
||
test_description='format-patch mime headers and extra headers do not conflict' | ||
. ./test-lib.sh | ||
|
||
test_expect_success 'create commit with utf-8 body' ' | ||
echo content >file && | ||
git add file && | ||
git commit -m one && | ||
echo more >>file && | ||
git commit -a -m "two | ||
utf-8 body: ñ" | ||
' | ||
|
||
test_expect_success 'patch has mime headers' ' | ||
rm -f 0001-two.patch && | ||
git format-patch HEAD^ && | ||
grep -i "content-type: text/plain; charset=utf-8" 0001-two.patch | ||
' | ||
|
||
test_expect_success 'patch has mime and extra headers' ' | ||
rm -f 0001-two.patch && | ||
git config format.headers "x-foo: bar" && | ||
git format-patch HEAD^ && | ||
grep -i "x-foo: bar" 0001-two.patch && | ||
grep -i "content-type: text/plain; charset=utf-8" 0001-two.patch | ||
' | ||
|
||
test_done |