1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 14:52:40 +01:00

Don't parse separator tabs as part of the filename in Git diffs which affect files with spaces

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
This commit is contained in:
epriestley 2014-08-14 12:13:02 -07:00
parent 4c0edd296e
commit 65b6e1bdac
3 changed files with 21 additions and 0 deletions

View file

@ -830,6 +830,10 @@ final class ArcanistDiffParser {
$remainder = '\t.*'; $remainder = '\t.*';
} else if ($this->isRCS) { } else if ($this->isRCS) {
$remainder = '\s.*'; $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( $ok = preg_match(

View file

@ -595,6 +595,12 @@ EOTEXT
$hunks = $change->getHunks(); $hunks = $change->getHunks();
$this->assertEqual(1, count($hunks)); $this->assertEqual(1, count($hunks));
break; 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: default:
throw new Exception("No test block for diff file {$diff_file}."); throw new Exception("No test block for diff file {$diff_file}.");
break; break;

View file

@ -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