Page MenuHomePhabricator

D10267.diff
No OneTemporary

D10267.diff

diff --git a/src/parser/ArcanistDiffParser.php b/src/parser/ArcanistDiffParser.php
--- a/src/parser/ArcanistDiffParser.php
+++ b/src/parser/ArcanistDiffParser.php
@@ -830,6 +830,10 @@
$remainder = '\t.*';
} else if ($this->isRCS) {
$remainder = '\s.*';
+ } else if ($this->getIsGit()) {
+ // When filenames contain spaces, Git terminates this line with a tab.
+ // Normally, the tab is not present. If there's a tab, ignore it.
+ $remainder = '(?:\t.*)?';
}
$ok = preg_match(
diff --git a/src/parser/__tests__/ArcanistDiffParserTestCase.php b/src/parser/__tests__/ArcanistDiffParserTestCase.php
--- a/src/parser/__tests__/ArcanistDiffParserTestCase.php
+++ b/src/parser/__tests__/ArcanistDiffParserTestCase.php
@@ -595,6 +595,12 @@
$hunks = $change->getHunks();
$this->assertEqual(1, count($hunks));
break;
+ case 'git-remove-spaces.gitdiff':
+ $this->assertEqual(1, count($changes));
+
+ $change = array_shift($changes);
+ $this->assertEqual('file with spaces.txt', $change->getOldPath());
+ break;
default:
throw new Exception("No test block for diff file {$diff_file}.");
break;
diff --git a/src/parser/__tests__/diff/git-remove-spaces.gitdiff b/src/parser/__tests__/diff/git-remove-spaces.gitdiff
new file mode 100644
--- /dev/null
+++ b/src/parser/__tests__/diff/git-remove-spaces.gitdiff
@@ -0,0 +1,11 @@
+diff --git a/file with spaces.txt b/file with spaces.txt
+deleted file mode 100644
+index ae9854d..0000000
+--- a/file with spaces.txt
++++ /dev/null
+@@ -1,5 +0,0 @@
+-duck
+-duck
+-duck
+-duck
+-goose

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 25, 1:53 AM (9 h, 43 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6924289
Default Alt Text
D10267.diff (1 KB)

Event Timeline