X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=combine-diff.c;h=7693884fdb7e43d0aecd77ad1c71531181d7ceee;hb=459a21bd35675e140e19569e8b5c62c7fc4eee5b;hp=d812600d1185aa82b3a0dae69f61daca789b9322;hpb=e8a1a11d4e0036a4205dbed533c135b51cd87218;p=git.git diff --git a/combine-diff.c b/combine-diff.c index d812600d..7693884f 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -1,5 +1,6 @@ #include "cache.h" #include "commit.h" +#include "blob.h" #include "diff.h" #include "diffcore.h" #include "quote.h" @@ -104,7 +105,7 @@ static char *grab_blob(const unsigned char *sha1, unsigned long *size) return xcalloc(1, 1); } blob = read_sha1_file(sha1, type, size); - if (strcmp(type, "blob")) + if (strcmp(type, blob_type)) die("object '%s' is not a blob!", sha1_to_hex(sha1)); return blob; } @@ -621,7 +622,8 @@ static void reuse_combine_diff(struct sline *sline, unsigned long cnt, } static int show_patch_diff(struct combine_diff_path *elem, int num_parent, - int dense, const char *header) + int dense, const char *header, + struct diff_options *opt) { unsigned long size, cnt, lno; char *result, *cp, *ep; @@ -631,6 +633,7 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent, char ourtmp_buf[TMPPATHLEN]; char *ourtmp = ourtmp_buf; int working_tree_file = !memcmp(elem->sha1, null_sha1, 20); + int abbrev = opt->full_index ? 40 : DEFAULT_ABBREV; /* Read the result of merge first */ if (!working_tree_file) { @@ -647,7 +650,7 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent, int len = st.st_size; int cnt = 0; - elem->mode = DIFF_FILE_CANON_MODE(st.st_mode); + elem->mode = canon_mode(st.st_mode); size = len; result = xmalloc(len + 1); while (cnt < len) { @@ -724,7 +727,7 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent, if (header) { shown_header++; - puts(header); + printf("%s%c", header, opt->line_termination); } printf("diff --%s ", dense ? "cc" : "combined"); if (quote_c_style(elem->path, NULL, NULL, 0)) @@ -735,10 +738,10 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent, printf("index "); for (i = 0; i < num_parent; i++) { abb = find_unique_abbrev(elem->parent[i].sha1, - DEFAULT_ABBREV); + abbrev); printf("%s%s", i ? "," : "", abb); } - abb = find_unique_abbrev(elem->sha1, DEFAULT_ABBREV); + abb = find_unique_abbrev(elem->sha1, abbrev); printf("..%s\n", abb); if (mode_differs) { @@ -797,7 +800,7 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, const cha inter_name_termination = 0; if (header) - puts(header); + printf("%s%c", header, line_termination); for (i = 0; i < num_parent; i++) { if (p->parent[i].mode) @@ -862,7 +865,7 @@ int show_combined_diff(struct combine_diff_path *p, default: case DIFF_FORMAT_PATCH: - return show_patch_diff(p, num_parent, dense, header); + return show_patch_diff(p, num_parent, dense, header, opt); } }