diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-09-01 09:37:05 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2017-09-01 09:41:12 +0200 |
commit | cc4c44a98a552b64c281101cbadb91effa5be5dd (patch) | |
tree | 9247fafb740fcc4920f5bf1b1e6838ebb04c85bb /tests/diff/parse.c | |
parent | 57bc9daba35dcabdacc40fd8bab0577fa7e86367 (diff) | |
download | libgit2-cc4c44a98a552b64c281101cbadb91effa5be5dd.tar.gz |
patch_parse: fix parsing patches only containing exact renames
Patches which contain exact renames only will not contain an actual diff
body, but only a list of files that were renamed. Thus, the patch header
is immediately followed by the terminating sequence "-- ". We currently
do not recognize this character sequence as a possible terminating
sequence. Add it and create a test to catch the failure.
Diffstat (limited to 'tests/diff/parse.c')
-rw-r--r-- | tests/diff/parse.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/diff/parse.c b/tests/diff/parse.c index acb6eb8a5..dc2ceefec 100644 --- a/tests/diff/parse.c +++ b/tests/diff/parse.c @@ -57,6 +57,27 @@ static void test_parse_invalid_diff(const char *invalid_diff) git_buf_free(&buf); } +void test_diff_parse__exact_rename(void) +{ + const char *content = + "---\n" + " old_name.c => new_name.c | 0\n" + " 1 file changed, 0 insertions(+), 0 deletions(-)\n" + " rename old_name.c => new_name.c (100%)\n" + "\n" + "diff --git a/old_name.c b/new_name.c\n" + "similarity index 100%\n" + "rename from old_name.c\n" + "rename to new_name.c\n" + "-- \n" + "2.9.3\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); |