Summary:
Fixes T5870. When a filename contains spaces, Git will add a "\t" at the end of the "---" and "+++" lines. We currently consume this and think we're reading a file called "blah blah\t".
Instead, parse it out as not part of the filename.
Test Plan: Added failing unit test and made it pass.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5870
Differential Revision: https://secure.phabricator.com/D10267
$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(
$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;
--- /dev/null
+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