commit - bacc99353dcb86d36bf8ffe0f99e0a47984b3bc7
commit + 9b6978794ceef93ae5f616c11f62b66c71038c43
blob - b46cb06e829d3c06ce5d01dcf1ebd68f0be7c2d0
blob + f3a09e4ad8f59d8af7ddee44566442c0bf640d57
--- lib/diff.c
+++ lib/diff.c
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) {
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)