vendor/libgit2/src/patch_parse.c in rugged-1.3.2.3 vs vendor/libgit2/src/patch_parse.c in rugged-1.4.2

- old
+ new

@@ -8,11 +8,11 @@ #include "patch_parse.h" #include "git2/patch.h" #include "patch.h" #include "diff_parse.h" -#include "path.h" +#include "fs_path.h" typedef struct { git_patch base; git_patch_parse_ctx *ctx; @@ -63,52 +63,52 @@ } return len; } -static int parse_header_path_buf(git_buf *path, git_patch_parse_ctx *ctx, size_t path_len) +static int parse_header_path_buf(git_str *path, git_patch_parse_ctx *ctx, size_t path_len) { int error; - if ((error = git_buf_put(path, ctx->parse_ctx.line, path_len)) < 0) + if ((error = git_str_put(path, ctx->parse_ctx.line, path_len)) < 0) return error; git_parse_advance_chars(&ctx->parse_ctx, path_len); - git_buf_rtrim(path); + git_str_rtrim(path); if (path->size > 0 && path->ptr[0] == '"' && - (error = git_buf_unquote(path)) < 0) + (error = git_str_unquote(path)) < 0) return error; - git_path_squash_slashes(path); + git_fs_path_squash_slashes(path); if (!path->size) return git_parse_err("patch contains empty path at line %"PRIuZ, ctx->parse_ctx.line_num); return 0; } static int parse_header_path(char **out, git_patch_parse_ctx *ctx) { - git_buf path = GIT_BUF_INIT; + git_str path = GIT_STR_INIT; int error; if ((error = parse_header_path_buf(&path, ctx, header_path_len(ctx))) < 0) goto out; - *out = git_buf_detach(&path); + *out = git_str_detach(&path); out: - git_buf_dispose(&path); + git_str_dispose(&path); return error; } static int parse_header_git_oldpath( git_patch_parsed *patch, git_patch_parse_ctx *ctx) { - git_buf old_path = GIT_BUF_INIT; + git_str old_path = GIT_STR_INIT; int error; if (patch->old_path) { error = git_parse_err("patch contains duplicate old path at line %"PRIuZ, ctx->parse_ctx.line_num); @@ -116,35 +116,35 @@ } if ((error = parse_header_path_buf(&old_path, ctx, ctx->parse_ctx.line_len - 1)) < 0) goto out; - patch->old_path = git_buf_detach(&old_path); + patch->old_path = git_str_detach(&old_path); out: - git_buf_dispose(&old_path); + git_str_dispose(&old_path); return error; } static int parse_header_git_newpath( git_patch_parsed *patch, git_patch_parse_ctx *ctx) { - git_buf new_path = GIT_BUF_INIT; + git_str new_path = GIT_STR_INIT; int error; if (patch->new_path) { error = git_parse_err("patch contains duplicate new path at line %"PRIuZ, ctx->parse_ctx.line_num); goto out; } if ((error = parse_header_path_buf(&new_path, ctx, ctx->parse_ctx.line_len - 1)) < 0) goto out; - patch->new_path = git_buf_detach(&new_path); + patch->new_path = git_str_detach(&new_path); out: - git_buf_dispose(&new_path); + git_str_dispose(&new_path); return error; } static int parse_header_mode(uint16_t *mode, git_patch_parse_ctx *ctx) { @@ -255,19 +255,19 @@ static int parse_header_rename( char **out, git_patch_parse_ctx *ctx) { - git_buf path = GIT_BUF_INIT; + git_str path = GIT_STR_INIT; if (parse_header_path_buf(&path, ctx, header_path_len(ctx)) < 0) return -1; /* Note: the `rename from` and `rename to` lines include the literal * filename. They do *not* include the prefix. (Who needs consistency?) */ - *out = git_buf_detach(&path); + *out = git_str_detach(&path); return 0; } static int parse_header_renamefrom( git_patch_parsed *patch, git_patch_parse_ctx *ctx) @@ -351,11 +351,11 @@ /* * We cannot expect to be able to always parse paths correctly at this * point. Due to the possibility of unquoted names, whitespaces in * filenames and custom prefixes we have to allow that, though, and just - * proceeed here. We then hope for the "---" and "+++" lines to fix that + * proceed here. We then hope for the "---" and "+++" lines to fix that * for us. */ if (!git_parse_ctx_contains(&ctx->parse_ctx, "\n", 1) && !git_parse_ctx_contains(&ctx->parse_ctx, "\r\n", 2)) { git_parse_advance_chars(&ctx->parse_ctx, ctx->parse_ctx.line_len - 1); @@ -380,11 +380,11 @@ STATE_SIMILARITY, STATE_RENAME, STATE_COPY, - STATE_END, + STATE_END } parse_header_state; typedef struct { const char *str; parse_header_state expected_state; @@ -764,11 +764,11 @@ static int parse_patch_binary_side( git_diff_binary_file *binary, git_patch_parse_ctx *ctx) { git_diff_binary_t type = GIT_DIFF_BINARY_NONE; - git_buf base85 = GIT_BUF_INIT, decoded = GIT_BUF_INIT; + git_str base85 = GIT_STR_INIT, decoded = GIT_STR_INIT; int64_t len; int error = 0; if (git_parse_ctx_contains_s(&ctx->parse_ctx, "literal ")) { type = GIT_DIFF_BINARY_LITERAL; @@ -813,11 +813,11 @@ if (!encoded_len || !ctx->parse_ctx.line_len || encoded_len > ctx->parse_ctx.line_len - 1) { error = git_parse_err("truncated binary data at line %"PRIuZ, ctx->parse_ctx.line_num); goto done; } - if ((error = git_buf_decode_base85( + if ((error = git_str_decode_base85( &decoded, ctx->parse_ctx.line, encoded_len, decoded_len)) < 0) goto done; if (decoded.size - decoded_orig != decoded_len) { error = git_parse_err("truncated binary data at line %"PRIuZ, ctx->parse_ctx.line_num); @@ -833,14 +833,14 @@ } binary->type = type; binary->inflatedlen = (size_t)len; binary->datalen = decoded.size; - binary->data = git_buf_detach(&decoded); + binary->data = git_str_detach(&decoded); done: - git_buf_dispose(&base85); - git_buf_dispose(&decoded); + git_str_dispose(&base85); + git_str_dispose(&decoded); return error; } static int parse_patch_binary( git_patch_parsed *patch,