X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fdatabase.cc;h=6842fafadad86967b4363abd5869a2aeaef345c2;hp=415b0d77c3439abb9165d8236c5106d3f1cfffee;hb=14073b8851067db4dbf5727bf1f5547a66750934;hpb=328626d0fd17910eec5d8b5b51dda46f4bbd8189 diff --git a/lib/database.cc b/lib/database.cc index 415b0d77..6842fafa 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -1313,22 +1313,21 @@ _notmuch_database_link_message_to_parents (notmuch_database_t *notmuch, const char *parent_thread_id; parent_message_id = (char *) l->data; + + _notmuch_message_add_term (message, "reference", + parent_message_id); + parent_thread_id = _resolve_message_id_to_thread_id (notmuch, message, parent_message_id); - if (parent_thread_id == NULL) { - _notmuch_message_add_term (message, "reference", - parent_message_id); - } else { - if (*thread_id == NULL) { - *thread_id = talloc_strdup (message, parent_thread_id); - _notmuch_message_add_term (message, "thread", *thread_id); - } else if (strcmp (*thread_id, parent_thread_id)) { - ret = _merge_threads (notmuch, *thread_id, parent_thread_id); - if (ret) - goto DONE; - } + if (*thread_id == NULL) { + *thread_id = talloc_strdup (message, parent_thread_id); + _notmuch_message_add_term (message, "thread", *thread_id); + } else if (strcmp (*thread_id, parent_thread_id)) { + ret = _merge_threads (notmuch, *thread_id, parent_thread_id); + if (ret) + goto DONE; } }