[PATCH v4 2/4] cli: make --entire-thread=false work for format=json.

Peter Wang novalazy at gmail.com
Fri May 25 19:15:56 PDT 2012


On Tue, 24 Apr 2012 10:11:13 +0100, Mark Walters <markwalters1009 at gmail.com> wrote:
> The --entire-thread option in notmuch-show.c defaults to true when
> format=json. Previously there was no way to turn this off. This patch
> makes it respect --entire-thread=false.
> 
> The one subtlety is that we initialise a notmuch_bool_t to -1 to
> indicate that the option parsing has not set it. This allows the code
> to distinguish between the option being omitted from the command line,
> and the option being set to false on the command line.
> ---
>  notmuch-show.c |   16 ++++++++++++++--
>  1 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/notmuch-show.c b/notmuch-show.c
> index 0d21f1a..48551bb 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -996,7 +996,13 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
>      char *query_string;
>      int opt_index, ret;
>      const notmuch_show_format_t *format = &format_text;
> -    notmuch_show_params_t params = { .part = -1, .omit_excluded = TRUE };
> +
> +    /* We abuse the notmuch_bool_t variable params.entire-thread by
> +     * setting it to -1 to denote that the command line parsing has
> +     * not set it. We ensure it is set to TRUE or FALSE before passing
> +     * it to any other function.*/
> +    notmuch_show_params_t params = { .part = -1, .entire_thread = -1 };
> +
>      int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
>      notmuch_bool_t verify = FALSE;
>      int exclude = EXCLUDE_TRUE;

Hi Mark,

As an alternative to the abuse, could you just treat it as with exclude,
using an enum with three values (TRUE|FALSE|DEFAULT)?
Then set params.entire_thread afterwards.

Peter


More information about the notmuch mailing list