summaryrefslogtreecommitdiff
path: root/tests/diff/parse.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-10-10 12:34:45 +0200
committerGitHub <noreply@github.com>2019-10-10 12:34:45 +0200
commit6716e2f3aca9bbe07478a4bd7bc79f6d24753472 (patch)
treefdbf7d889657f3bdfbeb092a16258f88889108ca /tests/diff/parse.c
parentf04a58b00c1a350e2cd90bddcdaa7865183c9d2f (diff)
parentb61810bf1ff1007bc0a5d8e47362a735f2ff1f0b (diff)
downloadlibgit2-6716e2f3aca9bbe07478a4bd7bc79f6d24753472.tar.gz
Merge pull request #5248 from dlax/parse-patch-empty-files
patch_parse: handle patches with new empty files
Diffstat (limited to 'tests/diff/parse.c')
-rw-r--r--tests/diff/parse.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/diff/parse.c b/tests/diff/parse.c
index a067861de..7d9f4b2e5 100644
--- a/tests/diff/parse.c
+++ b/tests/diff/parse.c
@@ -78,6 +78,26 @@ void test_diff_parse__exact_rename(void)
git_diff_free(diff);
}
+void test_diff_parse__empty_file(void)
+{
+ const char *content =
+ "---\n"
+ " file | 0\n"
+ " 1 file changed, 0 insertions(+), 0 deletions(-)\n"
+ " created mode 100644 file\n"
+ "\n"
+ "diff --git a/file b/file\n"
+ "new file mode 100644\n"
+ "index 0000000..e69de29\n"
+ "-- \n"
+ "2.20.1\n";
+ git_diff *diff;
+
+ cl_git_pass(git_diff_from_buffer(
+ &diff, content, strlen(content)));
+ git_diff_free(diff);
+}
+
void test_diff_parse__invalid_patches_fails(void)
{
test_parse_invalid_diff(PATCH_CORRUPT_MISSING_NEW_FILE);