simplify blame_open(): pcommit is not required
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
diff --git a/lib/blame.c b/lib/blame.c
index 27c02f1..45a62df 100644
--- a/lib/blame.c
+++ b/lib/blame.c
@@ -243,31 +243,28 @@ blame_open(struct got_blame **blamep, const char *path,
}
while (1) {
struct got_object_qid *pid;
- struct got_commit_object *pcommit;
pid = SIMPLEQ_FIRST(&commit->parent_ids);
if (pid == NULL)
break;
- err = got_object_open_as_commit(&pcommit, repo, pid->id);
- if (err)
- break;
-
err = blame_commit(blame, id, pid->id, path, repo);
if (err) {
if (err->code == GOT_ERR_ITER_COMPLETED)
err = NULL;
- got_object_commit_close(pcommit);
break;
}
+
free(id);
id = got_object_id_dup(pid->id);
- got_object_commit_close(commit);
- commit = pcommit;
if (id == NULL) {
err = got_error_from_errno();
goto done;
}
+ got_object_commit_close(commit);
+ err = got_object_open_as_commit(&commit, repo, id);
+ if (err)
+ break;
}
/* Annotate remaining non-annotated lines with last commit. */