feat: derive mappings from staged git renames with --from-git-renames - #11
Merged
Conversation
The dominant agent workflow is 'git mv the files, then rewrite the remaining references'. The rename information already lives in git, yet users were reconstructing FROM=TO pairs by hand. --from-git-renames reads renames staged in the index (git diff --cached --find-renames) and derives old_stem=new_stem mappings from renames that keep their directory and extension. Renames that fit no token mapping (file-to-dir moves, extension changes) are reported as underivable with a reason instead of being silently dropped; conflicting derivations for the same FROM are a hard error naming both paths. Derived mappings merge with --map/--map-file and are recorded under 'derived' in the plan output, plan.json, and rep show. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
zawakin
force-pushed
the
feature/rep-from-git-renames
branch
from
July 6, 2026 01:41
2e61689 to
15646ad
Compare
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.
Why
The dominant real-world flow is:
git mvthe files first, then use rep to rewrite remaining references. The FROM=TO information already lives in git's rename detection, yet users rebuild it by hand (in the motivating log, via a Python script over 46 files).What
rep plan --from-git-renames: reads renames staged in the index (git diff --cached --find-renames --name-status --diff-filter=R -z, newgit::staged_renames+ NUL-record parser with unit tests).src/rename_derive.rs: derivesold_stem=new_stemonly from renames that keep directory and extension. Everything else is reported — not dropped — asunderivablewith a reason (directory_changedcovers file→dir moves likescenes/38_x.ts → scenes/x/scene.ts,extension_changedthe rest; same dir+ext+stem would be the same path, so the two reasons are exhaustive).--map/--map-fileand flow intoplan.jsonmappingslike manual ones; a new additive optionalderivedblock (from_git_renames,mappings,underivable) appears in plan output, plan.json, andrep show. No schema bumps (serde(default)keeps old plan.json readable).--map→ exit 2 no-op that still carries thederivedblock; human output explains whether to stage renames or write manual maps.long_helpdocuments the recipe (staged renames dirty the tree, so: derive → commit renames → re-plan → apply); the dirty-tree/stale-plan checks stay the safety net.Tests
Unit: derivation rules, dedup, conflict, multi-dot stems,
-zparser. E2E: derive+plan+plan.json roundtrip, file→dir underivable, no staged renames → 2, duplicate with--map→ 10, conflicting derivations → 10 naming both paths, merge with manual maps,rep showsurfacesderived.mise run rep:verifygreen.Stacked on #10.
🤖 Generated with Claude Code