2006-12-11 17:04:19 +01:00
|
|
|
/* ui-log.c: functions for log output
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Lars Hjemli
|
|
|
|
*
|
|
|
|
* Licensed under GNU General Public License v2
|
|
|
|
* (see COPYING for full license text)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "cgit.h"
|
|
|
|
|
2006-12-15 18:17:36 +01:00
|
|
|
void print_commit(struct commit *commit)
|
2006-12-11 17:04:19 +01:00
|
|
|
{
|
|
|
|
char buf[32];
|
2006-12-15 18:17:36 +01:00
|
|
|
struct commitinfo *info;
|
|
|
|
struct tm *time;
|
2006-12-11 17:04:19 +01:00
|
|
|
|
2006-12-15 18:17:36 +01:00
|
|
|
info = cgit_parse_commit(commit);
|
|
|
|
time = gmtime(&commit->date);
|
2006-12-11 17:04:19 +01:00
|
|
|
html("<tr><td>");
|
|
|
|
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time);
|
|
|
|
html_txt(buf);
|
|
|
|
html("</td><td>");
|
|
|
|
char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1));
|
2006-12-16 00:19:56 +01:00
|
|
|
char *url = cgit_pageurl(cgit_query_repo, "commit", qry);
|
2006-12-11 17:04:19 +01:00
|
|
|
html_link_open(url, NULL, NULL);
|
2007-01-28 12:17:03 +01:00
|
|
|
html_ntxt(cgit_max_msg_len, info->subject);
|
2006-12-11 17:04:19 +01:00
|
|
|
html_link_close();
|
|
|
|
html("</td><td>");
|
2006-12-15 18:17:36 +01:00
|
|
|
html_txt(info->author);
|
2006-12-11 17:04:19 +01:00
|
|
|
html("</td></tr>\n");
|
2006-12-16 14:58:20 +01:00
|
|
|
cgit_free_commitinfo(info);
|
2006-12-11 17:04:19 +01:00
|
|
|
}
|
|
|
|
|
2006-12-15 18:17:36 +01:00
|
|
|
|
2006-12-28 02:45:28 +01:00
|
|
|
void cgit_print_log(const char *tip, int ofs, int cnt, char *grep)
|
2006-12-11 17:04:19 +01:00
|
|
|
{
|
|
|
|
struct rev_info rev;
|
|
|
|
struct commit *commit;
|
2006-12-28 02:45:28 +01:00
|
|
|
const char *argv[3] = {NULL, tip, NULL};
|
|
|
|
int argc = 2;
|
2006-12-14 00:40:34 +01:00
|
|
|
int i;
|
2006-12-11 17:04:19 +01:00
|
|
|
|
2006-12-28 02:45:28 +01:00
|
|
|
if (grep)
|
|
|
|
argv[argc++] = fmt("--grep=%s", grep);
|
2006-12-11 17:04:19 +01:00
|
|
|
init_revisions(&rev, NULL);
|
|
|
|
rev.abbrev = DEFAULT_ABBREV;
|
|
|
|
rev.commit_format = CMIT_FMT_DEFAULT;
|
|
|
|
rev.verbose_header = 1;
|
|
|
|
rev.show_root_diff = 0;
|
2006-12-28 02:45:28 +01:00
|
|
|
setup_revisions(argc, argv, &rev, NULL);
|
|
|
|
if (rev.grep_filter) {
|
|
|
|
rev.grep_filter->regflags |= REG_ICASE;
|
|
|
|
compile_grep_patterns(rev.grep_filter);
|
|
|
|
}
|
2006-12-11 17:04:19 +01:00
|
|
|
prepare_revision_walk(&rev);
|
|
|
|
|
2006-12-22 00:58:18 +01:00
|
|
|
html("<table class='list nowrap'>");
|
2007-01-28 00:39:26 +01:00
|
|
|
html("<tr class='nohover'><th class='left'>Date</th>"
|
2006-12-16 19:35:31 +01:00
|
|
|
"<th class='left'>Message</th>"
|
|
|
|
"<th class='left'>Author</th></tr>\n");
|
2006-12-14 00:40:34 +01:00
|
|
|
|
|
|
|
if (ofs<0)
|
|
|
|
ofs = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) {
|
|
|
|
free(commit->buffer);
|
|
|
|
commit->buffer = NULL;
|
|
|
|
free_commit_list(commit->parents);
|
|
|
|
commit->parents = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) {
|
2006-12-15 18:17:36 +01:00
|
|
|
print_commit(commit);
|
2006-12-11 17:04:19 +01:00
|
|
|
free(commit->buffer);
|
|
|
|
commit->buffer = NULL;
|
|
|
|
free_commit_list(commit->parents);
|
|
|
|
commit->parents = NULL;
|
|
|
|
}
|
|
|
|
html("</table>\n");
|
2006-12-14 00:40:34 +01:00
|
|
|
|
|
|
|
html("<div class='pager'>");
|
|
|
|
if (ofs > 0) {
|
|
|
|
html(" <a href='");
|
|
|
|
html(cgit_pageurl(cgit_query_repo, cgit_query_page,
|
|
|
|
fmt("h=%s&ofs=%d", tip, ofs-cnt)));
|
|
|
|
html("'>[prev]</a> ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((commit = get_revision(&rev)) != NULL) {
|
|
|
|
html(" <a href='");
|
|
|
|
html(cgit_pageurl(cgit_query_repo, "log",
|
|
|
|
fmt("h=%s&ofs=%d", tip, ofs+cnt)));
|
|
|
|
html("'>[next]</a> ");
|
|
|
|
}
|
|
|
|
html("</div>");
|
2006-12-11 17:04:19 +01:00
|
|
|
}
|
|
|
|
|