mirror of
https://github.com/git/git.git
synced 2024-11-30 21:44:02 +08:00
6bf4f1b4c9
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>
51 lines
935 B
Bash
Executable File
51 lines
935 B
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='format-patch -s should force MIME encoding as needed'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success setup '
|
|
|
|
>F &&
|
|
git add F &&
|
|
git commit -m initial &&
|
|
echo new line >F &&
|
|
|
|
test_tick &&
|
|
git commit -m "This adds some lines to F" F
|
|
|
|
'
|
|
|
|
test_expect_success 'format normally' '
|
|
|
|
git format-patch --stdout -1 >output &&
|
|
! grep Content-Type output
|
|
|
|
'
|
|
|
|
test_expect_success 'format with signoff without funny signer name' '
|
|
|
|
git format-patch -s --stdout -1 >output &&
|
|
! grep Content-Type output
|
|
|
|
'
|
|
|
|
test_expect_success 'format with non ASCII signer name' '
|
|
|
|
GIT_COMMITTER_NAME="はまの ふにおう" \
|
|
git format-patch -s --stdout -1 >output &&
|
|
grep Content-Type output
|
|
|
|
'
|
|
|
|
test_expect_success 'attach and signoff do not duplicate mime headers' '
|
|
|
|
GIT_COMMITTER_NAME="はまの ふにおう" \
|
|
git format-patch -s --stdout -1 --attach >output &&
|
|
test `grep -ci ^MIME-Version: output` = 1
|
|
|
|
'
|
|
|
|
test_done
|
|
|