Re: [PATCH 5/6] cli/new: support /<regex>/ in new.ignore

Subject: Re: [PATCH 5/6] cli/new: support /<regex>/ in new.ignore

Date: Mon, 25 Sep 2017 23:13:27 -0300

To: Jani Nikula, notmuch@notmuchmail.org

Cc:

From: David Bremner


Jani Nikula <jani@nikula.org> writes:

> +	  A regular expression delimited with // that will be matched
> +	  against the path of the file or directory relative to the
> +	  database path. The beginning and end of string must be
> +	  explictly anchored. For example, /.*/foo$/ would match
> +	  "bar/foo" and "bar/baz/foo", but not "foo" or "bar/foobar".

Is it worth remarking that '/' does not need to be escaped? or more
interestingly, what happens if it is escaped, do things break?
>  
> +static notmuch_bool_t
> +_setup_ignore (notmuch_config_t *config, add_files_state_t *state)
> +{

Would be nice to document what this return value means.

> +    const char **ignore_list, **ignore;
> +    int nregex = 0, nverbatim = 0;
> +    const char **verbatim = NULL;
> +    regex_t *regex = NULL;
> +
> +    ignore_list = notmuch_config_get_new_ignore (config, NULL);
> +    if (! ignore_list)
> +	return TRUE;
> +
> +    for (ignore = ignore_list; *ignore; ignore++) {
> +	const char *s = *ignore;
> +	size_t len = strlen (s);
> +
> +	if (len > 2 && s[0] == '/' && s[len - 1] == '/') {

One thing we eventually settled on in the query parser is that an
opening '/' without a trailing '/' is an errror. But perhaps it's fine
to take a more permissive approach here.

> +
> +    if (! state->ignore_regex_length)
> +	return FALSE;

It's a nitpick, even by the standards of this review, but I'd prefer an
explicit '> 0' check.

_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch

Thread: