vendor/libgit2/src/diff_print.c in rugged-0.28.4 vs vendor/libgit2/src/diff_print.c in rugged-0.28.4.1

- old
+ new

@@ -8,11 +8,11 @@ #include "common.h" #include "diff.h" #include "diff_file.h" #include "patch_generate.h" -#include "futils.h" +#include "fileops.h" #include "zstream.h" #include "blob.h" #include "delta.h" #include "git2/sys/diff.h" @@ -46,11 +46,11 @@ pi->buf = out; if (!pi->id_strlen) { if (!repo) pi->id_strlen = GIT_ABBREV_DEFAULT; - else if (git_repository__configmap_lookup(&pi->id_strlen, repo, GIT_CONFIGMAP_ABBREV) < 0) + else if (git_repository__cvar(&pi->id_strlen, repo, GIT_CVAR_ABBREV) < 0) return -1; } if (pi->id_strlen > GIT_OID_HEXSZ) pi->id_strlen = GIT_OID_HEXSZ; @@ -267,12 +267,11 @@ return git_buf_oom(out) ? -1 : 0; } static int diff_print_oid_range( - git_buf *out, const git_diff_delta *delta, int id_strlen, - bool print_index) + git_buf *out, const git_diff_delta *delta, int id_strlen) { char start_oid[GIT_OID_HEXSZ+1], end_oid[GIT_OID_HEXSZ+1]; if (delta->old_file.mode && id_strlen > delta->old_file.id_abbrev) { @@ -292,23 +291,21 @@ git_oid_tostr(start_oid, id_strlen + 1, &delta->old_file.id); git_oid_tostr(end_oid, id_strlen + 1, &delta->new_file.id); if (delta->old_file.mode == delta->new_file.mode) { - if (print_index) - git_buf_printf(out, "index %s..%s %o\n", - start_oid, end_oid, delta->old_file.mode); + git_buf_printf(out, "index %s..%s %o\n", + start_oid, end_oid, delta->old_file.mode); } else { if (delta->old_file.mode == 0) git_buf_printf(out, "new file mode %o\n", delta->new_file.mode); else if (delta->new_file.mode == 0) git_buf_printf(out, "deleted file mode %o\n", delta->old_file.mode); else diff_print_modes(out, delta); - if (print_index) - git_buf_printf(out, "index %s..%s\n", start_oid, end_oid); + git_buf_printf(out, "index %s..%s\n", start_oid, end_oid); } return git_buf_oom(out) ? -1 : 0; } @@ -326,14 +323,14 @@ const git_diff_delta *delta, const char *template, const char *oldpath, const char *newpath) { - if (git_oid_is_zero(&delta->old_file.id)) + if (git_oid_iszero(&delta->old_file.id)) oldpath = "/dev/null"; - if (git_oid_is_zero(&delta->new_file.id)) + if (git_oid_iszero(&delta->new_file.id)) newpath = "/dev/null"; return git_buf_printf(out, template, oldpath, newpath); } @@ -382,12 +379,12 @@ return error; } static bool delta_is_unchanged(const git_diff_delta *delta) { - if (git_oid_is_zero(&delta->old_file.id) && - git_oid_is_zero(&delta->new_file.id)) + if (git_oid_iszero(&delta->old_file.id) && + git_oid_iszero(&delta->new_file.id)) return true; if (delta->old_file.mode == GIT_FILEMODE_COMMIT || delta->new_file.mode == GIT_FILEMODE_COMMIT) return false; @@ -401,12 +398,11 @@ int git_diff_delta__format_file_header( git_buf *out, const git_diff_delta *delta, const char *oldpfx, const char *newpfx, - int id_strlen, - bool print_index) + int id_strlen) { git_buf old_path = GIT_BUF_INIT, new_path = GIT_BUF_INIT; bool unchanged = delta_is_unchanged(delta); int error = 0; @@ -433,12 +429,11 @@ if ((error = diff_delta_format_similarity_header(out, delta)) < 0) goto done; } if (!unchanged) { - if ((error = diff_print_oid_range(out, delta, - id_strlen, print_index)) < 0) + if ((error = diff_print_oid_range(out, delta, id_strlen)) < 0) goto done; if ((delta->flags & GIT_DIFF_FLAG_BINARY) == 0) diff_delta_format_with_paths(out, delta, "--- %s\n+++ %s\n", old_path.ptr, new_path.ptr); @@ -569,11 +564,10 @@ bool binary = (delta->flags & GIT_DIFF_FLAG_BINARY) || (pi->flags & GIT_DIFF_FORCE_BINARY); bool show_binary = !!(pi->flags & GIT_DIFF_SHOW_BINARY); int id_strlen = pi->id_strlen; - bool print_index = (pi->format != GIT_DIFF_FORMAT_PATCH_ID); if (binary && show_binary) id_strlen = delta->old_file.id_abbrev ? delta->old_file.id_abbrev : delta->new_file.id_abbrev; @@ -586,12 +580,11 @@ (delta->status == GIT_DELTA_UNTRACKED && (pi->flags & GIT_DIFF_SHOW_UNTRACKED_CONTENT) == 0)) return 0; if ((error = git_diff_delta__format_file_header( - pi->buf, delta, oldpfx, newpfx, - id_strlen, print_index)) < 0) + pi->buf, delta, oldpfx, newpfx, id_strlen)) < 0) return error; pi->line.origin = GIT_DIFF_LINE_FILE_HDR; pi->line.content = git_buf_cstr(pi->buf); pi->line.content_len = git_buf_len(pi->buf); @@ -673,14 +666,9 @@ switch (format) { case GIT_DIFF_FORMAT_PATCH: print_file = diff_print_patch_file; print_binary = diff_print_patch_binary; print_hunk = diff_print_patch_hunk; - print_line = diff_print_patch_line; - break; - case GIT_DIFF_FORMAT_PATCH_ID: - print_file = diff_print_patch_file; - print_binary = diff_print_patch_binary; print_line = diff_print_patch_line; break; case GIT_DIFF_FORMAT_PATCH_HEADER: print_file = diff_print_patch_file; break;