List for cgit developers and users
 help / color / mirror / Atom feed
From: kevr.gtalk at gmail.com (Kevin Morris)
Subject: [PATCH] Add trailing ellipsis to commits with body content
Date: Fri, 22 Feb 2019 22:03:10 -0800	[thread overview]
Message-ID: <20190223060310.8736-1-kevr.gtalk@gmail.com> (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



                 reply	other threads:[~2019-02-23  6:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190223060310.8736-1-kevr.gtalk@gmail.com \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).