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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]