summaryrefslogtreecommitdiff
path: root/src/patch_parse.c
diff options
context:
space:
mode:
authorDenis Laxalde <denis@laxalde.org>2020-08-29 16:46:47 +0200
committerDenis Laxalde <denis@laxalde.org>2020-08-29 16:54:15 +0200
commit74293ea04a21f35151f0be095baf7bd3b3fd339c (patch)
treeb395cf3b6983179b497b2994160d2fde8ea92c9c /src/patch_parse.c
parent931bd3b83d624ec890a537ba4c1357ebf8032dca (diff)
downloadlibgit2-74293ea04a21f35151f0be095baf7bd3b3fd339c.tar.gz
patch_parse: handle absence of "index" header for new/deleted cases
This follows up on 11de594f85479e4804b07dc4f7b33cfe9212bea0 which added support for parsing patches without extended headers (the "index <hash>..<hash> <mode>" line); issue #5267. We now allow transition from "file mode" state to "path" state directly if there is no "index", which will happen for patches adding or deleting files as demonstrated in added test case.
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 918575306..619fea3ee 100644
--- a/src/patch_parse.c
+++ b/src/patch_parse.c
@@ -407,6 +407,7 @@ static const parse_header_transition transitions[] = {
{ "--- " , STATE_DIFF, STATE_PATH, parse_header_git_oldpath },
{ "--- " , STATE_INDEX, STATE_PATH, parse_header_git_oldpath },
+ { "--- " , STATE_FILEMODE, STATE_PATH, parse_header_git_oldpath },
{ "+++ " , STATE_PATH, STATE_END, parse_header_git_newpath },
{ "GIT binary patch" , STATE_INDEX, STATE_END, NULL },
{ "Binary files " , STATE_INDEX, STATE_END, NULL },