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

David Bremner david at tethera.net
Mon Sep 25 19:13:27 PDT 2017


Jani Nikula <jani at 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.



More information about the notmuch mailing list