diff options
author | Denis Laxalde <denis@laxalde.org> | 2019-09-28 15:52:25 +0200 |
---|---|---|
committer | Denis Laxalde <denis@laxalde.org> | 2019-09-28 15:52:25 +0200 |
commit | b61810bf1ff1007bc0a5d8e47362a735f2ff1f0b (patch) | |
tree | 76ebb13fba7ad245f68d08ce0bd0c78a84c8f4c4 /tests/diff | |
parent | 70325370667370159d5b85690c6dd5db17be3b20 (diff) | |
download | libgit2-b61810bf1ff1007bc0a5d8e47362a735f2ff1f0b.tar.gz |
patch_parse: handle patches with new empty files
Patches containing additions of empty files will not contain diff data
but will end with the index header line followed by the terminating
sequence "-- ". We follow the same logic as in cc4c44a and allow "-- "
to immediately follow the index header.
Diffstat (limited to 'tests/diff')
-rw-r--r-- | tests/diff/parse.c | 20 |
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); |