Repository navigation
Commit 221defb
committed
fix(repo): unquote
`Repo.ignored` runs `git check-ignore -- <paths>` and recovered the
matched paths from stdout with
`.replace("\\\\", "\\").replace('"', "").split("\n")`. git C-quotes a
path that contains a non-ASCII byte (with the default `core.quotePath`),
a double quote, a backslash or a control character, and that replacement
does not reverse the quoting. With `*.env` in `.gitignore`:
- `données.env` came back as `donn\303\251es.env`
- `q"uote.env` came back as `q\uote.env`
- `tab<TAB>.env` came back as `tab\t.env`
- a name containing a line feed came back with a literal `\n`
A caller that compares the result with the paths it passed in, for
example to leave ignored files out of a commit, an upload or an archive,
therefore treats those ignored files as not ignored.
Read stdout as bytes and unquote each quoted line with
`git.diff._unquote_path`, which already reverses git's C-quoting for
patch headers. Splitting at line feeds stays safe because git always
quotes a path that contains one. `git check-ignore -z` would avoid the
quoting, but git accepts `-z` only together with `--stdin`. Paths git
does not quote are returned unchanged.
Adds `test_ignored_items_reported_verbatim` to `test/test_repo.py`; it
fails before this change and passes after. `ruff check`,
`ruff format --check` and `mypy` pass. The full pytest suite run locally
fails the same 83 tests with and without this change; those failures
come from fixture commits missing in the local clone, not from this
change.git check-ignore paths in Repo.ignored
1 parent 9d3aff0 commit 221defb
2 files changed
Lines changed: 19 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
1158 | 1159 | | |
1159 | 1160 | | |
1160 | 1161 | | |
1161 | | - | |
| 1162 | + | |
1162 | 1163 | | |
1163 | 1164 | | |
1164 | 1165 | | |
| |||
1168 | 1169 | | |
1169 | 1170 | | |
1170 | 1171 | | |
1171 | | - | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
1172 | 1178 | | |
1173 | 1179 | | |
1174 | 1180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1657 | 1657 | | |
1658 | 1658 | | |
1659 | 1659 | | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
1660 | 1671 | | |
1661 | 1672 | | |
1662 | 1673 | | |
| |||
0 commit comments