diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2015-08-15 19:46:38 +0300 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-08-15 19:46:38 +0300 |
commit | e451cd5c0350aa70e05df44bbf5cbdc0e6504f46 (patch) | |
tree | 4b33b940c850db82d4ee6c6c5251150662a55d15 /src | |
parent | 755004eaed008779bed9e5efb8b539917dbf431b (diff) |
diff: don't error out on an invalid regex
When parsing user-provided regex patterns for functions, we must not
fail to provide a diff just because a pattern is not well
formed. Ignore it instead.
Diffstat (limited to 'src')
-rw-r--r-- | src/diff_driver.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/diff_driver.c b/src/diff_driver.c index 9d1337103..bc3518991 100644 --- a/src/diff_driver.c +++ b/src/diff_driver.c @@ -97,8 +97,7 @@ static int diff_driver_add_patterns( for (scan = regex_str; scan; scan = end) { /* get pattern to fill in */ if ((pat = git_array_alloc(drv->fn_patterns)) == NULL) { - error = -1; - break; + return -1; } pat->flags = regex_flags; @@ -117,10 +116,9 @@ static int diff_driver_add_patterns( break; if ((error = regcomp(&pat->re, buf.ptr, regex_flags)) != 0) { - /* if regex fails to compile, warn? fail? */ - error = giterr_set_regex(&pat->re, error); - regfree(&pat->re); - break; + /* + * TODO: issue a warning + */ } } @@ -128,7 +126,8 @@ static int diff_driver_add_patterns( (void)git_array_pop(drv->fn_patterns); /* release last item */ git_buf_free(&buf); - return error; + /* We want to ignore bad patterns, so return success regardless */ + return 0; } static int diff_driver_xfuncname(const git_config_entry *entry, void *payload) |