summaryrefslogtreecommitdiff
path: root/mailinfo.c
diff options
context:
space:
mode:
authorĐoàn Trần Công Danh <congdanhqx@gmail.com>2021-05-09 17:12:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-05-10 06:06:22 (GMT)
commitf1aa29944320e51441e5b5e32591e69f2fa74de2 (patch)
treee91b0c0cc616a2f3d3c82f8595d2c2bf05b2f536 /mailinfo.c
parent0b689562cafc05b1a36bdea3d025c9ecdf2514bd (diff)
downloadgit-f1aa29944320e51441e5b5e32591e69f2fa74de2.zip
git-f1aa29944320e51441e5b5e32591e69f2fa74de2.tar.gz
git-f1aa29944320e51441e5b5e32591e69f2fa74de2.tar.bz2
mailinfo: allow squelching quoted CRLF warning
In previous change, Git starts to warn for quoted CRLF in decoded base64/QP email. Despite those warnings are usually helpful, quoted CRLF could be part of some users' workflow. Let's give them an option to turn off the warning completely. Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'mailinfo.c')
-rw-r--r--mailinfo.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/mailinfo.c b/mailinfo.c
index c8caee4..a784552 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -1040,7 +1040,8 @@ static void handle_filter_flowed(struct mailinfo *mi, struct strbuf *line,
static void summarize_quoted_cr(struct mailinfo *mi)
{
- if (mi->have_quoted_cr)
+ if (mi->have_quoted_cr &&
+ mi->quoted_cr == quoted_cr_warn)
warning(_("quoted CRLF detected"));
}
@@ -1220,6 +1221,17 @@ int mailinfo(struct mailinfo *mi, const char *msg, const char *patch)
return mi->input_error;
}
+int mailinfo_parse_quoted_cr_action(const char *actionstr, int *action)
+{
+ if (!strcmp(actionstr, "nowarn"))
+ *action = quoted_cr_nowarn;
+ else if (!strcmp(actionstr, "warn"))
+ *action = quoted_cr_warn;
+ else
+ return -1;
+ return 0;
+}
+
static int git_mailinfo_config(const char *var, const char *value, void *mi_)
{
struct mailinfo *mi = mi_;
@@ -1230,6 +1242,11 @@ static int git_mailinfo_config(const char *var, const char *value, void *mi_)
mi->use_scissors = git_config_bool(var, value);
return 0;
}
+ if (!strcmp(var, "mailinfo.quotedcr")) {
+ if (mailinfo_parse_quoted_cr_action(value, &mi->quoted_cr) != 0)
+ return error(_("bad action '%s' for '%s'"), value, var);
+ return 0;
+ }
/* perhaps others here */
return 0;
}
@@ -1242,6 +1259,7 @@ void setup_mailinfo(struct mailinfo *mi)
strbuf_init(&mi->charset, 0);
strbuf_init(&mi->log_message, 0);
strbuf_init(&mi->inbody_header_accum, 0);
+ mi->quoted_cr = quoted_cr_warn;
mi->header_stage = 1;
mi->use_inbody_headers = 1;
mi->content_top = mi->content;