From 11de594f85479e4804b07dc4f7b33cfe9212bea0 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Wed, 16 Oct 2019 22:11:33 +0200 Subject: patch_parse: handle patches without extended headers Extended header lines (especially the "index .. ") are not required by "git apply" so it import patches. So we allow the from-file/to-file lines (--- a/file\n+++ b/file) to directly follow the git diff header. This fixes #5267. --- tests/diff/parse.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/diff/parse.c') diff --git a/tests/diff/parse.c b/tests/diff/parse.c index 7d9f4b2e5..b004d1e23 100644 --- a/tests/diff/parse.c +++ b/tests/diff/parse.c @@ -98,6 +98,16 @@ void test_diff_parse__empty_file(void) git_diff_free(diff); } +void test_diff_parse__no_extended_headers(void) +{ + const char *content = PATCH_NO_EXTENDED_HEADERS; + 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); -- cgit v1.2.1