]> git.proxmox.com Git - libgit2.git/commitdiff
patch::parse: handle patches with no hunks
authorEdward Thomson <ethomson@github.com>
Mon, 25 Apr 2016 21:52:39 +0000 (17:52 -0400)
committerEdward Thomson <ethomson@github.com>
Sun, 26 Jun 2016 03:08:06 +0000 (23:08 -0400)
Patches may have no hunks when there's no modifications (for example,
in a rename).  Handle them.

src/patch_parse.c

index cdf48502d48c20f207b8cec462f29acb0ead5f8f..72c4d148fe550a1a328ccc31fc02584136afa9ef 100644 (file)
@@ -361,6 +361,7 @@ typedef struct {
 } header_git_op;
 
 static const header_git_op header_git_ops[] = {
+       { "diff --git ", NULL },
        { "@@ -", NULL },
        { "GIT binary patch", NULL },
        { "--- ", parse_header_git_oldpath },
@@ -437,7 +438,8 @@ static int parse_header_git(
                }
                
                if (!found) {
-                       error = parse_err("invalid patch header at line %d", ctx->line_num);
+                       error = parse_err("invalid patch header at line %d",
+                               ctx->line_num);
                        goto done;
                }
        }