Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id AEC474196F4 for ; Tue, 6 Apr 2010 12:45:32 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.5 X-Spam-Level: X-Spam-Status: No, score=-1.5 tagged_above=-999 required=5 tests=[BAYES_50=0.8, RCVD_IN_DNSWL_MED=-2.3] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1Sf0kARRGCAB for ; Tue, 6 Apr 2010 12:45:31 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) by olra.theworths.org (Postfix) with ESMTP id A1C0C4196F0 for ; Tue, 6 Apr 2010 12:45:31 -0700 (PDT) Received: from localhost ([::1] helo=localhost.localdomain) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NzEiI-0003UJ-Ui for notmuch@notmuchmail.org; Tue, 06 Apr 2010 19:45:31 +0000 Received: by localhost.localdomain (Postfix, from userid 500) id 6419AC007F; Tue, 6 Apr 2010 12:45:30 -0700 (PDT) From: Dirk Hohndel To: notmuch Subject: [PATCH 1/2] fix notmuch_message_file_get_header Date: Tue, 06 Apr 2010 12:45:30 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2010 19:45:32 -0000 fix notmuch_message_file_get_header to always return the first instance of the header you are looking for Signed-off-by: Dirk Hohndel --- lib/message-file.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/message-file.c b/lib/message-file.c index 3a1a681..0c152a3 100644 --- a/lib/message-file.c +++ b/lib/message-file.c @@ -318,9 +318,15 @@ notmuch_message_file_get_header (notmuch_message_file_t *message, match = (strcasecmp (header, header_desired) == 0); decoded_value = g_mime_utils_header_decode_text (message->value.str); - - g_hash_table_insert (message->headers, header, decoded_value); - + if (g_hash_table_lookup (message->headers, header) == NULL) { + /* Only insert if we don't have a value for this header, yet. + * This way we always return the FIRST instance of any header + * we search for + * FIXME: we should be returning ALL instances of a header + * or at least provide a way to iterate over them + */ + g_hash_table_insert (message->headers, header, decoded_value); + } if (match) return decoded_value; } -- 1.6.6.1 -- Dirk Hohndel Intel Open Source Technology Center