]> git.ipfire.org Git - thirdparty/git.git/blobdiff - mailinfo.c
mailinfo: allow squelching quoted CRLF warning
[thirdparty/git.git] / mailinfo.c
index c8caee4f55b1bab1e1d8fac63c0e448be8db8d0a..a784552c7b2636324083a5f1313d82005c658c6a 100644 (file)
@@ -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;