Merge branch 'full-log'

Conflicts:
	cgit.c
	cgit.h
This commit is contained in:
Lars Hjemli 2008-12-06 11:37:37 +01:00
commit 3c32fe0771
9 changed files with 61 additions and 13 deletions

2
cgit.c
View File

@ -156,6 +156,8 @@ static void querystring_cb(const char *name, const char *value)
ctx.qry.mimetype = xstrdup(value); ctx.qry.mimetype = xstrdup(value);
} else if (!strcmp(name, "s")){ } else if (!strcmp(name, "s")){
ctx.qry.sort = xstrdup(value); ctx.qry.sort = xstrdup(value);
} else if (!strcmp(name, "showmsg")) {
ctx.qry.showmsg = atoi(value);
} }
} }

View File

@ -120,6 +120,10 @@ table.list tr {
background: white; background: white;
} }
table.list tr.logheader {
background: #eee;
}
table.list tr:hover { table.list tr:hover {
background: #eee; background: #eee;
} }
@ -143,6 +147,17 @@ table.list td {
padding: 0.1em 0.5em 0.1em 0.5em; padding: 0.1em 0.5em 0.1em 0.5em;
} }
table.list td.logsubject {
font-family: monospace;
font-weight: bold;
}
table.list td.logmsg {
font-family: monospace;
white-space: pre;
padding: 1em 0em 2em 0em;
}
table.list td a { table.list td a {
color: black; color: black;
} }

1
cgit.h
View File

@ -123,6 +123,7 @@ struct cgit_query {
int ofs; int ofs;
int nohead; int nohead;
char *sort; char *sort;
int showmsg;
}; };
struct cgit_config { struct cgit_config {

View File

@ -35,15 +35,18 @@ void print_commit(struct commit *commit)
{ {
struct commitinfo *info; struct commitinfo *info;
char *tmp; char *tmp;
int cols = 2;
info = cgit_parse_commit(commit); info = cgit_parse_commit(commit);
html("<tr><td>"); htmlf("<tr%s><td>",
ctx.qry.showmsg ? " class='logheader'" : "");
tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1)); tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1));
tmp = cgit_pageurl(ctx.repo->url, "commit", tmp); tmp = cgit_pageurl(ctx.repo->url, "commit", tmp);
html_link_open(tmp, NULL, NULL); html_link_open(tmp, NULL, NULL);
cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE);
html_link_close(); html_link_close();
html("</td><td>"); htmlf("</td><td%s>",
ctx.qry.showmsg ? " class='logsubject'" : "");
cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
sha1_to_hex(commit->object.sha1)); sha1_to_hex(commit->object.sha1));
html("</td><td>"); html("</td><td>");
@ -61,6 +64,17 @@ void print_commit(struct commit *commit)
} }
} }
html("</td></tr>\n"); html("</td></tr>\n");
if (ctx.qry.showmsg) {
if (ctx.repo->enable_log_filecount) {
cols++;
if (ctx.repo->enable_log_linecount)
cols++;
}
htmlf("<tr class='nohover'><td/><td colspan='%d' class='logmsg'>",
cols);
html_txt(info->msg);
html("</td></tr>\n");
}
cgit_free_commitinfo(info); cgit_free_commitinfo(info);
} }
@ -113,8 +127,15 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
html("<table class='list nowrap'>"); html("<table class='list nowrap'>");
html("<tr class='nohover'><th class='left'>Age</th>" html("<tr class='nohover'><th class='left'>Age</th>"
"<th class='left'>Commit message</th>" "<th class='left'>Commit message");
"<th class='left'>Author</th>"); if (pager) {
html(" (");
cgit_log_link("toggle", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
ctx.qry.path, ctx.qry.ofs, ctx.qry.grep,
ctx.qry.search, ctx.qry.showmsg ? 0 : 1);
html(")");
}
html("</th><th class='left'>Author</th>");
if (ctx.repo->enable_log_filecount) { if (ctx.repo->enable_log_filecount) {
html("<th class='left'>Files</th>"); html("<th class='left'>Files</th>");
columns++; columns++;
@ -149,20 +170,20 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, cgit_log_link("[prev]", NULL, NULL, ctx.qry.head,
ctx.qry.sha1, ctx.qry.path, ctx.qry.sha1, ctx.qry.path,
ofs - cnt, ctx.qry.grep, ofs - cnt, ctx.qry.grep,
ctx.qry.search); ctx.qry.search, ctx.qry.showmsg);
html("&nbsp;"); html("&nbsp;");
} }
if ((commit = get_revision(&rev)) != NULL) { if ((commit = get_revision(&rev)) != NULL) {
cgit_log_link("[next]", NULL, NULL, ctx.qry.head, cgit_log_link("[next]", NULL, NULL, ctx.qry.head,
ctx.qry.sha1, ctx.qry.path, ctx.qry.sha1, ctx.qry.path,
ofs + cnt, ctx.qry.grep, ofs + cnt, ctx.qry.grep,
ctx.qry.search); ctx.qry.search, ctx.qry.showmsg);
} }
html("</div>"); html("</div>");
} else if ((commit = get_revision(&rev)) != NULL) { } else if ((commit = get_revision(&rev)) != NULL) {
html("<tr class='nohover'><td colspan='3'>"); html("<tr class='nohover'><td colspan='3'>");
cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0, cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0,
NULL, NULL); NULL, NULL, ctx.qry.showmsg);
html("</td></tr>\n"); html("</td></tr>\n");
} }
} }

