Commit Diff


commit - b74c76254a0262d7eca704ebdb9e3bbb1d6fecb2
commit + bacc99353dcb86d36bf8ffe0f99e0a47984b3bc7
blob - 2c9c8f8dabffa1ff8cf97e599093f4b2b60e3049
blob + 54d808ec2c08ac0e57c12400068fb20edd2302b2
--- include/got_object.h
+++ include/got_object.h
@@ -80,6 +80,12 @@ struct got_object_id *got_object_id_dup(struct got_obj
 struct got_object_id *got_object_get_id(struct got_object *);
 
 /*
+ * Get a newly allocated copy of an object's ID string.
+ * The caller should dispose of it with free(3).
+ */
+const struct got_error *got_object_get_id_str(char **, struct got_object *);
+
+/*
  * Obtain the type of an object.
  * Returns one of the GOT_OBJ_TYPE_x values (see above).
  */
blob - 6d774945f4b0453d42901b53c79698525b6932f9
blob + b46cb06e829d3c06ce5d01dcf1ebd68f0be7c2d0
--- lib/diff.c
+++ lib/diff.c
@@ -519,12 +519,23 @@ got_diff_objects_as_commits(struct got_object *obj1, s
 			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_diff_objects_as_trees(tree_obj1, tree_obj2, repo, outfile);
 done:
blob - 45d21d4d24881d81b51e3afb2be011038e6c143f
blob + fd3ef97d777386e079ab697ef1959196c6ac765e
--- lib/object.c
+++ lib/object.c
@@ -103,6 +103,12 @@ struct got_object_id *
 got_object_get_id(struct got_object *obj)
 {
 	return got_object_id_dup(&obj->id);
+}
+
+const struct got_error *
+got_object_get_id_str(char **outbuf, struct got_object *obj)
+{
+	return got_object_id_str(outbuf, &obj->id);
 }
 
 int