diff --git a/lib/database.cc b/lib/database.cc index c7602906..9c0952a4 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -524,7 +524,7 @@ parse_references (void *ctx, GHashTable *hash, const char *refs) { - char *ref; + char *ref, *last_ref = NULL; if (refs == NULL || *refs == '\0') return NULL; @@ -532,20 +532,17 @@ parse_references (void *ctx, while (*refs) { ref = _parse_message_id (ctx, refs, &refs); - if (ref && strcmp (ref, message_id)) + if (ref && strcmp (ref, message_id)) { g_hash_table_insert (hash, ref, NULL); + last_ref = ref; + } } /* The return value of this function is used to add a parent * reference to the database. We should avoid making a message - * its own parent, thus the following check. + * its own parent, thus the above check. */ - - if (ref && strcmp(ref, message_id)) { - return ref; - } else { - return NULL; - } + return last_ref; } notmuch_status_t diff --git a/test/T510-thread-replies.sh b/test/T510-thread-replies.sh index d818b89f..1392fbed 100755 --- a/test/T510-thread-replies.sh +++ b/test/T510-thread-replies.sh @@ -138,7 +138,6 @@ expected=`echo "$expected" | notmuch_json_show_sanitize` test_expect_equal_json "$output" "$expected" test_begin_subtest "Ignore garbage at the end of References" -test_subtest_known_broken add_message '[id]="foo@five.com"' \ '[subject]="five"' add_message '[id]="bar@five.com"' \