From c2bfd40f8aaaa69a66c6eb729c202e42a43ec166 Mon Sep 17 00:00:00 2001 From: Johan Herland Date: Mon, 15 Nov 2010 18:39:53 +0100 Subject: ui-log: Move 'Age' column when commit graph is present When the commit graph is present, we prefer to draw it along the left edge, and moving the 'Age' column to the right of the 'Author' column, like in gitk. Signed-off-by: Johan Herland Signed-off-by: Lars Hjemli --- ui-log.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/ui-log.c b/ui-log.c index 05b5c29..8add66a 100644 --- a/ui-log.c +++ b/ui-log.c @@ -96,7 +96,7 @@ void print_commit(struct commit *commit, struct rev_info *revs) { struct commitinfo *info; char *tmp; - int cols = 2; + int cols = revs->graph ? 3 : 2; struct strbuf graphbuf = STRBUF_INIT; struct strbuf msgbuf = STRBUF_INIT; @@ -110,7 +110,7 @@ void print_commit(struct commit *commit, struct rev_info *revs) /* Advance graph until current commit */ while (!graph_next_line(revs->graph, &graphbuf)) { /* Print graph segment in otherwise empty table row */ - html(""); + html(""); html(graphbuf.buf); htmlf("\n", cols); strbuf_setlen(&graphbuf, 0); @@ -119,14 +119,7 @@ void print_commit(struct commit *commit, struct rev_info *revs) } info = cgit_parse_commit(commit); - htmlf("", - ctx.qry.showmsg ? " class='logheader'" : ""); - tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1)); - tmp = cgit_fileurl(ctx.repo->url, "commit", ctx.qry.vpath, tmp); - html_link_open(tmp, NULL, NULL); - cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); - html_link_close(); - html(""); + htmlf("", ctx.qry.showmsg ? " class='logheader'" : ""); if (revs->graph) { /* Print graph segment for current commit */ @@ -135,6 +128,15 @@ void print_commit(struct commit *commit, struct rev_info *revs) html(""); strbuf_setlen(&graphbuf, 0); } + else { + html(""); + tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1)); + tmp = cgit_fileurl(ctx.repo->url, "commit", ctx.qry.vpath, tmp); + html_link_open(tmp, NULL, NULL); + cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); + html_link_close(); + html(""); + } htmlf("", ctx.qry.showmsg ? " class='logsubject'" : ""); if (ctx.qry.showmsg) { @@ -167,6 +169,16 @@ void print_commit(struct commit *commit, struct rev_info *revs) show_commit_decorations(commit); html(""); html_txt(info->author); + + if (revs->graph) { + html(""); + tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1)); + tmp = cgit_fileurl(ctx.repo->url, "commit", ctx.qry.vpath, tmp); + html_link_open(tmp, NULL, NULL); + cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); + html_link_close(); + } + if (ctx.repo->enable_log_filecount) { files = 0; add_lines = 0; @@ -182,7 +194,7 @@ void print_commit(struct commit *commit, struct rev_info *revs) html("\n"); if (revs->graph || ctx.qry.showmsg) { /* Print a second table row */ - html(""); /* Empty 'Age' column */ + html(""); if (ctx.qry.showmsg) { /* Concatenate commit message + notes in msgbuf */ @@ -223,6 +235,8 @@ void print_commit(struct commit *commit, struct rev_info *revs) } html("\n"); } + else + html(""); /* Empty 'Age' column */ /* Print msgbuf into remainder of table row */ htmlf("\n", cols, @@ -345,9 +359,11 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern if (pager) html(""); - html(""); + html(""); if (commit_graph) html(""); + else + html(""); html(""); + if (commit_graph) + html(""); if (ctx.repo->enable_log_filecount) { html(""); columns++; -- cgit
Age
AgeCommit message"); if (pager) { html(" ("); @@ -358,6 +374,8 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern html(")"); } html("AuthorAgeFiles