HomePhabricator

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

Description

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

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.

Reviewers: Blessed Reviewers, epriestley

Reviewed By: Blessed Reviewers, epriestley

Subscribers: jboning, Korvin

Differential Revision: https://secure.phabricator.com/D16387

Details

Provenance
alexmvAuthored on Aug 10 2016, 9:32 PM
alexmvPushed on Aug 17 2016, 12:27 AM
Reviewer
Blessed Reviewers
Differential Revision
D16387: Correctly parse file renames and copies from `git diff --raw`
Parents
rARCe5be662d15a8: Use --no-ext-diff in `arc land` call to `git diff`
Branches
Unknown
Tags
Unknown
Build Status
Buildable 13330
Build 17097: Run Core Tests