Skip to content

fix(loop): read untracked paths NUL-separated so a non-ASCII new file no longer crashes a kept-tree refusal - #3625

Merged
clabonte merged 1 commit into
mainfrom
fix/issue-3616-untracked-paths-nul
Nov 27, 2026
Merged

clabonte merged 1 commit into
mainfrom
fix/issue-3616-untracked-paths-nul

Conversation

@clabonte

Copy link
Copy Markdown
Contributor

Closes #3616.

Root cause

untracked_paths() read git ls-files --others --exclude-standard line by line. Under git's default core.quotePath=true, a non-ASCII name (docs/café.md) came back C-quoted, quotes included. retain_tree_after_refusal then passed it to git add -N, which exits 128 on a pathspec that matches nothing. As a result, a guard refusal that kept the tree crashed the driver.

Fix

untracked_paths() reads with -z and splits on NUL, so every caller gets the real name. That covers retain_tree_after_refusal and squash_commit's new-file detection.

The issue also names ignored_paths and git_diff_names, which may mis-handle the same names. They don't crash, so they are left for a separate change to keep this fix minimal.

Tests

tests/test_untracked_paths_non_ascii.py:

  • untracked_paths() returns the real name.
  • A kept-tree refusal marks a new non-ASCII file intent-to-add, does not crash, and leaves HEAD unmoved.

Both tests fail on the unchanged code.

Verification

scripts/smoke-test.sh: 5163 tests OK (4 skipped); ruff and the bats suites are green.

🤖 Generated with Claude Code

… no longer crashes a kept-tree refusal

Closes #3616. `untracked_paths()` read `git ls-files --others --exclude-standard`
line by line. Under git's default `core.quotePath=true` a non-ASCII name such as
`docs/café.md` came back C-quoted, quotes included. `retain_tree_after_refusal`
passed that string to `git add -N`, which matched nothing and exited 128, so a
guard refusal that kept the tree crashed the driver.

`untracked_paths()` now passes `-z` and splits on NUL, so callers get the real
name (the same read `squash_commit`'s new-file detection uses).

Tests:
- tests/test_untracked_paths_non_ascii.py:NonAsciiUntrackedPaths — the real name
  is returned; a kept tree marks a new non-ASCII file intent-to-add without
  crashing (both fail on the unchanged code)

Verification:
- scripts/smoke-test.sh: 5163 tests OK (4 skipped), ruff and bats green

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clabonte
clabonte merged commit 88c54b3 into main Nov 27, 2026
7 checks passed
@clabonte
clabonte deleted the fix/issue-3616-untracked-paths-nul branch November 27, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Driver crashes keeping the tree when an attempt created a non-ASCII-named file (git add -N on a quoted path)

1 participant