Merge branch 'bc/master-diff-hunk-header-fix'
* bc/master-diff-hunk-header-fix: Clarify commit error message for unmerged files Use strchrnul() instead of strchr() plus manual workaround Use remove_path from dir.c instead of own implementation Add remove_path: a function to remove as much as possible of a path git-submodule: Fix "Unable to checkout" for the initial 'update' Clarify how the user can satisfy stash's 'dirty state' check. t4018-diff-funcname: test syntax of builtin xfuncname patterns t4018-diff-funcname: test syntax of builtin xfuncname patterns make "git remote" report multiple URLs diff hunk pattern: fix misconverted "\{" tex macro introducers diff: fix "multiple regexp" semantics to find hunk header comment diff: use extended regexp to find hunk headers diff: use extended regexp to find hunk headers diff.*.xfuncname which uses "extended" regex's for hunk header selection diff.c: associate a flag with each pattern and use it for compiling regex diff.c: return pattern entry pointer rather than just the hunk header pattern Conflicts: builtin-merge-recursive.c t/t7201-co.sh xdiff-interface.h
This commit is contained in:
@ -194,31 +194,34 @@ static long ff_regexp(const char *line, long len,
|
||||
char *line_buffer = xstrndup(line, len); /* make NUL terminated */
|
||||
struct ff_regs *regs = priv;
|
||||
regmatch_t pmatch[2];
|
||||
int result = 0, i;
|
||||
int i;
|
||||
int result = -1;
|
||||
|
||||
for (i = 0; i < regs->nr; i++) {
|
||||
struct ff_reg *reg = regs->array + i;
|
||||
if (reg->negate ^ !!regexec(®->re,
|
||||
line_buffer, 2, pmatch, 0)) {
|
||||
free(line_buffer);
|
||||
return -1;
|
||||
if (!regexec(®->re, line_buffer, 2, pmatch, 0)) {
|
||||
if (reg->negate)
|
||||
goto fail;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (regs->nr <= i)
|
||||
goto fail;
|
||||
i = pmatch[1].rm_so >= 0 ? 1 : 0;
|
||||
line += pmatch[i].rm_so;
|
||||
result = pmatch[i].rm_eo - pmatch[i].rm_so;
|
||||
if (result > buffer_size)
|
||||
result = buffer_size;
|
||||
else
|
||||
while (result > 0 && (isspace(line[result - 1]) ||
|
||||
line[result - 1] == '\n'))
|
||||
while (result > 0 && (isspace(line[result - 1])))
|
||||
result--;
|
||||
memcpy(buffer, line, result);
|
||||
fail:
|
||||
free(line_buffer);
|
||||
return result;
|
||||
}
|
||||
|
||||
void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value)
|
||||
void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)
|
||||
{
|
||||
int i;
|
||||
struct ff_regs *regs;
|
||||
@ -243,7 +246,7 @@ void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value)
|
||||
expression = buffer = xstrndup(value, ep - value);
|
||||
else
|
||||
expression = value;
|
||||
if (regcomp(®->re, expression, 0))
|
||||
if (regcomp(®->re, expression, cflags))
|
||||
die("Invalid regexp to look for hunk header: %s", expression);
|
||||
free(buffer);
|
||||
value = ep + 1;
|
||||
|
Reference in New Issue
Block a user