View File

@ -58,7 +58,8 @@ static int print_branch(struct refinfo *ref)
if (!info) if (!info)
return 1; return 1;
html("<tr><td>"); html("<tr><td>");
cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0, NULL, NULL); cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0, NULL, NULL,
ctx.qry.showmsg);
html("</td><td>"); html("</td><td>");
if (ref->object->type == OBJ_COMMIT) { if (ref->object->type == OBJ_COMMIT) {

View File

@ -257,7 +257,7 @@ void cgit_print_repolist()
html("<td>"); html("<td>");
cgit_summary_link("summary", NULL, "button", NULL); cgit_summary_link("summary", NULL, "button", NULL);
cgit_log_link("log", NULL, "button", NULL, NULL, NULL, cgit_log_link("log", NULL, "button", NULL, NULL, NULL,
0, NULL, NULL); 0, NULL, NULL, ctx.qry.showmsg);
cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL); cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL);
html("</td>"); html("</td>");
} }

View File

@ -281,7 +281,8 @@ void cgit_plain_link(char *name, char *title, char *class, char *head,
} }
void cgit_log_link(char *name, char *title, char *class, char *head, void cgit_log_link(char *name, char *title, char *class, char *head,
char *rev, char *path, int ofs, char *grep, char *pattern) char *rev, char *path, int ofs, char *grep, char *pattern,
int showmsg)
{ {
char *delim; char *delim;
@ -305,6 +306,11 @@ void cgit_log_link(char *name, char *title, char *class, char *head,
html(delim); html(delim);
html("ofs="); html("ofs=");
htmlf("%d", ofs); htmlf("%d", ofs);
delim = "&";
}
if (showmsg) {
html(delim);
html("showmsg=1");
} }
html("'>"); html("'>");
html_txt(name); html_txt(name);
@ -570,6 +576,8 @@ void add_hidden_formfields(int incl_head, int incl_search, char *page)
html_hidden("id", ctx.qry.sha1); html_hidden("id", ctx.qry.sha1);
if (ctx.qry.sha2) if (ctx.qry.sha2)
html_hidden("id2", ctx.qry.sha2); html_hidden("id2", ctx.qry.sha2);
if (ctx.qry.showmsg)
html_hidden("showmsg", "1");
if (incl_search) { if (incl_search) {
if (ctx.qry.grep) if (ctx.qry.grep)
@ -636,7 +644,7 @@ void cgit_print_pageheader(struct cgit_context *ctx)
cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head,
ctx->qry.sha1, NULL); ctx->qry.sha1, NULL);
cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head, cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head,
NULL, NULL, 0, NULL, NULL); NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg);
cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head, cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head,
ctx->qry.sha1, NULL); ctx->qry.sha1, NULL);
cgit_commit_link("commit", NULL, hc(cmd, "commit"), cgit_commit_link("commit", NULL, hc(cmd, "commit"),

View File

@ -19,7 +19,7 @@ extern void cgit_plain_link(char *name, char *title, char *class, char *head,
char *rev, char *path); char *rev, char *path);
extern void cgit_log_link(char *name, char *title, char *class, char *head, extern void cgit_log_link(char *name, char *title, char *class, char *head,
char *rev, char *path, int ofs, char *grep, char *rev, char *path, int ofs, char *grep,
char *pattern); char *pattern, int showmsg);
extern void cgit_commit_link(char *name, char *title, char *class, char *head, extern void cgit_commit_link(char *name, char *title, char *class, char *head,
char *rev); char *rev);
extern void cgit_patch_link(char *name, char *title, char *class, char *head, extern void cgit_patch_link(char *name, char *title, char *class, char *head,

View File

@ -106,7 +106,7 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
html("<td>"); html("<td>");
cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev, cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev,
fullpath, 0, NULL, NULL); fullpath, 0, NULL, NULL, ctx.qry.showmsg);
html("</td></tr>\n"); html("</td></tr>\n");
free(name); free(name);
return 0; return 0;