Home GnuPG

Parse git renames with inconsistent quoting or custom prefixes
d0957c344156Unpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

Parse git renames with inconsistent quoting or custom prefixes

Summary:
The previous parser failed when only one of the old/new filenames was
quoted, as with a rename of a Unicode filename to a non-Unicode
filename, or vice versa. It also incorrectly parsed custom prefixes,
even going to far as to encode this logic in the tests: a diff of
"src/file dst/file" which is not a rename should not be recorded as
changing "src/file", but rather "file".

Switch to using the "rename from" / "rename to" as the source of truth
for old and current filenames when complex renames are done. This
matches the logic that git itself uses to parse patches; the contents
of the diff --git line are merely viewed as a simplest-case
prediction, with renames handled later should it not match.

The diff parser already had logic to parse "rename from" / "rename to"
lines and extract their information. As such, this diff consists
primarily of removing logic from the splitGitDiffPaths method, and
allowing it to quietly fail.

This resolves two ambiguity mentioned in comments and tests: in
renaming "old file old" to "file", as well as the renaming of
"old file with spaces" to "new file with spaces" when neither are
quoted.

Test Plan:
arc unit. Many of the existing test cases no longer
applied to the splitGitDiffPaths method; they were moved into a new
test method which also supplies values for "rename from" and "rename
to" lines.

As noted in the summary, this alters one of the expected values of an
existing test. Specifically, the following diff is a file addition of
file with custom prefixes, and not the addition of "dst/file":

diff --git src/file dst/file
new file mode 100644
index 0000000..1269488
--- /dev/null
+++ dst/file
@@ -0,0 +1 @@
+data

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

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

Details

Provenance
Alex Vandiver <alexmv@dropbox.com>Authored on Aug 16 2016, 10:38 PM
Parents
rARCee6357386d0b: Correctly parse file renames and copies from `git diff --raw`
Branches
Unknown
Tags
Unknown

Event Timeline

Alex Vandiver <alexmv@dropbox.com> committed rARCd0957c344156: Parse git renames with inconsistent quoting or custom prefixes (authored by Alex Vandiver <alexmv@dropbox.com>).Aug 17 2016, 2:45 AM