]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix parsing of `git diff` when diff.mnemonicprefix=true
authorMarek Sapota <mareksapota@fb.com>
Wed, 19 Oct 2011 22:27:42 +0000 (15:27 -0700)
committerMarek Sapota <mareksapota@fb.com>
Thu, 20 Oct 2011 00:29:12 +0000 (17:29 -0700)
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
src/parser/diff/__tests__/ArcanistDiffParserTestCase.php
src/parser/diff/__tests__/data/git-mnemonicprefix.gitdiff [new file with mode: 0644]

index dfd8fda940f8079db7174b2cb85f44ad3fee95e5..f09ee484f932a76c065e61fcc30c63d03c1bfe72 100644 (file)
@@ -204,7 +204,7 @@ class ArcanistDiffParser {
         // This is a git commit message, probably from "git show".
         '(?P<type>commit) (?P<hash>[a-f0-9]+)',
         // This is a git diff, probably from "git show" or "git diff".
-        '(?P<type>diff --git) a/(?P<old>.+) b/(?P<cur>.+)',
+        '(?P<type>diff --git) [abicwo12]/(?P<old>.+) [abicwo12]/(?P<cur>.+)',
         // This is a unified diff, probably from "diff -u" or synthetic diffing.
         '(?P<type>---) (?P<old>.+)\s+\d{4}-\d{2}-\d{2}.*',
         '(?P<binary>Binary) files '.
index 7e1fdc316b81eda504bf5f865ffedef36a08b60d..2af1e63b0fe3bc98c314a231b5bd403c4c9223f4 100644 (file)
@@ -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 (file)
index 0000000..36deb9c
--- /dev/null
@@ -0,0 +1,7 @@
+diff --git i/FILE w/FILE
+index e8b5482..2a42638 100644
+--- i/FILE
++++ w/FILE
+@@ -1 +1,2 @@
+ TEXT
++MORE TEXT