diff options
| author | Patrick Steinhardt <ps@pks.im> | 2019-07-18 11:57:55 +0200 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2019-07-18 12:02:54 +0200 |
| commit | 6f6340afeca17bf0773e2450efc7c96f7ca8bd5d (patch) | |
| tree | 139b0d4ea20c94602427b772ddc564d3e21fb617 /tests/diff/diff_helpers.h | |
| parent | 368b9795ae3b3bd6fe659110a6595e9430b2d48d (diff) | |
| download | libgit2-6f6340afeca17bf0773e2450efc7c96f7ca8bd5d.tar.gz | |
ignore: fix determining whether a shorter pattern negates another
When computing whether we need to store a negative pattern, we iterate
through all previously known patterns and check whether the negative
pattern undoes any of the previous ones. In doing so we call `wildmatch`
and check it's return for any negative error values. If there was a
negative return, we will abort and bubble up that error to the caller.
In fact, this check for negative values stems from the time where we
still used `fnmatch` instead of `wildmatch`. For `fnmatch`, negative
values indicate a "real" error, while for `wildmatch` a negative value
may be returned if the matching was prematurely aborted. A premature
abort may for example also happen if the pattern matches a prefix of the
haystack if the pattern is shorter. Returning an error in that case is
the wrong thing to do.
Fix the code to compare for equality with `WM_MATCH`, only. Negative
values returned by `wildmatch` are perfectly fine and thus should be
ignored. Add a test that verifies we do not see the error.
Diffstat (limited to 'tests/diff/diff_helpers.h')
0 files changed, 0 insertions, 0 deletions
