Repository navigation
fix: detect renames when the new file is untracked - #246
Merged
Merged
Conversation
a plain `mv old new` (no `git mv`/staging) left `old` as an unstaged deletion and `new` untracked, so `git diff -M` never paired them - the tree showed a deletion plus an all-+ add instead of one rename. `UntrackedRenames` recovers the pairing off a throwaway index: copy `.git/index`, `git add -N` the untracked paths against the copy via `GIT_INDEX_FILE`, then `git diff -M` reports the rename. The real index and working tree are never touched. `FileDiff` renders these the same way via `untrackedRenameDiff`. Git-only (hg/jj have no untracked-rename concept), gated to unstaged working-tree mode. Related to #243
`cleanOverlayEnv` cleared every overlay-detection var except the agterm ones. On an agterm host `AGTERM_SESSION_ID` leaked from the real environment, so the launcher took its agterm branch (real `agtermctl session overlay open`) instead of the fake backend under test. That path doesn't pipe the fake revdiff's stdout/exit back, so every non-clean case returned exit 0 / empty output, while the "clean" case passed by coincidence. CI stayed green because CI isn't an agterm session. now clear `AGTERM_SESSION_ID` and `AGTERM_SOCKET` too. The agterm overlay backend (#238) added the launcher branch but left this helper out of sync.
- [major] [annotations_load.go] --annotations preload now runs the untracked-rename detector (foldUntrackedRenames) so (-)/context annotations on an untracked rename round-trip instead of being dropped as all-added - [major] [diff.go] untracked-rename git calls use GIT_LITERAL_PATHSPECS=1 (renameIndexEnv) so a filename like ":(top)x" is treated literally, not as pathspec magic - [minor] [diff.go] temp index path made absolute (filepath.Abs) so GIT_INDEX_FILE and cleanup agree when TMPDIR is relative - [minor] [diff.go] UntrackedRenames returns nil on a missing .git/index (fresh repo, no commits) instead of a spurious WARN - [over-engineering] [loaders.go] dropped the redundant renameNew map in mergeUntrackedEntries (entrySet already covers rename new-sides) - [test-gap] [diff_test.go] added pure-rename, path-with-spaces, pathspec-magic-name, and no-commit-repo tests - [test-gap] [annotations_load_test.go] added untracked-rename preload round-trip test - [doc-gap] [site/docs.html] rename-detection paragraph now covers the working-tree --untracked case CLAUDE.md gotcha updated to match.
- [minor] [diff.go] scope the no-index no-op to the missing-.git/index case via an errNoIndex sentinel; previously errors.Is(err, fs.ErrNotExist) wrapped the whole tempIndexWithIntentToAdd call, so an ENOENT from os.CreateTemp (missing TMPDIR) or a corrupt index was swallowed and silently disabled rename detection. other ENOENT now propagates with a warning. - [test] [diff_test.go] added TestGit_UntrackedRenames_RealErrorNotSwallowed
LandonSchropp
added a commit
to LandonSchropp/agent-toolkit
that referenced
this pull request
Jul 22, 2026
revdiff v1.11.1 (umputun/revdiff#246) now detects renames when the new file is untracked natively, making the throwaway-index workaround unnecessary.
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.
Renames done in the working tree without staging (
mv old new, nogit mv) showed up as a deletion plus an all-+new file instead of one rename entry. Staging the rename or using--stagedalready worked; only the unstaged-plus-untracked path was broken.Untracked files are diffed independently against
/dev/null, so the new path never shares agit diffinvocation with the deleted origin and-Mhas nothing to pair. The fix recovers the pairing off a throwaway index: copy.git/indexto a temp file, mark the untracked paths intent-to-add (git add -N) against the copy viaGIT_INDEX_FILE, thengit diff -Mreports the rename. The real index and working tree are never touched. The same trick renders the per-file rename diff. Git-only (hg and jj have no untracked-rename concept), gated to unstaged working-tree mode, and applied across all three paths: file tree, file diff, and--annotationspreload.Credit to @LandonSchropp for the report and the
GIT_INDEX_FILEapproach.Edge cases covered: pathspec-magic filenames like
:(top)xare treated literally viaGIT_LITERAL_PATHSPECS=1; a fresh repo with no commits (no index yet) returns no renames instead of erroring; a relativeTMPDIRno longer mismatches the temp-index path against cleanup.Also in this branch, unrelated to the rename fix: the launcher exit-code test was non-hermetic on agterm hosts.
cleanOverlayEnvdid not clearAGTERM_SESSION_ID/AGTERM_SOCKET, so inside an agterm session the launcher took the realagtermctloverlay path instead of the fake backend under test. Cleared those vars.Fixes #243