summaryrefslogtreecommitdiff
path: root/src/patch_parse.c
diff options
context:
space:
mode:
authorDenis Laxalde <denis@laxalde.org>2019-10-16 22:11:33 +0200
committerPatrick Steinhardt <ps@pks.im>2020-03-26 16:20:18 +0100
commitfc60777e31495543479bddba62615d9c27476424 (patch)
treec0907fbc0d3e93508ccde75652e5486a46d1dfab /src/patch_parse.c
parentfceedda5dc212d9653992ce623f18b6869944919 (diff)
downloadlibgit2-fc60777e31495543479bddba62615d9c27476424.tar.gz
patch_parse: handle patches without extended headers
Extended header lines (especially the "index <hash>..<hash> <mode>") 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.
Diffstat (limited to 'src/patch_parse.c')
-rw-r--r--src/patch_parse.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/patch_parse.c b/src/patch_parse.c
index 87bc311c5..73f1eb11a 100644
--- a/src/patch_parse.c
+++ b/src/patch_parse.c
@@ -377,6 +377,7 @@ static const parse_header_transition transitions[] = {
{ "index " , STATE_DIFF, STATE_INDEX, parse_header_git_index },
{ "index " , STATE_END, STATE_INDEX, parse_header_git_index },
+ { "--- " , STATE_DIFF, STATE_PATH, parse_header_git_oldpath },
{ "--- " , STATE_INDEX, STATE_PATH, parse_header_git_oldpath },
{ "+++ " , STATE_PATH, STATE_END, parse_header_git_newpath },
{ "GIT binary patch" , STATE_INDEX, STATE_END, NULL },