From: Dirk Hohndel Date: Tue, 6 Apr 2010 19:45:30 +0000 (-0700) Subject: fix notmuch_message_file_get_header X-Git-Tag: 0.2~104 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=a48f3687785b2c138b2c47848bd05512fc893a0b fix notmuch_message_file_get_header fix notmuch_message_file_get_header to always return the first instance of the header you are looking for Signed-off-by: Dirk Hohndel --- diff --git a/lib/message-file.c b/lib/message-file.c index 3a1a681d..0c152a39 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; }