From f67401daa4a034d0844a7bc608ced1081206da5a Mon Sep 17 00:00:00 2001 From: Marek Sapota Date: Wed, 19 Oct 2011 15:27:42 -0700 Subject: [PATCH] Fix parsing of `git diff` when diff.mnemonicprefix=true Test Plan: Go to /differential/diff/create and try to upload a patch that was created with `git diff` when diff.mnemonicprefix was set to true. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: 1022 --- src/parser/diff/ArcanistDiffParser.php | 2 +- src/parser/diff/__tests__/ArcanistDiffParserTestCase.php | 6 ++++++ src/parser/diff/__tests__/data/git-mnemonicprefix.gitdiff | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/parser/diff/__tests__/data/git-mnemonicprefix.gitdiff diff --git a/src/parser/diff/ArcanistDiffParser.php b/src/parser/diff/ArcanistDiffParser.php index dfd8fda9..f09ee484 100644 --- a/src/parser/diff/ArcanistDiffParser.php +++ b/src/parser/diff/ArcanistDiffParser.php @@ -204,7 +204,7 @@ class ArcanistDiffParser { // This is a git commit message, probably from "git show". '(?Pcommit) (?P[a-f0-9]+)', // This is a git diff, probably from "git show" or "git diff". - '(?Pdiff --git) a/(?P.+) b/(?P.+)', + '(?Pdiff --git) [abicwo12]/(?P.+) [abicwo12]/(?P.+)', // This is a unified diff, probably from "diff -u" or synthetic diffing. '(?P---) (?P.+)\s+\d{4}-\d{2}-\d{2}.*', '(?PBinary) files '. diff --git a/src/parser/diff/__tests__/ArcanistDiffParserTestCase.php b/src/parser/diff/__tests__/ArcanistDiffParserTestCase.php index 7e1fdc31..2af1e63b 100644 --- a/src/parser/diff/__tests__/ArcanistDiffParserTestCase.php +++ b/src/parser/diff/__tests__/ArcanistDiffParserTestCase.php @@ -418,6 +418,12 @@ EOTEXT $this->assertEqual(0, count($change->getHunks())); } break; + case 'git-mnemonicprefix.gitdiff': + // Check parsing of diffs created with `diff.mnemonicprefix` + // configuration option set to `true`. + $this->assertEqual(1, count($changes)); + $this->assertEqual(1, count(reset($changes)->getHunks())); + break; case 'git-commit.gitdiff': $this->assertEqual(1, count($changes)); $change = reset($changes); diff --git a/src/parser/diff/__tests__/data/git-mnemonicprefix.gitdiff b/src/parser/diff/__tests__/data/git-mnemonicprefix.gitdiff new file mode 100644 index 00000000..36deb9ca --- /dev/null +++ b/src/parser/diff/__tests__/data/git-mnemonicprefix.gitdiff @@ -0,0 +1,7 @@ +diff --git i/FILE w/FILE +index e8b5482..2a42638 100644 +--- i/FILE ++++ w/FILE +@@ -1 +1,2 @@ + TEXT ++MORE TEXT