Repository navigation
Commit 3900431
committed
fix(repo): unquote the filename line in
`Repo.blame_incremental` took `BlameEntry.orig_path` from the `filename`
line of `git blame --incremental` verbatim. Git writes that line with
`write_name_quoted`, so a path containing a double quote, a backslash, a
control character or, with the default `core.quotePath=true`, any
non-ASCII byte is C-quoted: a line attributed to `café.txt` came back as
`orig_path == '"caf\303\251.txt"'` and `"quoted".txt` as
`'"\\"quoted\\".txt"'`, names that exist nowhere in the repository.
The quoted form reaches callers whenever the blamed file was renamed
from such a name, which the author of the history chooses.
Decode a quoted `filename` value with the existing `_unquote_path`
helper from `git.diff`, which already reverses Git's quoting for diff
headers; unquoted values are unchanged. The non-incremental porcelain
parser in `Repo.blame` reads the same line but does not expose it, so
it needs no change.
Adds a `blame-quoted-filename` case to `tests/fixtures/repo.sh` and
`test_blame_incremental_unquotes_filenames` in `test/test_repo.py`,
which fails before the change and passes after on both the CLI and the
Gix backend. Ruff, mypy and ShellCheck pass.Repo.blame_incremental
1 parent 4debc51 commit 3900431
3 files changed
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1293 | 1293 | | |
1294 | 1294 | | |
1295 | 1295 | | |
| 1296 | + | |
| 1297 | + | |
1296 | 1298 | | |
1297 | 1299 | | |
1298 | 1300 | | |
| |||
1375 | 1377 | | |
1376 | 1378 | | |
1377 | 1379 | | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
1378 | 1384 | | |
1379 | 1385 | | |
1380 | 1386 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
792 | 792 | | |
793 | 793 | | |
794 | 794 | | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
795 | 806 | | |
796 | 807 | | |
797 | 808 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
126 | 134 | | |
127 | 135 | | |
128 | 136 | | |
| |||
0 commit comments