* [PATCH] Add trailing ellipsis to commits with body content
@ 2019-02-23 6:03 kevr.gtalk
0 siblings, 0 replies; only message in thread
From: kevr.gtalk @ 2019-02-23 6:03 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-02-23 6:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-23 6:03 [PATCH] Add trailing ellipsis to commits with body content kevr.gtalk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).