[PATCH] Add trailing ellipsis to commits with body content

Kevin Morris kevr.gtalk at gmail.com
Sat Feb 23 07:03:10 CET 2019


Add ellipsis to each short commit subject where its body contains
some user-input data (excluding vanilla Signed-off-by -sm messages)

Signed-off-by: Kevin Morris <kevr.gtalk at gmail.com>
---
 ui-log.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/ui-log.c b/ui-log.c
index 3bcb657..202aa55 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -237,8 +237,25 @@ static void print_commit(struct commit *commit, struct rev_info *revs)
 			strlcpy(info->subject + i, wrap_symbol, subject_len - i + 1);
 		}
 	}
-	cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
+
+	char *subject = NULL;
+	size_t subject_len = strlen(info->subject);
+	char *msg = info->msg;
+	const char signed_off[] = "Signed-off-by";
+	if(strncmp(signed_off, msg, strlen(signed_off)) == 0) {
+		subject = calloc(subject_len + 2, sizeof(char));
+		snprintf(subject, subject_len + 1, "%s", info->subject);
+	} else if(strlen(info->msg) > 0) {
+		// Ellipsis here
+		subject = calloc(subject_len + 5 + 1, sizeof(char));
+		snprintf(subject, subject_len + 5, "%s ...", info->subject); 
+	} else {
+		subject = calloc(subject_len + 2, sizeof(char));
+		snprintf(subject, subject_len + 1, "%s", info->subject);
+	}
+	cgit_commit_link(subject, NULL, NULL, ctx.qry.head,
 			 oid_to_hex(&commit->object.oid), ctx.qry.vpath);
+	free(subject);
 	show_commit_decorations(commit);
 	html("</td><td>");
 	cgit_open_filter(ctx.repo->email_filter, info->author_email, "log");
-- 
2.20.1



More information about the CGit mailing list