commit d157810fc8eed7b3b5b84ea214e7d9d95863e7d0 from: Stefan Sperling date: Thu Jun 21 21:36:40 2018 UTC make annotate_line() non-fatal; handles files getting short commit - ed77f2ae3c0b3d80baa937a627d7c7c55583337a commit + d157810fc8eed7b3b5b84ea214e7d9d95863e7d0 blob - 45a62df5727ec9a18821e43e1ac83f19029fad66 blob + 933ef189e913efdb7831787569b32f5139f2eaea --- lib/blame.c +++ lib/blame.c @@ -80,21 +80,20 @@ dump_blob_and_count_lines(size_t *nlines, FILE *outfil return NULL; } -static const struct got_error * +static void annotate_line(struct got_blame *blame, int lineno, struct got_object_id *id) { struct got_blame_line *line; if (lineno < 1 || lineno > blame->nlines) - return got_error(GOT_ERR_RANGE); + return; line = &blame->lines[lineno - 1]; if (line->annotated) - return NULL; + return; memcpy(&line->id, id, sizeof(line->id)); line->annotated = 1; - return NULL; } static const struct got_error * @@ -158,11 +157,8 @@ blame_commit(struct got_blame *blame, struct got_objec int a = change->cv.a; int b = change->cv.b; int lineno; - for (lineno = a; lineno <= b; lineno++) { - err = annotate_line(blame, lineno, id); - if (err) - goto done; - } + for (lineno = a; lineno <= b; lineno++) + annotate_line(blame, lineno, id); } free(id_str); } @@ -268,11 +264,8 @@ blame_open(struct got_blame **blamep, const char *path } /* Annotate remaining non-annotated lines with last commit. */ - for (lineno = 1; lineno < blame->nlines; lineno++) { - err = annotate_line(blame, lineno, id); - if (err) - break; - } + for (lineno = 1; lineno < blame->nlines; lineno++) + annotate_line(blame, lineno, id); done: free(id);