fix: parse git's compact {old => new} rename notation in commit file list#188
Closed
rubensa wants to merge 1 commit into
Closed
fix: parse git's compact {old => new} rename notation in commit file list#188rubensa wants to merge 1 commit into
{old => new} rename notation in commit file list#188rubensa wants to merge 1 commit into
Conversation
…list
Files renamed under a renamed directory collapsed onto a single key and
overwrote each other, so only some appeared in the file list (and a plain
add/delete sibling could show duplicated). Add split_rename() to expand the
brace form to the real old/new paths instead of truncating at the '{'.
Author
|
Superseded by #189. While validating this fix I found that once renamed files correctly appear in the file list, opening their diff is still broken (#131) — the diff/view handlers use a single path for both revisions, so the child side resolves the pre-rename path (which doesn't exist there) and renders empty. That shares the same root cause as this PR (renames not tracked through to per-revision paths), so #189 fixes both #187 and #131 together and includes this PR's change as its first commit. Closing in favour of #189. |
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.
Fixes #187.
Problem
When a commit renames a directory, git reports the moved files with its compact
rename notation, e.g.
src/{old => new}/file.txt. The file-list parser(
git_numstat_summary_to_changes_arrayinweb/src/components/CommitDiff.vue, fed bygit show --numstat --summary) only understood the full-path formold => new.For a numstat row like
src/{old => new}/file.txtit did:So every file renamed under the same directory collapsed onto the same key
(
src/old) and the entries overwrote each other in the accumulator — only the last onesurvived. The
--summaryrename branch had the same assumption, so it couldn't reconcileeither. Result: files silently missing from the commit's file list, and a basename that
also appeared as a plain add/delete pair could show up duplicated.
Fix
Add a small
split_rename()helper that expands git's compact formprefix/{old => new}/suffix(and the degenerate{old => new},dir/{ => new}/f,dir/{old => }/f, and plainold => new) into the real old/new paths, and key theentries on the real old path in both the numstat branch and the
--summaryrenamebranch. No change to the git command or to the
FileDiffshape.Verification
Built and type-checked locally against a fresh checkout:
npm run build(vite + esbuild) — passes.vue-tsc --noEmit— no new errors from this change (the one remainingCommitDiff.vuediagnostic is pre-existing and present on the unmodified tree, justline-shifted).
Functional check on the directory-rename repro below (
src/old/→src/new/):src/oldkey, so the second overwrites the firstThe number of dropped files scales with the directory: an N-file directory rename
collapses all N brace-renamed entries onto a single key, so only one survives (plus
any siblings that happen to appear as plain add/delete pairs, which can then look
duplicated).
Reproduce the original bug
Open the
rename dircommit: before this fix at least one renamed file is missing fromthe list; with more files in the directory, several go missing and a basename can appear
duplicated.