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