[PATCH] Avoid empty thread names if possible.

Tomi Ollila tomi.ollila at iki.fi
Tue Oct 28 14:36:58 PDT 2014


On Tue, Oct 07 2014, Jesse Rosenthal wrote:

> Currently the thread is named based on either the oldest or newest
> matching message (depending on the search order). If this message has
> an empty subject, though, the thread will show up with an empty
> subject in the search results. (See the thread starting with
> `id:1412371140-21051-1-git-send-email-david at tethera.net` for an
> example.)
>
> This patch changes the behavior to name based on the oldest/newest
> matching non-empty subject. This is particularly helpful for patchsets.
> If the only subjects are empty, the thread subject will still be empty.
>
> Signed-off-by: Jesse Rosenthal <jrosenthal at jhu.edu>
> ---
>  lib/thread.cc | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/thread.cc b/lib/thread.cc
> index 8922403..ea10295 100644
> --- a/lib/thread.cc
> +++ b/lib/thread.cc
> @@ -348,18 +348,20 @@ _thread_add_matched_message (notmuch_thread_t *thread,
>  {
>      time_t date;
>      notmuch_message_t *hashed_message;
> +    const char *cur_subject;
>  
>      date = notmuch_message_get_date (message);
> +    cur_subject = notmuch_thread_get_subject (thread);
>  
>      if (date < thread->oldest || ! thread->matched_messages) {
>  	thread->oldest = date;
> -	if (sort == NOTMUCH_SORT_OLDEST_FIRST)
> +	if (sort == NOTMUCH_SORT_OLDEST_FIRST || strlen(cur_subject) == 0)

IMO it is a bit silly to scan through the whole string and use the return
value of 0 (vs != 0) to have effect. we should probably have something like
#define EMPTY_STRING(s) ((s)[0] == '\0') 
and use that instead.

Also, to keep promise, mentioning 'patch' in commit message referring to 
the change introduced does IMO also look silly :D

Tomi

>  	    _thread_set_subject_from_message (thread, message);
>      }
>  
>      if (date > thread->newest || ! thread->matched_messages) {
>  	thread->newest = date;
> -	if (sort != NOTMUCH_SORT_OLDEST_FIRST)
> +	if (sort != NOTMUCH_SORT_OLDEST_FIRST || strlen(cur_subject) == 0)
>  	    _thread_set_subject_from_message (thread, message);
>      }
>  
> -- 
> 2.1.2
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


More information about the notmuch mailing list