1 Return-Path: <five9a2@gmail.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 170AB431FC9
\r
6 for <notmuch@notmuchmail.org>; Tue, 24 Nov 2009 17:35:18 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 Received: from olra.theworths.org ([127.0.0.1])
\r
9 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
10 with ESMTP id QNlxXLGaMvD4 for <notmuch@notmuchmail.org>;
\r
11 Tue, 24 Nov 2009 17:35:17 -0800 (PST)
\r
12 Received: from mail-bw0-f224.google.com (mail-bw0-f224.google.com
\r
14 by olra.theworths.org (Postfix) with ESMTP id 8E5F3431FBC
\r
15 for <notmuch@notmuchmail.org>; Tue, 24 Nov 2009 17:35:16 -0800 (PST)
\r
16 Received: by mail-bw0-f224.google.com with SMTP id 24so5514914bwz.30
\r
17 for <notmuch@notmuchmail.org>; Tue, 24 Nov 2009 17:35:16 -0800 (PST)
\r
18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
19 h=domainkey-signature:received:received:sender:from:to:cc:subject
\r
20 :date:message-id:x-mailer:in-reply-to:references;
\r
21 bh=4++x3HFF3KcDPZFjuT4QxhwyOx5q35MMbfUt16Z7yH4=;
\r
22 b=R/rL30kLrIK13ulDwxYZ8nujKqpCVp7ePmxZrzWBs/uQTxjnfpBpY7RNtRkxLSsxCf
\r
23 dIZoMeqH+K+rYwQnCPLYe2nTeHyKGEp3zlFK5uv7EsSwFj66i6WtsWSyrB0vPwQbpP6P
\r
24 X1RbOIiCWsnx8cCIXBJ1O2XHSAI0uWyHyJXNA=
\r
25 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
\r
26 h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to
\r
28 b=rTeWZQTtNo/9E2wDebkT8ASo3/LJfDsEacaqYSIUNF0xmy5m0sGAqbVqGW2wWVl/oU
\r
29 FwSdlupfcI8Hs6dxH6rFFopLxfFPd9MXGTfwhyFWXNtImyZM3tVJQ0pZh2GTP/R25B3D
\r
30 A4dtLiKGz7QHnSjkv7g3TWg/l/ZusF1RyyA2o=
\r
31 Received: by 10.204.150.68 with SMTP id x4mr6803275bkv.151.1259112916316;
\r
32 Tue, 24 Nov 2009 17:35:16 -0800 (PST)
\r
33 Received: from localhost.localdomain (vawpc43.ethz.ch [129.132.59.11])
\r
34 by mx.google.com with ESMTPS id 35sm7911394fkt.40.2009.11.24.17.35.14
\r
35 (version=TLSv1/SSLv3 cipher=RC4-MD5);
\r
36 Tue, 24 Nov 2009 17:35:15 -0800 (PST)
\r
37 Sender: Jed Brown <five9a2@gmail.com>
\r
38 From: Jed Brown <jed@59A2.org>
\r
39 To: notmuch@notmuchmail.org
\r
40 Date: Wed, 25 Nov 2009 02:35:14 +0100
\r
41 Message-Id: <1259112914-19806-3-git-send-email-jed@59A2.org>
\r
42 X-Mailer: git-send-email 1.6.5.3
\r
43 In-Reply-To: <1259112914-19806-2-git-send-email-jed@59A2.org>
\r
44 References: <1259112914-19806-1-git-send-email-jed@59A2.org>
\r
45 <1259112914-19806-2-git-send-email-jed@59A2.org>
\r
46 Subject: [notmuch] [PATCH 2/2] notmuch-reply.c: implement
\r
47 notmuch_reply_format_headers_only
\r
48 X-BeenThere: notmuch@notmuchmail.org
\r
49 X-Mailman-Version: 2.1.12
\r
51 List-Id: "Use and development of the notmuch mail system."
\r
52 <notmuch.notmuchmail.org>
\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
56 List-Post: <mailto:notmuch@notmuchmail.org>
\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
59 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
60 X-List-Received-Date: Wed, 25 Nov 2009 01:35:18 -0000
\r
62 This command only generates References, To, and Cc headers.
\r
63 The purpose is primarily for use in
\r
65 git send-email --notmuch id:<MESSAGE-ID>
\r
67 to get proper threading and address the relevant parties. Hooks for
\r
68 other SCMs may come later.
\r
70 Signed-off-by: Jed Brown <jed@59A2.org>
\r
72 notmuch-reply.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
\r
73 1 files changed, 70 insertions(+), 0 deletions(-)
\r
75 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
76 index 17eb38d..e85568c 100644
\r
77 --- a/notmuch-reply.c
\r
78 +++ b/notmuch-reply.c
\r
79 @@ -283,6 +283,74 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_
\r
83 +/* This format is currently tuned for a git send-email --notmuch hook */
\r
85 +notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query)
\r
87 + GMimeMessage *reply;
\r
88 + notmuch_messages_t *messages;
\r
89 + notmuch_message_t *message;
\r
90 + const char *recipients, *in_reply_to, *orig_references, *references;
\r
91 + char *reply_headers;
\r
94 + for (messages = notmuch_query_search_messages (query);
\r
95 + notmuch_messages_has_more (messages);
\r
96 + notmuch_messages_advance (messages))
\r
98 + message = notmuch_messages_get (messages);
\r
100 + /* The 0 means we do not want headers in a "pretty" order. */
\r
101 + reply = g_mime_message_new (0);
\r
102 + if (reply == NULL) {
\r
103 + fprintf (stderr, "Out of memory\n");
\r
107 + in_reply_to = talloc_asprintf (ctx, "<%s>",
\r
108 + notmuch_message_get_message_id (message));
\r
110 + orig_references = notmuch_message_get_header (message, "references");
\r
112 + /* We print References first because git format-patch treats it specially.
\r
113 + * Git uses the first entry of References to create In-Reply-To.
\r
115 + references = talloc_asprintf (ctx, "%s%s%s",
\r
117 + orig_references ? orig_references : "",
\r
118 + orig_references ? " " : "");
\r
119 + g_mime_object_set_header (GMIME_OBJECT (reply),
\r
120 + "References", references);
\r
122 + for (i = 0; i < ARRAY_SIZE (reply_to_map); i++) {
\r
123 + const char *addr;
\r
125 + recipients = notmuch_message_get_header (message,
\r
126 + reply_to_map[i].header);
\r
127 + if ((recipients == NULL || recipients[0] == '\0') && reply_to_map[i].fallback)
\r
128 + recipients = notmuch_message_get_header (message,
\r
129 + reply_to_map[i].fallback);
\r
131 + addr = add_recipients_for_string (reply, config,
\r
132 + reply_to_map[i].recipient_type,
\r
136 + g_mime_object_set_header (GMIME_OBJECT (reply), "Bcc",
\r
137 + notmuch_config_get_user_primary_email (config));
\r
139 + reply_headers = g_mime_object_to_string (GMIME_OBJECT (reply));
\r
140 + printf ("%s", reply_headers);
\r
141 + free (reply_headers);
\r
143 + g_object_unref (G_OBJECT (reply));
\r
146 + notmuch_message_destroy (message);
\r
152 notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
154 @@ -304,6 +372,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
155 opt = argv[i] + sizeof ("--format=") - 1;
\r
156 if (strcmp (opt, "default") == 0) {
\r
157 reply_format_func = notmuch_reply_format_default;
\r
158 + } else if (strcmp (opt, "headers-only") == 0) {
\r
159 + reply_format_func = notmuch_reply_format_headers_only;
\r
161 fprintf (stderr, "Invalid value for --format: %s\n", opt);
\r