make got_diff_objects_as_commits() require obj2 parameter
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
diff --git a/lib/diff.c b/lib/diff.c
index b46cb06..f3a09e4 100644
--- a/lib/diff.c
+++ b/lib/diff.c
@@ -506,8 +506,9 @@ got_diff_objects_as_commits(struct got_object *obj1, struct got_object *obj2,
const struct got_error *err;
struct got_commit_object *commit1 = NULL, *commit2 = NULL;
struct got_object *tree_obj1 = NULL, *tree_obj2 = NULL;
+ char *id_str;
- if (obj1 == NULL && obj2 == NULL)
+ if (obj2 == NULL)
return got_error(GOT_ERR_NO_OBJ);
if (obj1) {
@@ -518,25 +519,23 @@ got_diff_objects_as_commits(struct got_object *obj1, struct got_object *obj2,
if (err)
goto done;
}
- if (obj2) {
- char *id_str;
- err = got_object_commit_open(&commit2, repo, obj2);
- if (err)
- goto done;
- err = got_object_open(&tree_obj2, repo, commit2->tree_id);
- if (err)
- goto done;
- err = got_object_get_id_str(&id_str, obj2);
- if (err)
- goto done;
- fprintf(outfile, "commit: %s\n", id_str);
- free(id_str);
- fprintf(outfile, "author: %s\n", commit2->author);
- if (strcmp(commit2->author, commit2->committer) != 0)
- fprintf(outfile, "committer: %s\n", commit2->committer);
- fprintf(outfile, "\n%s\n", commit2->logmsg);
- }
+ err = got_object_commit_open(&commit2, repo, obj2);
+ if (err)
+ goto done;
+ err = got_object_open(&tree_obj2, repo, commit2->tree_id);
+ if (err)
+ goto done;
+ err = got_object_get_id_str(&id_str, obj2);
+ if (err)
+ goto done;
+ fprintf(outfile, "commit: %s\n", id_str);
+ free(id_str);
+ fprintf(outfile, "author: %s\n", commit2->author);
+ if (strcmp(commit2->author, commit2->committer) != 0)
+ fprintf(outfile, "committer: %s\n", commit2->committer);
+ fprintf(outfile, "\n%s\n", commit2->logmsg);
+
err = got_diff_objects_as_trees(tree_obj1, tree_obj2, repo, outfile);
done:
if (tree_obj1)