Page MenuHomePhabricator

Correctly parse file renames and copies from `git diff --raw`
ClosedPublic

Authored by alexmv on Aug 10 2016, 9:44 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 8:50 PM
Unknown Object (File)
Thu, Apr 11, 9:26 AM
Unknown Object (File)
Feb 22 2024, 11:21 AM
Unknown Object (File)
Jan 31 2024, 3:14 AM
Unknown Object (File)
Jan 18 2024, 11:53 PM
Unknown Object (File)
Jan 18 2024, 11:52 PM
Unknown Object (File)
Dec 19 2023, 12:05 PM
Unknown Object (File)
Dec 15 2023, 7:41 AM
Subscribers

Details

Summary

parseGitRawDiff dealt with the A, M, and D status flags from
git diff --raw, for file additions, modifications, and deletions
respectively. However, it failed to cope with C and R flags, for
copies and renames. Git version 2.9 and above default to resolving
renames, even in git diff --raw output, making this lack of support
only salient now (though users with Git's diff.rename set
encountered it previously).

Those two flags differ from the other three in that they offer both the
source and destination filename, separated by a tab. As
parseGitRawDiff was not aware of this property, it returned a
"filename" of "oldfile\tnewfile". This is surfaced in several
places, including as passed to linters as a filename to check.
Needless to say, this file is nearly guaranteed to never exist on
disk.

Detect both the C and R flag types, and generate either a file
addition, or a pair of addition/deletion entries.

Test Plan

Renamed a file, with a linter that printed each file it was
called with.

Diff Detail

Repository
rARC Arcanist
Branch
git-move-diffs
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 13288
Build 17037: Run Core Tests
Build 17036: arc lint + arc unit

Event Timeline

alexmv retitled this revision from to Correctly parse file renames and copies from `git diff --raw`.
alexmv updated this object.
alexmv edited the test plan for this revision. (Show Details)
alexmv added a reviewer: epriestley.

After further testing, this is only relevant now because git < 2.9 did not do rename detection by default; it was enabled in 2.9.

alexmv edited edge metadata.
epriestley edited edge metadata.
This revision is now accepted and ready to land.Aug 17 2016, 12:19 AM