diff options
-rw-r--r-- | Documentation/git-mailinfo.txt | 1 | ||||
-rw-r--r-- | mailinfo.c | 7 | ||||
-rw-r--r-- | mailinfo.h | 1 | ||||
-rwxr-xr-x | t/t5100-mailinfo.sh | 6 |
4 files changed, 15 insertions, 0 deletions
diff --git a/Documentation/git-mailinfo.txt b/Documentation/git-mailinfo.txt index 824947a070..3fcfd965fd 100644 --- a/Documentation/git-mailinfo.txt +++ b/Documentation/git-mailinfo.txt @@ -102,6 +102,7 @@ The valid actions are: * `nowarn`: Git will do nothing when such a CRLF is found. * `warn`: Git will issue a warning for each message if such a CRLF is found. +* `strip`: Git will convert those CRLF to LF. -- + The default action could be set by configuration option `mailinfo.quotedCR`. diff --git a/mailinfo.c b/mailinfo.c index a784552c7b..ed863c3a95 100644 --- a/mailinfo.c +++ b/mailinfo.c @@ -998,6 +998,11 @@ static void handle_filter_flowed(struct mailinfo *mi, struct strbuf *line, line->buf[len - 2] == '\r' && line->buf[len - 1] == '\n') { mi->have_quoted_cr = 1; + if (mi->quoted_cr == quoted_cr_strip) { + strbuf_setlen(line, len - 2); + strbuf_addch(line, '\n'); + len--; + } } handle_filter(mi, line); return; @@ -1227,6 +1232,8 @@ int mailinfo_parse_quoted_cr_action(const char *actionstr, int *action) *action = quoted_cr_nowarn; else if (!strcmp(actionstr, "warn")) *action = quoted_cr_warn; + else if (!strcmp(actionstr, "strip")) + *action = quoted_cr_strip; else return -1; return 0; diff --git a/mailinfo.h b/mailinfo.h index 768d06ac2a..2ddf8be90f 100644 --- a/mailinfo.h +++ b/mailinfo.h @@ -8,6 +8,7 @@ enum quoted_cr_action { quoted_cr_nowarn, quoted_cr_warn, + quoted_cr_strip, }; struct mailinfo { diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh index 1ecefa381d..141b29f031 100755 --- a/t/t5100-mailinfo.sh +++ b/t/t5100-mailinfo.sh @@ -259,6 +259,12 @@ test_expect_success 'mailinfo warn CR in base64 encoded email' ' check_quoted_cr_mail quoted-cr/0001 --quoted-cr=nowarn && test_must_be_empty quoted-cr/0001.err && check_quoted_cr_mail quoted-cr/0002 --quoted-cr=nowarn && + test_must_be_empty quoted-cr/0002.err && + cp quoted-cr/0001-expected.msg quoted-cr/0002-expected.msg && + cp quoted-cr/0001-expected.patch quoted-cr/0002-expected.patch && + check_quoted_cr_mail quoted-cr/0001 --quoted-cr=strip && + test_must_be_empty quoted-cr/0001.err && + check_quoted_cr_mail quoted-cr/0002 --quoted-cr=strip && test_must_be_empty quoted-cr/0002.err ' |