summaryrefslogtreecommitdiffabout
path: root/ui-log.c
authorLars Hjemli <hjemli@gmail.com>2007-02-17 12:46:18 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-02-20 23:24:36 (UTC)
commit66cacd053ba900c8eb3b7962027370c84a97f990 (patch) (unidiff)
tree9ccd8202204bf556a186ba1520a6c767756855bf /ui-log.c
parentac70cb4795c90db02917db63d169b0fadfe9fb99 (diff)
downloadcgit-66cacd053ba900c8eb3b7962027370c84a97f990.zip
cgit-66cacd053ba900c8eb3b7962027370c84a97f990.tar.gz
cgit-66cacd053ba900c8eb3b7962027370c84a97f990.tar.bz2
Layout update
Diffstat (limited to 'ui-log.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-log.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/ui-log.c b/ui-log.c
index 24d571d..159393a 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -9,90 +9,89 @@
9#include "cgit.h" 9#include "cgit.h"
10 10
11void print_commit(struct commit *commit) 11void print_commit(struct commit *commit)
12{ 12{
13 char buf[32]; 13 char buf[32];
14 struct commitinfo *info; 14 struct commitinfo *info;
15 struct tm *time; 15 struct tm *time;
16 16
17 info = cgit_parse_commit(commit); 17 info = cgit_parse_commit(commit);
18 time = gmtime(&commit->date); 18 time = gmtime(&commit->date);
19 html("<tr><td>"); 19 html("<tr><td>");
20 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); 20 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time);
21 html_txt(buf); 21 html_txt(buf);
22 html("</td><td>"); 22 html("</td><td>");
23 char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); 23 char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1));
24 char *url = cgit_pageurl(cgit_query_repo, "commit", qry); 24 char *url = cgit_pageurl(cgit_query_repo, "commit", qry);
25 html_link_open(url, NULL, NULL); 25 html_link_open(url, NULL, NULL);
26 html_ntxt(cgit_max_msg_len, info->subject); 26 html_ntxt(cgit_max_msg_len, info->subject);
27 html_link_close(); 27 html_link_close();
28 html("</td><td>"); 28 html("</td><td>");
29 html_txt(info->author); 29 html_txt(info->author);
30 html("</td></tr>\n"); 30 html("</td></tr>\n");
31 cgit_free_commitinfo(info); 31 cgit_free_commitinfo(info);
32} 32}
33 33
34 34
35void cgit_print_log(const char *tip, int ofs, int cnt, char *grep) 35void cgit_print_log(const char *tip, int ofs, int cnt, char *grep)
36{ 36{
37 struct rev_info rev; 37 struct rev_info rev;
38 struct commit *commit; 38 struct commit *commit;
39 const char *argv[3] = {NULL, tip, NULL}; 39 const char *argv[3] = {NULL, tip, NULL};
40 int argc = 2; 40 int argc = 2;
41 int i; 41 int i;
42 42
43 if (grep) 43 if (grep)
44 argv[argc++] = fmt("--grep=%s", grep); 44 argv[argc++] = fmt("--grep=%s", grep);
45 init_revisions(&rev, NULL); 45 init_revisions(&rev, NULL);
46 rev.abbrev = DEFAULT_ABBREV; 46 rev.abbrev = DEFAULT_ABBREV;
47 rev.commit_format = CMIT_FMT_DEFAULT; 47 rev.commit_format = CMIT_FMT_DEFAULT;
48 rev.verbose_header = 1; 48 rev.verbose_header = 1;
49 rev.show_root_diff = 0; 49 rev.show_root_diff = 0;
50 setup_revisions(argc, argv, &rev, NULL); 50 setup_revisions(argc, argv, &rev, NULL);
51 if (rev.grep_filter) { 51 if (rev.grep_filter) {
52 rev.grep_filter->regflags |= REG_ICASE; 52 rev.grep_filter->regflags |= REG_ICASE;
53 compile_grep_patterns(rev.grep_filter); 53 compile_grep_patterns(rev.grep_filter);
54 } 54 }
55 prepare_revision_walk(&rev); 55 prepare_revision_walk(&rev);
56 56
57 html("<h2>Log</h2>");
58 html("<table class='list nowrap'>"); 57 html("<table class='list nowrap'>");
59 html("<tr class='nohover'><th class='left'>Date</th>" 58 html("<tr class='nohover'><th class='left'>Date</th>"
60 "<th class='left'>Message</th>" 59 "<th class='left'>Message</th>"
61 "<th class='left'>Author</th></tr>\n"); 60 "<th class='left'>Author</th></tr>\n");
62 61
63 if (ofs<0) 62 if (ofs<0)
64 ofs = 0; 63 ofs = 0;
65 64
66 for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { 65 for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) {
67 free(commit->buffer); 66 free(commit->buffer);
68 commit->buffer = NULL; 67 commit->buffer = NULL;
69 free_commit_list(commit->parents); 68 free_commit_list(commit->parents);
70 commit->parents = NULL; 69 commit->parents = NULL;
71 } 70 }
72 71
73 for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { 72 for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) {
74 print_commit(commit); 73 print_commit(commit);
75 free(commit->buffer); 74 free(commit->buffer);
76 commit->buffer = NULL; 75 commit->buffer = NULL;
77 free_commit_list(commit->parents); 76 free_commit_list(commit->parents);
78 commit->parents = NULL; 77 commit->parents = NULL;
79 } 78 }
80 html("</table>\n"); 79 html("</table>\n");
81 80
82 html("<div class='pager'>"); 81 html("<div class='pager'>");
83 if (ofs > 0) { 82 if (ofs > 0) {
84 html("&nbsp;<a href='"); 83 html("&nbsp;<a href='");
85 html(cgit_pageurl(cgit_query_repo, cgit_query_page, 84 html(cgit_pageurl(cgit_query_repo, cgit_query_page,
86 fmt("h=%s&ofs=%d", tip, ofs-cnt))); 85 fmt("h=%s&ofs=%d", tip, ofs-cnt)));
87 html("'>[prev]</a>&nbsp;"); 86 html("'>[prev]</a>&nbsp;");
88 } 87 }
89 88
90 if ((commit = get_revision(&rev)) != NULL) { 89 if ((commit = get_revision(&rev)) != NULL) {
91 html("&nbsp;<a href='"); 90 html("&nbsp;<a href='");
92 html(cgit_pageurl(cgit_query_repo, "log", 91 html(cgit_pageurl(cgit_query_repo, "log",
93 fmt("h=%s&ofs=%d", tip, ofs+cnt))); 92 fmt("h=%s&ofs=%d", tip, ofs+cnt)));
94 html("'>[next]</a>&nbsp;"); 93 html("'>[next]</a>&nbsp;");
95 } 94 }
96 html("</div>"); 95 html("</div>");
97} 96}
98 97