indent log messages in output of 'got log'
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
diff --git a/got/got.c b/got/got.c
index aaa7c0a..df469a9 100644
--- a/got/got.c
+++ b/got/got.c
@@ -309,18 +309,29 @@ print_commit(struct got_commit_object *commit, struct got_object_id *id,
struct got_repository *repo, int show_patch)
{
const struct got_error *err = NULL;
- char *buf;
+ char *id_str, *logmsg, *line;
- err = got_object_id_str(&buf, id);
+ err = got_object_id_str(&id_str, id);
if (err)
return err;
printf("-----------------------------------------------\n");
- printf("commit %s\n", buf);
+ printf("commit %s\n", id_str);
+ free(id_str);
printf("author: %s\n", commit->author);
if (strcmp(commit->author, commit->committer) != 0)
printf("committer: %s\n", commit->committer);
- printf("\n%s\n", commit->logmsg);
+
+ logmsg = strdup(commit->logmsg);
+ if (logmsg == NULL)
+ return got_error_from_errno();
+
+ do {
+ line = strsep(&logmsg, "\n");
+ if (line)
+ printf(" %s\n", line);
+ } while (line);
+ free(logmsg);
if (show_patch) {
err = print_patch(commit, id, repo);
@@ -328,7 +339,6 @@ print_commit(struct got_commit_object *commit, struct got_object_id *id,
printf("\n");
}
- free(buf);
return err;
}