2 404c43c4 2018-06-21 stsp * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
4 404c43c4 2018-06-21 stsp * Permission to use, copy, modify, and distribute this software for any
5 404c43c4 2018-06-21 stsp * purpose with or without fee is hereby granted, provided that the above
6 404c43c4 2018-06-21 stsp * copyright notice and this permission notice appear in all copies.
8 404c43c4 2018-06-21 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 404c43c4 2018-06-21 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 404c43c4 2018-06-21 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 404c43c4 2018-06-21 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 404c43c4 2018-06-21 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 404c43c4 2018-06-21 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 404c43c4 2018-06-21 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 404c43c4 2018-06-21 stsp #include <sys/queue.h>
18 404c43c4 2018-06-21 stsp #include <sys/stat.h>
20 404c43c4 2018-06-21 stsp #include <sha1.h>
21 404c43c4 2018-06-21 stsp #include <string.h>
22 404c43c4 2018-06-21 stsp #include <stdio.h>
23 404c43c4 2018-06-21 stsp #include <stdlib.h>
24 404c43c4 2018-06-21 stsp #include <time.h>
25 404c43c4 2018-06-21 stsp #include <util.h>
26 404c43c4 2018-06-21 stsp #include <zlib.h>
28 404c43c4 2018-06-21 stsp #include "got_error.h"
29 404c43c4 2018-06-21 stsp #include "got_object.h"
30 404c43c4 2018-06-21 stsp #include "got_blame.h"
31 404c43c4 2018-06-21 stsp #include "got_opentemp.h"
33 63581804 2018-07-09 stsp #include "got_lib_inflate.h"
34 404c43c4 2018-06-21 stsp #include "got_lib_delta.h"
35 404c43c4 2018-06-21 stsp #include "got_lib_object.h"
36 404c43c4 2018-06-21 stsp #include "got_lib_diff.h"
37 c35a7943 2018-07-12 stsp #include "got_lib_diffoffset.h"
38 293f6400 2018-09-20 stsp #include "got_commit_graph.h"
40 404c43c4 2018-06-21 stsp struct got_blame_line {
41 404c43c4 2018-06-21 stsp int annotated;
42 9b94757a 2018-06-21 stsp struct got_object_id id;
43 6c4c42e0 2019-06-24 stsp off_t offset;
46 c35a7943 2018-07-12 stsp struct got_blame_diff_offsets {
47 c35a7943 2018-07-12 stsp struct got_diffoffset_chunks *chunks;
48 c35a7943 2018-07-12 stsp struct got_object_id *commit_id;
49 c35a7943 2018-07-12 stsp SLIST_ENTRY(got_blame_diff_offsets) entry;
52 c35a7943 2018-07-12 stsp SLIST_HEAD(got_blame_diff_offsets_list, got_blame_diff_offsets);
54 404c43c4 2018-06-21 stsp struct got_blame {
56 6c4c42e0 2019-06-24 stsp size_t filesize;
58 06ca4d09 2018-11-19 stsp int nannotated;
59 404c43c4 2018-06-21 stsp struct got_blame_line *lines; /* one per line */
60 6c4c42e0 2019-06-24 stsp off_t *line_offsets; /* one per line */
61 c35a7943 2018-07-12 stsp int ncommits;
62 c35a7943 2018-07-12 stsp struct got_blame_diff_offsets_list diff_offsets_list;
66 c35a7943 2018-07-12 stsp free_diff_offsets(struct got_blame_diff_offsets *diff_offsets)
68 c35a7943 2018-07-12 stsp if (diff_offsets->chunks)
69 c35a7943 2018-07-12 stsp got_diffoffset_free(diff_offsets->chunks);
70 c35a7943 2018-07-12 stsp free(diff_offsets->commit_id);
71 c35a7943 2018-07-12 stsp free(diff_offsets);
74 404c43c4 2018-06-21 stsp static const struct got_error *
75 c35a7943 2018-07-12 stsp alloc_diff_offsets(struct got_blame_diff_offsets **diff_offsets,
76 c35a7943 2018-07-12 stsp struct got_object_id *commit_id)
78 c35a7943 2018-07-12 stsp const struct got_error *err = NULL;
80 c35a7943 2018-07-12 stsp *diff_offsets = calloc(1, sizeof(**diff_offsets));
81 c35a7943 2018-07-12 stsp if (*diff_offsets == NULL)
82 638f9024 2019-05-13 stsp return got_error_from_errno("calloc");
84 c35a7943 2018-07-12 stsp (*diff_offsets)->commit_id = got_object_id_dup(commit_id);
85 c35a7943 2018-07-12 stsp if ((*diff_offsets)->commit_id == NULL) {
86 638f9024 2019-05-13 stsp err = got_error_from_errno("got_object_id_dup");
87 c35a7943 2018-07-12 stsp free_diff_offsets(*diff_offsets);
88 c35a7943 2018-07-12 stsp *diff_offsets = NULL;
92 c35a7943 2018-07-12 stsp err = got_diffoffset_alloc(&(*diff_offsets)->chunks);
94 c35a7943 2018-07-12 stsp free_diff_offsets(*diff_offsets);
98 c35a7943 2018-07-12 stsp return NULL;
101 c35a7943 2018-07-12 stsp static const struct got_error *
102 84451b3e 2018-07-10 stsp annotate_line(struct got_blame *blame, int lineno, struct got_object_id *id,
103 84451b3e 2018-07-10 stsp const struct got_error *(*cb)(void *, int, int, struct got_object_id *),
106 404c43c4 2018-06-21 stsp const struct got_error *err = NULL;
107 404c43c4 2018-06-21 stsp struct got_blame_line *line;
109 404c43c4 2018-06-21 stsp if (lineno < 1 || lineno > blame->nlines)
110 f2e233d8 2018-11-19 stsp return NULL;
112 404c43c4 2018-06-21 stsp line = &blame->lines[lineno - 1];
113 404c43c4 2018-06-21 stsp if (line->annotated)
114 84451b3e 2018-07-10 stsp return NULL;
116 404c43c4 2018-06-21 stsp memcpy(&line->id, id, sizeof(line->id));
117 404c43c4 2018-06-21 stsp line->annotated = 1;
118 06ca4d09 2018-11-19 stsp blame->nannotated++;
120 84451b3e 2018-07-10 stsp err = cb(arg, blame->nlines, lineno, id);
121 84451b3e 2018-07-10 stsp return err;
125 c35a7943 2018-07-12 stsp get_blamed_line(struct got_blame_diff_offsets_list *diff_offsets_list,
126 c35a7943 2018-07-12 stsp int lineno)
128 c35a7943 2018-07-12 stsp struct got_blame_diff_offsets *diff_offsets;
130 c35a7943 2018-07-12 stsp SLIST_FOREACH(diff_offsets, diff_offsets_list, entry)
131 c35a7943 2018-07-12 stsp lineno = got_diffoffset_get(diff_offsets->chunks, lineno);
133 c35a7943 2018-07-12 stsp return lineno;
136 404c43c4 2018-06-21 stsp static const struct got_error *
137 c35a7943 2018-07-12 stsp blame_changes(struct got_blame *blame, struct got_diff_changes *changes,
138 c35a7943 2018-07-12 stsp struct got_object_id *commit_id,
139 c35a7943 2018-07-12 stsp const struct got_error *(*cb)(void *, int, int, struct got_object_id *),
142 c35a7943 2018-07-12 stsp const struct got_error *err = NULL;
143 c35a7943 2018-07-12 stsp struct got_diff_change *change;
144 c35a7943 2018-07-12 stsp struct got_blame_diff_offsets *diff_offsets;
146 c35a7943 2018-07-12 stsp SIMPLEQ_FOREACH(change, &changes->entries, entry) {
147 c35a7943 2018-07-12 stsp int c = change->cv.c;
148 c35a7943 2018-07-12 stsp int d = change->cv.d;
149 c35a7943 2018-07-12 stsp int new_lineno = c;
150 c35a7943 2018-07-12 stsp int new_length = (c < d ? d - c + 1 : (c == d ? 1 : 0));
153 c35a7943 2018-07-12 stsp for (ln = new_lineno; ln < new_lineno + new_length; ln++) {
154 c35a7943 2018-07-12 stsp err = annotate_line(blame,
155 c35a7943 2018-07-12 stsp get_blamed_line(&blame->diff_offsets_list, ln),
156 c35a7943 2018-07-12 stsp commit_id, cb, arg);
158 c35a7943 2018-07-12 stsp return err;
159 06ca4d09 2018-11-19 stsp if (blame->nlines == blame->nannotated)
160 06ca4d09 2018-11-19 stsp return NULL;
164 c35a7943 2018-07-12 stsp err = alloc_diff_offsets(&diff_offsets, commit_id);
166 c35a7943 2018-07-12 stsp return err;
167 c35a7943 2018-07-12 stsp SIMPLEQ_FOREACH(change, &changes->entries, entry) {
168 c35a7943 2018-07-12 stsp int a = change->cv.a;
169 c35a7943 2018-07-12 stsp int b = change->cv.b;
170 c35a7943 2018-07-12 stsp int c = change->cv.c;
171 c35a7943 2018-07-12 stsp int d = change->cv.d;
172 c35a7943 2018-07-12 stsp int old_lineno = a;
173 c35a7943 2018-07-12 stsp int old_length = (a < b ? b - a + 1 : (a == b ? 1 : 0));
174 c35a7943 2018-07-12 stsp int new_lineno = c;
175 c35a7943 2018-07-12 stsp int new_length = (c < d ? d - c + 1 : (c == d ? 1 : 0));
177 c35a7943 2018-07-12 stsp err = got_diffoffset_add(diff_offsets->chunks,
178 c35a7943 2018-07-12 stsp old_lineno, old_length, new_lineno, new_length);
180 df9513f1 2018-07-13 stsp free_diff_offsets(diff_offsets);
181 c35a7943 2018-07-12 stsp return err;
184 c35a7943 2018-07-12 stsp SLIST_INSERT_HEAD(&blame->diff_offsets_list, diff_offsets, entry);
186 c35a7943 2018-07-12 stsp return NULL;
189 c35a7943 2018-07-12 stsp static const struct got_error *
190 404c43c4 2018-06-21 stsp blame_commit(struct got_blame *blame, struct got_object_id *id,
191 84451b3e 2018-07-10 stsp struct got_object_id *pid, const char *path, struct got_repository *repo,
192 84451b3e 2018-07-10 stsp const struct got_error *(*cb)(void *, int, int, struct got_object_id *),
195 404c43c4 2018-06-21 stsp const struct got_error *err = NULL;
196 404c43c4 2018-06-21 stsp struct got_object *obj = NULL, *pobj = NULL;
197 27d434c2 2018-09-15 stsp struct got_object_id *obj_id = NULL, *pobj_id = NULL;
198 404c43c4 2018-06-21 stsp struct got_blob_object *blob = NULL, *pblob = NULL;
199 404c43c4 2018-06-21 stsp struct got_diff_changes *changes = NULL;
201 27d434c2 2018-09-15 stsp err = got_object_id_by_path(&obj_id, repo, id, path);
205 27d434c2 2018-09-15 stsp err = got_object_open(&obj, repo, obj_id);
209 15a94983 2018-12-23 stsp if (obj->type != GOT_OBJ_TYPE_BLOB) {
210 404c43c4 2018-06-21 stsp err = got_error(GOT_ERR_OBJ_TYPE);
214 27d434c2 2018-09-15 stsp err = got_object_id_by_path(&pobj_id, repo, pid, path);
216 d1451975 2018-11-11 stsp if (err->code == GOT_ERR_NO_TREE_ENTRY) {
217 404c43c4 2018-06-21 stsp /* Blob's history began in previous commit. */
218 404c43c4 2018-06-21 stsp err = got_error(GOT_ERR_ITER_COMPLETED);
223 27d434c2 2018-09-15 stsp /* If IDs match then don't bother with diffing. */
224 27d434c2 2018-09-15 stsp if (got_object_id_cmp(obj_id, pobj_id) == 0) {
226 27d434c2 2018-09-15 stsp err = cb(arg, blame->nlines, -1, id);
230 27d434c2 2018-09-15 stsp err = got_object_open(&pobj, repo, pobj_id);
234 15a94983 2018-12-23 stsp if (pobj->type != GOT_OBJ_TYPE_BLOB) {
236 404c43c4 2018-06-21 stsp * Encountered a non-blob at the path (probably a tree).
237 404c43c4 2018-06-21 stsp * Blob's history began in previous commit.
239 404c43c4 2018-06-21 stsp err = got_error(GOT_ERR_ITER_COMPLETED);
243 404c43c4 2018-06-21 stsp err = got_object_blob_open(&blob, repo, obj, 8192);
247 404c43c4 2018-06-21 stsp err = got_object_blob_open(&pblob, repo, pobj, 8192);
251 c35a7943 2018-07-12 stsp err = got_diff_blob_lines_changed(&changes, pblob, blob);
255 404c43c4 2018-06-21 stsp if (changes) {
256 c35a7943 2018-07-12 stsp err = blame_changes(blame, changes, id, cb, arg);
257 ce7f1bfe 2018-07-13 stsp got_diff_free_changes(changes);
258 d68a0a7d 2018-07-10 stsp } else if (cb)
259 3bf198ba 2018-07-10 stsp err = cb(arg, blame->nlines, -1, id);
261 27d434c2 2018-09-15 stsp free(obj_id);
262 27d434c2 2018-09-15 stsp free(pobj_id);
264 404c43c4 2018-06-21 stsp got_object_close(obj);
266 404c43c4 2018-06-21 stsp got_object_close(pobj);
268 404c43c4 2018-06-21 stsp got_object_blob_close(blob);
270 404c43c4 2018-06-21 stsp got_object_blob_close(pblob);
271 404c43c4 2018-06-21 stsp return err;
274 fb43ecf1 2019-02-11 stsp static const struct got_error *
275 404c43c4 2018-06-21 stsp blame_close(struct got_blame *blame)
277 fb43ecf1 2019-02-11 stsp const struct got_error *err = NULL;
278 c35a7943 2018-07-12 stsp struct got_blame_diff_offsets *diff_offsets;
280 fb43ecf1 2019-02-11 stsp if (blame->f && fclose(blame->f) != 0)
281 638f9024 2019-05-13 stsp err = got_error_from_errno("fclose");
282 404c43c4 2018-06-21 stsp free(blame->lines);
283 c35a7943 2018-07-12 stsp while (!SLIST_EMPTY(&blame->diff_offsets_list)) {
284 c35a7943 2018-07-12 stsp diff_offsets = SLIST_FIRST(&blame->diff_offsets_list);
285 c35a7943 2018-07-12 stsp SLIST_REMOVE_HEAD(&blame->diff_offsets_list, entry);
286 c35a7943 2018-07-12 stsp free_diff_offsets(diff_offsets);
288 404c43c4 2018-06-21 stsp free(blame);
289 fb43ecf1 2019-02-11 stsp return err;
292 404c43c4 2018-06-21 stsp static const struct got_error *
293 404c43c4 2018-06-21 stsp blame_open(struct got_blame **blamep, const char *path,
294 84451b3e 2018-07-10 stsp struct got_object_id *start_commit_id, struct got_repository *repo,
295 84451b3e 2018-07-10 stsp const struct got_error *(*cb)(void *, int, int, struct got_object_id *),
298 404c43c4 2018-06-21 stsp const struct got_error *err = NULL;
299 404c43c4 2018-06-21 stsp struct got_object *obj = NULL;
300 27d434c2 2018-09-15 stsp struct got_object_id *obj_id = NULL;
301 404c43c4 2018-06-21 stsp struct got_blob_object *blob = NULL;
302 404c43c4 2018-06-21 stsp struct got_blame *blame = NULL;
303 404c43c4 2018-06-21 stsp struct got_object_id *id = NULL;
304 404c43c4 2018-06-21 stsp int lineno;
305 293f6400 2018-09-20 stsp struct got_commit_graph *graph = NULL;
307 404c43c4 2018-06-21 stsp *blamep = NULL;
309 27d434c2 2018-09-15 stsp err = got_object_id_by_path(&obj_id, repo, start_commit_id, path);
311 404c43c4 2018-06-21 stsp return err;
313 27d434c2 2018-09-15 stsp err = got_object_open(&obj, repo, obj_id);
317 15a94983 2018-12-23 stsp if (obj->type != GOT_OBJ_TYPE_BLOB) {
318 404c43c4 2018-06-21 stsp err = got_error(GOT_ERR_OBJ_TYPE);
322 404c43c4 2018-06-21 stsp err = got_object_blob_open(&blob, repo, obj, 8192);
326 404c43c4 2018-06-21 stsp blame = calloc(1, sizeof(*blame));
327 404c43c4 2018-06-21 stsp if (blame == NULL)
328 638f9024 2019-05-13 stsp return got_error_from_errno("calloc");
330 404c43c4 2018-06-21 stsp blame->f = got_opentemp();
331 404c43c4 2018-06-21 stsp if (blame->f == NULL) {
332 638f9024 2019-05-13 stsp err = got_error_from_errno("got_opentemp");
335 6c4c42e0 2019-06-24 stsp err = got_object_blob_dump_to_file(&blame->filesize, &blame->nlines,
336 6c4c42e0 2019-06-24 stsp &blame->line_offsets, blame->f, blob);
340 404c43c4 2018-06-21 stsp blame->lines = calloc(blame->nlines, sizeof(*blame->lines));
341 404c43c4 2018-06-21 stsp if (blame->lines == NULL) {
342 638f9024 2019-05-13 stsp err = got_error_from_errno("calloc");
346 293f6400 2018-09-20 stsp err = got_commit_graph_open(&graph, start_commit_id, path, 0, repo);
348 293f6400 2018-09-20 stsp return err;
349 293f6400 2018-09-20 stsp err = got_commit_graph_iter_start(graph, start_commit_id, repo);
355 293f6400 2018-09-20 stsp struct got_object_id *next_id;
357 293f6400 2018-09-20 stsp err = got_commit_graph_iter_next(&next_id, graph);
359 293f6400 2018-09-20 stsp if (err->code == GOT_ERR_ITER_COMPLETED) {
360 404c43c4 2018-06-21 stsp err = NULL;
363 293f6400 2018-09-20 stsp if (err->code != GOT_ERR_ITER_NEED_MORE)
365 293f6400 2018-09-20 stsp err = got_commit_graph_fetch_commits(graph, 1, repo);
371 293f6400 2018-09-20 stsp if (next_id == NULL)
374 293f6400 2018-09-20 stsp err = blame_commit(blame, id, next_id, path, repo,
377 293f6400 2018-09-20 stsp if (err->code == GOT_ERR_ITER_COMPLETED)
378 293f6400 2018-09-20 stsp err = NULL;
381 06ca4d09 2018-11-19 stsp if (blame->nannotated == blame->nlines)
384 293f6400 2018-09-20 stsp id = next_id;
387 06ca4d09 2018-11-19 stsp if (id && blame->nannotated < blame->nlines) {
388 293f6400 2018-09-20 stsp /* Annotate remaining non-annotated lines with last commit. */
389 293f6400 2018-09-20 stsp for (lineno = 1; lineno <= blame->nlines; lineno++) {
390 293f6400 2018-09-20 stsp err = annotate_line(blame, lineno, id, cb, arg);
398 293f6400 2018-09-20 stsp got_commit_graph_close(graph);
399 27d434c2 2018-09-15 stsp free(obj_id);
401 404c43c4 2018-06-21 stsp got_object_close(obj);
403 404c43c4 2018-06-21 stsp got_object_blob_close(blob);
406 1828273a 2018-07-09 stsp blame_close(blame);
408 404c43c4 2018-06-21 stsp *blamep = blame;
410 404c43c4 2018-06-21 stsp return err;
413 404c43c4 2018-06-21 stsp static const struct got_error *
414 404c43c4 2018-06-21 stsp blame_line(struct got_object_id **id, struct got_blame *blame, int lineno)
416 404c43c4 2018-06-21 stsp if (lineno < 1 || lineno > blame->nlines)
417 404c43c4 2018-06-21 stsp return got_error(GOT_ERR_RANGE);
418 404c43c4 2018-06-21 stsp *id = &blame->lines[lineno - 1].id;
419 404c43c4 2018-06-21 stsp return NULL;
422 404c43c4 2018-06-21 stsp static char *
423 404c43c4 2018-06-21 stsp parse_next_line(FILE *f, size_t *len)
425 404c43c4 2018-06-21 stsp char *line;
426 404c43c4 2018-06-21 stsp size_t linelen;
427 404c43c4 2018-06-21 stsp size_t lineno;
428 404c43c4 2018-06-21 stsp const char delim[3] = { '\0', '\0', '\0'};
430 404c43c4 2018-06-21 stsp line = fparseln(f, &linelen, &lineno, delim, 0);
432 404c43c4 2018-06-21 stsp *len = linelen;
433 404c43c4 2018-06-21 stsp return line;
436 404c43c4 2018-06-21 stsp const struct got_error *
437 404c43c4 2018-06-21 stsp got_blame(const char *path, struct got_object_id *start_commit_id,
438 404c43c4 2018-06-21 stsp struct got_repository *repo, FILE *outfile)
440 fb43ecf1 2019-02-11 stsp const struct got_error *err = NULL, *close_err = NULL;
441 404c43c4 2018-06-21 stsp struct got_blame *blame;
442 404c43c4 2018-06-21 stsp int lineno;
443 404c43c4 2018-06-21 stsp char *abspath;
445 404c43c4 2018-06-21 stsp if (asprintf(&abspath, "%s%s", path[0] == '/' ? "" : "/", path) == -1)
446 638f9024 2019-05-13 stsp return got_error_from_errno2("asprintf", path);
448 84451b3e 2018-07-10 stsp err = blame_open(&blame, abspath, start_commit_id, repo, NULL, NULL);
450 404c43c4 2018-06-21 stsp free(abspath);
451 404c43c4 2018-06-21 stsp return err;
454 dd031dc0 2018-07-04 stsp for (lineno = 1; lineno <= blame->nlines; lineno++) {
455 404c43c4 2018-06-21 stsp struct got_object_id *id;
456 404c43c4 2018-06-21 stsp char *line, *id_str;
458 404c43c4 2018-06-21 stsp line = parse_next_line(blame->f, NULL);
459 404c43c4 2018-06-21 stsp if (line == NULL)
462 404c43c4 2018-06-21 stsp err = blame_line(&id, blame, lineno);
464 d4af3990 2018-07-13 stsp free(line);
468 404c43c4 2018-06-21 stsp err = got_object_id_str(&id_str, id);
469 58c811c5 2018-07-13 stsp /* Do not free id; It points into blame->lines. */
471 404c43c4 2018-06-21 stsp free(line);
475 404c43c4 2018-06-21 stsp fprintf(outfile, "%.8s %s\n", id_str, line);
476 404c43c4 2018-06-21 stsp free(line);
477 404c43c4 2018-06-21 stsp free(id_str);
480 fb43ecf1 2019-02-11 stsp close_err = blame_close(blame);
481 404c43c4 2018-06-21 stsp free(abspath);
482 fb43ecf1 2019-02-11 stsp return err ? err : close_err;
485 84451b3e 2018-07-10 stsp const struct got_error *
486 84451b3e 2018-07-10 stsp got_blame_incremental(const char *path, struct got_object_id *commit_id,
487 84451b3e 2018-07-10 stsp struct got_repository *repo,
488 84451b3e 2018-07-10 stsp const struct got_error *(*cb)(void *, int, int, struct got_object_id *),
491 fb43ecf1 2019-02-11 stsp const struct got_error *err = NULL, *close_err = NULL;
492 84451b3e 2018-07-10 stsp struct got_blame *blame;
493 84451b3e 2018-07-10 stsp char *abspath;
495 84451b3e 2018-07-10 stsp if (asprintf(&abspath, "%s%s", path[0] == '/' ? "" : "/", path) == -1)
496 638f9024 2019-05-13 stsp return got_error_from_errno2("asprintf", path);
498 84451b3e 2018-07-10 stsp err = blame_open(&blame, abspath, commit_id, repo, cb, arg);
499 84451b3e 2018-07-10 stsp free(abspath);
501 fb43ecf1 2019-02-11 stsp close_err = blame_close(blame);
502 fb43ecf1 2019-02-11 stsp return err ? err : close_err;