Commit 24ea5512e058a018fb480a73576e051ee37991ff

Stefan Sperling 2019-08-22T14:26:00

make 'got cat' show raw log messages, i.e. leaving PGP sigs intact

diff --git a/got/got.c b/got/got.c
index 0b3586f..fac5ad8 100644
--- a/got/got.c
+++ b/got/got.c
@@ -6024,7 +6024,7 @@ cat_commit(struct got_object_id *id, struct got_repository *repo, FILE *outfile)
 	const struct got_object_id_queue *parent_ids;
 	struct got_object_qid *pid;
 	char *id_str = NULL;
-	char *logmsg = NULL;
+	const char *logmsg = NULL;
 	int i;
 
 	err = got_object_open_as_commit(&commit, repo, id);
@@ -6058,12 +6058,11 @@ cat_commit(struct got_object_id *id, struct got_repository *repo, FILE *outfile)
 	fprintf(outfile, "committer-time: %lld\n",
 	    got_object_commit_get_committer_time(commit));
 
-	err = got_object_commit_get_logmsg(&logmsg, commit);
+	logmsg = got_object_commit_get_logmsg_raw(commit);
 	fprintf(outfile, "log-message: %zd bytes\n", strlen(logmsg));
 	fprintf(outfile, "%s", logmsg);
 done:
 	free(id_str);
-	free(logmsg);
 	got_object_commit_close(commit);
 	return err;
 }
diff --git a/include/got_object.h b/include/got_object.h
index ceae59c..37d13ae 100644
--- a/include/got_object.h
+++ b/include/got_object.h
@@ -138,10 +138,17 @@ time_t got_object_commit_get_committer_time(struct got_commit_object *);
 /* Get a committer's timezone offset. */
 time_t got_object_commit_get_committer_gmtoff(struct got_commit_object *);
 
-/* Get the commit log message. The caller must dispose of it with free(3). */
+/*
+ * Get the commit log message.
+ * PGP-signatures contained in the log message will be stripped.
+ * The caller must dispose of it with free(3).
+ */
 const struct got_error *got_object_commit_get_logmsg(char **,
     struct got_commit_object *);
 
+/* Get the raw commit log message.*/
+const char *got_object_commit_get_logmsg_raw(struct got_commit_object *);
+
 /*
  * Attempt to open a tree object in a repository.
  * The caller must dispose of the tree with got_object_tree_close().
diff --git a/lib/object_parse.c b/lib/object_parse.c
index bf2e9f2..8a94189 100644
--- a/lib/object_parse.c
+++ b/lib/object_parse.c
@@ -480,6 +480,12 @@ done:
 	return err;
 }
 
+const char *
+got_object_commit_get_logmsg_raw(struct got_commit_object *commit)
+{
+	return commit->logmsg;
+}
+
 const struct got_error *
 got_object_parse_commit(struct got_commit_object **commit, char *buf,
     size_t len)