diff options
author | Patrick Steinhardt <ps@pks.im> | 2019-11-28 14:41:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-28 14:41:58 +0100 |
commit | fb439c975a2de33f5b0c317f3fdea49dc94b27dc (patch) | |
tree | ae22d26f1bc5d91f947577c291309cb57c2ebd77 /src/patch_parse.c | |
parent | 61176a9b363b1274c101d82f36cbf9cb71a10f74 (diff) | |
parent | ece5bb5e7d6e35e50096bac3d7bf17342daaec77 (diff) | |
download | libgit2-fb439c975a2de33f5b0c317f3fdea49dc94b27dc.tar.gz |
Merge pull request #5306 from herrerog/patchid
diff: complete support for git patchid
Diffstat (limited to 'src/patch_parse.c')
-rw-r--r-- | src/patch_parse.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/patch_parse.c b/src/patch_parse.c index 35fd65a0d..dad1813fa 100644 --- a/src/patch_parse.c +++ b/src/patch_parse.c @@ -231,9 +231,9 @@ static int parse_header_git_deletedfilemode( git_patch_parsed *patch, git_patch_parse_ctx *ctx) { - git__free((char *)patch->base.delta->old_file.path); + git__free((char *)patch->base.delta->new_file.path); - patch->base.delta->old_file.path = NULL; + patch->base.delta->new_file.path = NULL; patch->base.delta->status = GIT_DELTA_DELETED; patch->base.delta->nfiles = 1; @@ -244,9 +244,9 @@ static int parse_header_git_newfilemode( git_patch_parsed *patch, git_patch_parse_ctx *ctx) { - git__free((char *)patch->base.delta->new_file.path); + git__free((char *)patch->base.delta->old_file.path); - patch->base.delta->new_file.path = NULL; + patch->base.delta->old_file.path = NULL; patch->base.delta->status = GIT_DELTA_ADDED; patch->base.delta->nfiles = 1; @@ -884,6 +884,11 @@ static int parse_patch_binary_nodata( if (!old || !new) return git_parse_err("corrupt binary data without paths at line %"PRIuZ, ctx->parse_ctx.line_num); + if (patch->base.delta->status == GIT_DELTA_ADDED) + old = "/dev/null"; + else if (patch->base.delta->status == GIT_DELTA_DELETED) + new = "/dev/null"; + if (git_parse_advance_expected_str(&ctx->parse_ctx, "Binary files ") < 0 || git_parse_advance_expected_str(&ctx->parse_ctx, old) < 0 || git_parse_advance_expected_str(&ctx->parse_ctx, " and ") < 0 || |