fix: make git integration robust to renames, non-ASCII paths, and cwd - #26
Open
KEY60228 wants to merge 1 commit into
Open
fix: make git integration robust to renames, non-ASCII paths, and cwd#26KEY60228 wants to merge 1 commit into
KEY60228 wants to merge 1 commit into
Conversation
Rework the git module around vim.system() argv calls executed with
`git -C <root>`, fixing several failure modes:
- Renamed/copied files: parse `--name-status -z` NUL-separated output,
which emits two paths for R/C entries. Previously the tab-separated
pair was captured as a single bogus path and the status kept its
score suffix ("R100"), breaking diff retrieval, the file tree, and
Markdown output. Rename diffs now pass both paths as pathspec so git
can pair them, and Markdown labels show "Renamed from <old>".
- Non-ASCII filenames: -z output is unquoted raw bytes, so paths like
日本語.txt survive regardless of core.quotepath (previously stored
as octal-escaped quoted strings that matched nothing).
- cwd independence: all commands run with `git -C <root>`, so per-file
pathspecs resolve correctly when Neovim is started in a subdirectory
(previously the empty diff triggered the --no-index fallback and
displayed tracked files as full additions).
- Staged changes: the no-argument diff now compares HEAD to the
working tree (falling back to the index diff in unborn repos), so
staged edits are reviewable as documented.
- --no-index fallback: only applied to files explicitly flagged as
untracked by ls-files, instead of firing whenever a diff came back
empty.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reworks the git module around
vim.system()argv calls executed withgit -C <root>, fixing five failure modes found in a full-project review:--name-statusrename lines (R100\told\tnew) were parsed as a single bogus path with status"R100", breaking diff retrieval, the file tree, and Markdown output. Now parsed via NUL-separated-zoutput; rename diffs pass both paths as pathspec so git pairs them, and Markdown showsRenamed from <old>.core.quotepath, paths were stored as octal-escaped quoted strings that matched nothing.-zoutput is unquoted raw bytes, so they now work regardless of the setting.git -C <root>, so per-file pathspecs resolve correctly when Neovim is started in a subdirectory. Previously the empty diff silently triggered the--no-indexfallback and displayed tracked files as full additions.:ReviewThemStartnow diffsHEADagainst the working tree (falling back to the index diff in unborn repos), so staged edits are reviewable as the docs describe.--no-indexfallback: only applied to files explicitly flagged as untracked byls-files, instead of firing whenever a diff came back empty.get_file_diffnow takes theDiffFileentry (bare paths still accepted for compatibility). Docs updated to describe the merge-base semantics of the base-only form and the staged/untracked coverage of the no-argument form.Test plan
Verified with a headless-nvim script against a fixture repo (rename commit, Japanese filenames, staged + untracked files, run from a subdirectory): all 13 checks pass, including rename parse (
status=R,old_pathset), unquoted Japanese paths, staged file inclusion, per-file hunks from a subdirectory, no--no-indexmisfire for tracked files, and end-to-endsession.create.🤖 Generated with Claude Code