Code

Replace the word 'update-cache' by 'update-index' everywhere
[git.git] / builtin-blame.c
index f7e2c13885a384d58c3481fa7259a64bf9525045..e17b03d876a7da13ac4f01f50c2e0c459d3e9612 100644 (file)
@@ -98,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
@@ -518,8 +522,8 @@ static struct patch *compare_buffer(mmfile_t *file_p, mmfile_t *file_o,
        xdemitcb_t ecb;
 
        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));
@@ -1384,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 ",
@@ -1459,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");
        }
 }
 
@@ -2223,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)
@@ -2381,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);
@@ -2415,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)