mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-21 22:32:41 +01:00
Correctly parse git diffs with an empty file at the end
Summary: A minor bug in the parser prevented it from handling git diffs where an empty file appears at the end of the diff. Since git appends an extra newline, we failed to jump into the '$line === null' block. Test Plan: Ran unit tests. Generated a revision which only deleted an empty file. Reviewers: jungejason, nh, tuomaspelkonen, aran Reviewed By: nh CC: aran, nh, epriestley Differential Revision: 998
This commit is contained in:
parent
2fd37a1728
commit
1da98a11f1
19 changed files with 17 additions and 1 deletions
|
@ -569,7 +569,11 @@ class ArcanistDiffParser {
|
|||
|
||||
// $this->didFailParse("Expected 'index af23f...a98bc' header line.");
|
||||
} else {
|
||||
$line = $this->nextLine();
|
||||
// NOTE: In the git case, where this patch is the last change in the
|
||||
// file, we may have a final terminal newline. Skip over it so that
|
||||
// we'll hit the '$line === null' block below. This is covered by the
|
||||
// 'git-empty-file.gitdiff' test case.
|
||||
$line = $this->nextNonemptyLine();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -412,6 +412,12 @@ EOTEXT
|
|||
$change->getNewProperties()
|
||||
);
|
||||
break;
|
||||
case 'git-empty-files.gitdiff':
|
||||
$this->assertEqual(2, count($changes));
|
||||
while ($change = array_shift($changes)) {
|
||||
$this->assertEqual(0, count($change->getHunks()));
|
||||
}
|
||||
break;
|
||||
case 'git-commit.gitdiff':
|
||||
$this->assertEqual(1, count($changes));
|
||||
$change = reset($changes);
|
||||
|
|
0
src/parser/diff/__tests__/data/basic-missing-both-newlines-plus.udiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/basic-missing-both-newlines-plus.udiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/basic-missing-new-newline-plus.udiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/basic-missing-new-newline-plus.udiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/basic-missing-old-newline-plus.udiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/basic-missing-old-newline-plus.udiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-commit.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-commit.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-copy-plus.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-copy-plus.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-copy.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-copy.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-delete-file.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-delete-file.gitdiff
Executable file → Normal file
6
src/parser/diff/__tests__/data/git-empty-files.gitdiff
Normal file
6
src/parser/diff/__tests__/data/git-empty-files.gitdiff
Normal file
|
@ -0,0 +1,6 @@
|
|||
diff --git a/empty b/empty
|
||||
new file mode 100644
|
||||
index 0000000..e69de29
|
||||
diff --git a/empty2 b/empty2
|
||||
new file mode 100644
|
||||
index 0000000..e69de29
|
0
src/parser/diff/__tests__/data/git-ignore-whitespace-only.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-ignore-whitespace-only.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-merge-header.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-merge-header.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-move-edit.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-move-edit.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-move-plus.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-move-plus.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-move.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/git-move.gitdiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/svn-binary-diff.svndiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/svn-binary-diff.svndiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/svn-property-delete.svndiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/svn-property-delete.svndiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/svn-property-merge.svndiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/svn-property-merge.svndiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/svn-property-modify.svndiff
Executable file → Normal file
0
src/parser/diff/__tests__/data/svn-property-modify.svndiff
Executable file → Normal file
Loading…
Reference in a new issue