git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[CGit RFC/PATCH 3/5] ui-log: Refactor display of commit messages

From
Johan Herland <johan@herland.net>
Date
Jul 13, 2010, 21:40 UTC
Message-ID
<1279057221-28036-4-git-send-email-johan@herland.net>
In-Reply-To
<1279056219-27096-1-git-send-email-johan@herland.net>

Split new function print_commit_line() out of print_commit(). The new function only prints the initial table cells containing commit metadata, i.e. the commit subject, author and date (and file/line-count if enabled).

The printing of the rest of the commit message (when showmsg is enabled) is still performed in print_commit(), but is slightly changed to use additional newlines to achieve the vertical margins that were previously implemented with CSS. This is in preparation for the commit graph which will be printed to the left of the commit message as part of the same table row, and therefore needs to minimize margins that would otherwise cause ugly gaps in the graph.

Signed-off-by: Johan Herland <johan@herland.net>
---
 cgit.css |    2 +-
 ui-log.c |   38 +++++++++++++++++++++++++-------------
 2 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/cgit.css b/cgit.css
index 6e47eb3..78f654e 100644
--- a/cgit.css
+++ b/cgit.css
@@ -161,7 +161,7 @@ table.list td.logsubject {
 table.list td.logmsg {
 	font-family: monospace;
 	white-space: pre;
-	padding: 1em 0.5em 2em 0.5em;
+	padding: 0 0.5em;
 }
 
 table.list td a {
diff --git a/ui-log.c b/ui-log.c
index 390c38b..2cd0f19 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -75,14 +75,10 @@ void show_commit_decorations(struct commit *commit)
 	}
 }
 
-void print_commit(struct commit *commit)
+static void print_commit_line(struct commit *commit, struct commitinfo *info)
 {
-	struct commitinfo *info;
 	char *tmp;
-	int cols = 3;
 
-	info = cgit_parse_commit(commit);
-	htmlf("<tr%s>", ctx.qry.showmsg ? " class='logheader'" : "");
 	htmlf("<td%s>", ctx.qry.showmsg ? " class='logsubject'" : "");
 	cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
 			 sha1_to_hex(commit->object.sha1), ctx.qry.vpath, 0);
@@ -107,18 +103,34 @@ void print_commit(struct commit *commit)
 			htmlf("-%d/+%d", rem_lines, add_lines);
 		}
 	}
-	html("</td></tr>\n");
-	if (ctx.qry.showmsg) {
-		if (ctx.repo->enable_log_filecount) {
+	html("</td>");
+}
+
+void print_commit(struct commit *commit)
+{
+	struct commitinfo *info = cgit_parse_commit(commit);
+	int cols = 3;
+
+	if (ctx.repo->enable_log_filecount) {
+		cols++;
+		if (ctx.repo->enable_log_linecount)
 			cols++;
-			if (ctx.repo->enable_log_linecount)
-				cols++;
+	}
+
+	htmlf("<tr%s>", ctx.qry.showmsg ? " class='logheader'" : "");
+	print_commit_line(commit, info);
+	html("</tr>\n");
+
+	if (ctx.qry.showmsg) {
+		html("<tr class='nohover'>");
+		htmlf("<td colspan='%d' class='logmsg'>\n", cols);
+		if (*(info->msg)) {
+			html_txt(info->msg);
+			html("\n\n");
 		}
-		htmlf("<tr class='nohover'><td colspan='%d' class='logmsg'>",
-			cols);
-		html_txt(info->msg);
 		html("</td></tr>\n");
 	}
+
 	cgit_free_commitinfo(info);
 }
 
-- 
1.7.0.4
Previous: Johan HerlandNext: Johan Herland
Message 10 of 12 in “Preparing the graph API for external users”
  1. 0/2 Preparing the graph API for external usersJohan Herland, Jul 13, 2010
  2. 1/2 Make graph_next_line() available in the graph.h APIJohan Herland, Jul 13, 2010
  3. 2/2 Enable custom schemes for column colors in the graph APIJohan Herland, Jul 13, 2010
  4. 0/5 Commit graph on CGit's 'log' viewJohan Herland, Jul 13, 2010
  5. Lars HjemliJul 13, 2010
  6. Johan HerlandJul 14, 2010
  7. Lars HjemliJul 18, 2010
  8. 1/5 ui-stats: Remove unnecessary #includeJohan Herland, Jul 13, 2010
  9. 2/5 ui-log: Move 'Age' column to the right of 'Author', like in gitkJohan Herland, Jul 13, 2010
  10. 3/5 ui-log: Refactor display of commit messagesJohan Herland, Jul 13, 2010
  11. 4/5 ui-log: Implement support for commit graphsJohan Herland, Jul 13, 2010
  12. 5/5 ui-log: Colorize commit graphJohan Herland, Jul 13, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.