One function

fnmatch_pathname_to_regex in mherrmann/gitignore_parser

The author described this change as Fix lack of implicit anchoring of patterns to directory separators. It counts as a record because the check below fails on the code as it stood at 8ea444424 and passes on cdf80b7b1, with nothing else changed between the two runs.

Fix saved2023-10-04
Sharing licenceMIT · LICENSE
Change size+3 1

What the code was meant to do, written into the code itself as a docstring

Implements fnmatch style-behavior, as though with FNM_PATHNAME flagged; the path separator will not match shell-style '*' and '.' wildcards.

The change

5555 res.append(re.escape(c))
5656 if anchored:
5757 res.insert(0, '^')
58+ else:
59+ res.insert(0, f"(^|{seps_group})")
5860 if not directory_only:
5961 res.append('$')
6062 elif directory_only and negation:
6163 res.append('/$')
6264 else:
63- res.append('($|\/)')
65+ res.append('($|\\/)')
6466 return ''.join(res)

The check that tells the two apart

failpass·tests.py::Test::test_incomplete_filename

Check file tests.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it8ea4444243e79aa6a359d58b9e9196c15ae6d2d8
Broken version dated2023-10-03
Modulegitignore_parser
Units changedfnmatch_pathname_to_regex
Fingerprint52d54b58932c2749
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in mherrmann/gitignore_parser