Commit Diff


commit - 67c4c153acf0aeb91d39ea45524663e032ab2fe6
commit + 75b7a700d9d14ef8eb902961255212acbedef164
blob - 1a2d03cda24f7afe7ef3cb27b7b9683cbf87fe65
blob + c57eaabaef3b116c178390d76ee554ebbb2e16e9
--- lib/blame.c
+++ lib/blame.c
@@ -345,6 +345,7 @@ got_blame_incremental(const char *path, struct got_obj
 
 	err = blame_open(&blame, abspath, commit_id, repo, cb, arg);
 	free(abspath);
-	blame_close(blame);
+	if (err == NULL)
+		blame_close(blame);
 	return err;
 }
blob - 4404ee43ec1521f107a9d8924d5d1c0b20c921cd
blob + 581999675170afab7819c5cb96bad859a29b2545
--- tog/tog.c
+++ tog/tog.c
@@ -1125,6 +1125,7 @@ struct tog_blame_cb_args {
 	WINDOW *window;
 	int *first_displayed_line;
 	int *last_displayed_line;
+	int *done;
 };
 
 static const struct got_error *
@@ -1134,6 +1135,9 @@ blame_cb(void *arg, int nlines, int lineno, struct got
 	struct tog_blame_cb_args *a = arg;
 	struct tog_blame_line *line;
 	int eof;
+
+	if (*a->done)
+		return got_error(GOT_ERR_ITER_COMPLETED);
 
 	if (nlines != a->nlines || lineno < 1 || lineno > a->nlines)
 		return got_error(GOT_ERR_RANGE);
@@ -1241,6 +1245,7 @@ show_blame_view(const char *path, struct got_object_id
 	blame_cb_args.window = tog_blame_view.window;
 	blame_cb_args.first_displayed_line = &first_displayed_line;
 	blame_cb_args.last_displayed_line = &last_displayed_line;
+	blame_cb_args.done = &done;
 
 	blame_thread_args.path = path;
 	blame_thread_args.commit_id = commit_id;
@@ -1318,6 +1323,8 @@ done:
 	if (thread) {
 		if (pthread_join(thread, (void **)&err) != 0)
 			err = got_error_from_errno();
+		if (err && err->code == GOT_ERR_ITER_COMPLETED)
+			err = NULL;
 	}
 	if (blob)
 		got_object_blob_close(blob);