This is v3 of id:1376587658-19202-1-git-send-email-amdragon at mit.edu.
This addresses Jani's comment in id:87k3jl3ehe.fsf at nikula.org by
treating errors while retrieving the original message's References
header as if the original message didn't have a References header.  It
also adds a comment suggested by Jani on IRC.  The diff from v2 is
below.

diff --git a/notmuch-reply.c b/notmuch-reply.c
index bfd0f51..ac46d02 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -31,6 +31,7 @@ show_reply_headers (GMimeMessage *message)
     stream_stdout = g_mime_stream_file_new (stdout);
     if (stream_stdout) {
        g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE);
+       /* Output RFC 2822 formatted (and RFC 2047 encoded) headers. */
        g_mime_object_write_to_stream (GMIME_OBJECT(message), stream_stdout);
        g_object_unref(stream_stdout);
     }
@@ -526,14 +527,15 @@ create_reply_message(void *ctx,
                              "In-Reply-To", in_reply_to);

     orig_references = notmuch_message_get_header (message, "references");
-    if (orig_references) {
-       references = talloc_asprintf (ctx, "%s%s%s",
-                                     *orig_references ? orig_references : "",
-                                     *orig_references ? " " : "",
-                                     in_reply_to);
-       g_mime_object_set_header (GMIME_OBJECT (reply),
-                                 "References", references);
-    }
+    if (!orig_references)
+       /* Treat errors like missing References headers. */
+       orig_references = "";
+    references = talloc_asprintf (ctx, "%s%s%s",
+                                 *orig_references ? orig_references : "",
+                                 *orig_references ? " " : "",
+                                 in_reply_to);
+    g_mime_object_set_header (GMIME_OBJECT (reply),
+                             "References", references);

     return reply;
 }


Reply via email to