X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-blame.c;h=e17b03d876a7da13ac4f01f50c2e0c459d3e9612;hb=10455d2a955a29db1809be139177e4e298771eb0;hp=35471fc2615992451c8c5b51a346fe171029b572;hpb=679c7c56ed9f73db5892fe17ef9b67b84b0ca242;p=git.git diff --git a/builtin-blame.c b/builtin-blame.c index 35471fc26..e17b03d87 100644 --- a/builtin-blame.c +++ b/builtin-blame.c @@ -20,7 +20,7 @@ #include "mailmap.h" static char blame_usage[] = -"git-blame [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-L n,m] [-S ] [-M] [-C] [-C] [--contents ] [--incremental] [commit] [--] file\n" +"git-blame [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [-L n,m] [-S ] [-M] [-C] [-C] [--contents ] [--incremental] [commit] [--] file\n" " -c Use the same output mode as git-annotate (Default: off)\n" " -b Show blank SHA-1 for boundary commits (Default: off)\n" " -l Show long commit SHA1 (Default: off)\n" @@ -30,6 +30,7 @@ static char blame_usage[] = " -n, --show-number Show original linenumber (Default: off)\n" " -s Suppress author name and timestamp (Default: off)\n" " -p, --porcelain Show in a format designed for machine consumption\n" +" -w Ignore whitespace differences\n" " -L n,m Process only line range n,m, counting from 1\n" " -M, -C Find line movements within and across files\n" " --incremental Show blame entries as we find them, incrementally\n" @@ -45,6 +46,7 @@ static int show_root; static int blank_boundary; static int incremental; static int cmd_is_annotate; +static int xdl_opts = XDF_NEED_MINIMAL; static struct path_list mailmap; #ifndef DEBUG @@ -96,6 +98,10 @@ static char *fill_origin_blob(struct origin *o, mmfile_t *file) num_read_blob++; file->ptr = read_sha1_file(o->blob_sha1, &type, (unsigned long *)(&(file->size))); + if (!file->ptr) + die("Cannot read blob %s for path %s", + sha1_to_hex(o->blob_sha1), + o->path); o->file = *file; } else @@ -515,9 +521,9 @@ static struct patch *compare_buffer(mmfile_t *file_p, mmfile_t *file_o, xdemitconf_t xecfg; xdemitcb_t ecb; - xpp.flags = XDF_NEED_MINIMAL; + xpp.flags = xdl_opts; + memset(&xecfg, 0, sizeof(xecfg)); xecfg.ctxlen = context; - xecfg.flags = 0; ecb.outf = xdiff_outf; ecb.priv = &state; memset(&state, 0, sizeof(state)); @@ -1382,6 +1388,9 @@ static void get_commit_info(struct commit *commit, unsigned long size; commit->buffer = read_sha1_file(commit->object.sha1, &type, &size); + if (!commit->buffer) + die("Cannot read commit %s", + sha1_to_hex(commit->object.sha1)); } ret->author = author_buf; get_ac_line(commit->buffer, "\nauthor ", @@ -1457,6 +1466,7 @@ static void found_guilty_entry(struct blame_entry *ent) printf("boundary\n"); } write_filename_info(suspect->path); + maybe_flush_or_die(stdout, "stdout"); } } @@ -1744,11 +1754,11 @@ static int read_ancestry(const char *graft_file) */ static int lineno_width(int lines) { - int i, width; + int i, width; - for (width = 1, i = 10; i <= lines + 1; width++) - i *= 10; - return width; + for (width = 1, i = 10; i <= lines + 1; width++) + i *= 10; + return width; } /* @@ -2159,6 +2169,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix) output_option |= OUTPUT_LONG_OBJECT_NAME; else if (!strcmp("-s", arg)) output_option |= OUTPUT_NO_AUTHOR; + else if (!strcmp("-w", arg)) + xdl_opts |= XDF_IGNORE_WHITESPACE; else if (!strcmp("-S", arg) && ++i < argc) revs_file = argv[i]; else if (!prefixcmp(arg, "-M")) { @@ -2219,9 +2231,6 @@ int cmd_blame(int argc, const char **argv, const char *prefix) argv[unk++] = arg; } - if (!incremental) - setup_pager(); - if (!blame_move_score) blame_move_score = BLAME_DEFAULT_MOVE_SCORE; if (!blame_copy_score) @@ -2377,6 +2386,10 @@ int cmd_blame(int argc, const char **argv, const char *prefix) sb.final_buf = read_sha1_file(o->blob_sha1, &type, &sb.final_buf_size); + if (!sb.final_buf) + die("Cannot read blob %s for path %s", + sha1_to_hex(o->blob_sha1), + path); } num_read_blob++; lno = prepare_lines(&sb); @@ -2411,6 +2424,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix) read_mailmap(&mailmap, ".mailmap", NULL); + if (!incremental) + setup_pager(); + assign_blame(&sb, &revs, opt); if (incremental)