vendor/libgit2/src/patch_parse.c in rugged-0.27.5 vs vendor/libgit2/src/patch_parse.c in rugged-0.27.7

- old
+ new

@@ -96,11 +96,11 @@ goto out; patch->old_path = git_buf_detach(&old_path); out: - git_buf_free(&old_path); + git_buf_dispose(&old_path); return error; } static int parse_header_git_newpath( git_patch_parsed *patch, git_patch_parse_ctx *ctx) @@ -112,11 +112,11 @@ goto out; patch->new_path = git_buf_detach(&new_path); out: - git_buf_free(&new_path); + git_buf_dispose(&new_path); return error; } static int parse_header_mode(uint16_t *mode, git_patch_parse_ctx *ctx) { @@ -561,10 +561,12 @@ git_parse_advance_line(&ctx->parse_ctx)) { char c; int origin; int prefix = 1; + int old_lineno = hunk->hunk.old_start + (hunk->hunk.old_lines - oldlines); + int new_lineno = hunk->hunk.new_start + (hunk->hunk.new_lines - newlines); if (ctx->parse_ctx.line_len == 0 || ctx->parse_ctx.line[ctx->parse_ctx.line_len - 1] != '\n') { error = git_parse_err("invalid patch instruction at line %"PRIuZ, ctx->parse_ctx.line_num); goto done; @@ -584,15 +586,17 @@ break; case '-': origin = GIT_DIFF_LINE_DELETION; oldlines--; + new_lineno = -1; break; case '+': origin = GIT_DIFF_LINE_ADDITION; newlines--; + old_lineno = -1; break; default: error = git_parse_err("invalid patch hunk at line %"PRIuZ, ctx->parse_ctx.line_num); goto done; @@ -605,10 +609,13 @@ line->content = ctx->parse_ctx.line + prefix; line->content_len = ctx->parse_ctx.line_len - prefix; line->content_offset = ctx->parse_ctx.content_len - ctx->parse_ctx.remain_len; line->origin = origin; + line->num_lines = 1; + line->old_lineno = old_lineno; + line->new_lineno = new_lineno; hunk->line_count++; } if (oldlines || newlines) { @@ -768,11 +775,11 @@ binary->inflatedlen = (size_t)len; binary->datalen = decoded.size; binary->data = git_buf_detach(&decoded); done: - git_buf_free(&base85); - git_buf_free(&decoded); + git_buf_dispose(&base85); + git_buf_dispose(&decoded); return error; } static int parse_patch_binary( git_patch_parsed *patch,