make 'got cat' show raw log messages, i.e. leaving PGP sigs intact
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 58 59 60 61 62 63 64 65 66 67
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)