summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--ui-log.c42
-rw-r--r--ui-refs.c25
-rw-r--r--ui-summary.c10
3 files changed, 43 insertions, 34 deletions
diff --git a/ui-log.c b/ui-log.c
index 60c9269..9b2ffb6 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -32,50 +32,51 @@ void inspect_files(struct diff_filepair *pair)
32} 32}
33 33
34void print_commit(struct commit *commit) 34void print_commit(struct commit *commit)
35{ 35{
36 struct commitinfo *info; 36 struct commitinfo *info;
37 37
38 info = cgit_parse_commit(commit); 38 info = cgit_parse_commit(commit);
39 html("<tr><td>"); 39 html("<tr><td>");
40 cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); 40 cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE);
41 html("</td><td>"); 41 html("</td><td>");
42 cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, 42 cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
43 sha1_to_hex(commit->object.sha1)); 43 sha1_to_hex(commit->object.sha1));
44 html("</td><td>");
45 html_txt(info->author);
44 if (ctx.repo->enable_log_filecount) { 46 if (ctx.repo->enable_log_filecount) {
45 files = 0; 47 files = 0;
46 add_lines = 0; 48 add_lines = 0;
47 rem_lines = 0; 49 rem_lines = 0;
48 cgit_diff_commit(commit, inspect_files); 50 cgit_diff_commit(commit, inspect_files);
49 html("</td><td class='right'>"); 51 html("</td><td>");
50 htmlf("%d", files); 52 htmlf("%d", files);
51 if (ctx.repo->enable_log_linecount) { 53 if (ctx.repo->enable_log_linecount) {
52 html("</td><td class='right'>"); 54 html("</td><td>");
53 htmlf("-%d/+%d", rem_lines, add_lines); 55 htmlf("-%d/+%d", rem_lines, add_lines);
54 } 56 }
55 } 57 }
56 html("</td><td>");
57 html_txt(info->author);
58 html("</td></tr>\n"); 58 html("</td></tr>\n");
59 cgit_free_commitinfo(info); 59 cgit_free_commitinfo(info);
60} 60}
61 61
62 62
63void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, char *path, int pager) 63void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern,
64 char *path, int pager)
64{ 65{
65 struct rev_info rev; 66 struct rev_info rev;
66 struct commit *commit; 67 struct commit *commit;
67 const char *argv[] = {NULL, tip, NULL, NULL, NULL}; 68 const char *argv[] = {NULL, tip, NULL, NULL, NULL};
68 int argc = 2; 69 int argc = 2;
69 int i; 70 int i, columns = 3;
70 71
71 if (!tip) 72 if (!tip)
72 argv[1] = ctx.qry.head; 73 argv[1] = ctx.qry.head;
73 74
74 if (grep && pattern && (!strcmp(grep, "grep") || 75 if (grep && pattern && (!strcmp(grep, "grep") ||
75 !strcmp(grep, "author") || 76 !strcmp(grep, "author") ||
76 !strcmp(grep, "committer"))) 77 !strcmp(grep, "committer")))
77 argv[argc++] = fmt("--%s=%s", grep, pattern); 78 argv[argc++] = fmt("--%s=%s", grep, pattern);
78 79
79 if (path) { 80 if (path) {
80 argv[argc++] = "--"; 81 argv[argc++] = "--";
81 argv[argc++] = path; 82 argv[argc++] = path;
@@ -83,60 +84,69 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
83 init_revisions(&rev, NULL); 84 init_revisions(&rev, NULL);
84 rev.abbrev = DEFAULT_ABBREV; 85 rev.abbrev = DEFAULT_ABBREV;
85 rev.commit_format = CMIT_FMT_DEFAULT; 86 rev.commit_format = CMIT_FMT_DEFAULT;
86 rev.verbose_header = 1; 87 rev.verbose_header = 1;
87 rev.show_root_diff = 0; 88 rev.show_root_diff = 0;
88 setup_revisions(argc, argv, &rev, NULL); 89 setup_revisions(argc, argv, &rev, NULL);
89 if (rev.grep_filter) { 90 if (rev.grep_filter) {
90 rev.grep_filter->regflags |= REG_ICASE; 91 rev.grep_filter->regflags |= REG_ICASE;
91 compile_grep_patterns(rev.grep_filter); 92 compile_grep_patterns(rev.grep_filter);
92 } 93 }
93 prepare_revision_walk(&rev); 94 prepare_revision_walk(&rev);
94 95
95 html("<table summary='log' class='list nowrap'>"); 96 if (pager)
96 html("<tr class='nohover'><th class='left'>Age</th>" 97 html("<table class='list nowrap'>");
97 "<th class='left'>Message</th>");
98 98
99 html("<tr class='nohover'><th class='left'>Age</th>"
100 "<th class='left'>Commit message</th>"
101 "<th class='left'>Author</th>");
99 if (ctx.repo->enable_log_filecount) { 102 if (ctx.repo->enable_log_filecount) {
100 html("<th class='right'>Files</th>"); 103 html("<th class='left'>Files</th>");
101 if (ctx.repo->enable_log_linecount) 104 columns++;
102 html("<th class='right'>Lines</th>"); 105 if (ctx.repo->enable_log_linecount) {
106 html("<th class='left'>Lines</th>");
107 columns++;
103 } 108 }
104 html("<th class='left'>Author</th></tr>\n"); 109 }
110 html("</tr>\n");
105 111
106 if (ofs<0) 112 if (ofs<0)
107 ofs = 0; 113 ofs = 0;
108 114
109 for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { 115 for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) {
110 free(commit->buffer); 116 free(commit->buffer);
111 commit->buffer = NULL; 117 commit->buffer = NULL;
112 free_commit_list(commit->parents); 118 free_commit_list(commit->parents);
113 commit->parents = NULL; 119 commit->parents = NULL;
114 } 120 }
115 121
116 for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { 122 for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) {
117 print_commit(commit); 123 print_commit(commit);
118 free(commit->buffer); 124 free(commit->buffer);
119 commit->buffer = NULL; 125 commit->buffer = NULL;
120 free_commit_list(commit->parents); 126 free_commit_list(commit->parents);
121 commit->parents = NULL; 127 commit->parents = NULL;
122 } 128 }
123 html("</table>\n");
124
125 if (pager) { 129 if (pager) {
126 html("<div class='pager'>"); 130 htmlf("</table><div class='pager'>",
131 columns);
127 if (ofs > 0) { 132 if (ofs > 0) {
128 cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, 133 cgit_log_link("[prev]", NULL, NULL, ctx.qry.head,
129 ctx.qry.sha1, ctx.qry.path, 134 ctx.qry.sha1, ctx.qry.path,
130 ofs - cnt, ctx.qry.grep, 135 ofs - cnt, ctx.qry.grep,
131 ctx.qry.search); 136 ctx.qry.search);
132 html("&nbsp;"); 137 html("&nbsp;");
133 } 138 }
134 if ((commit = get_revision(&rev)) != NULL) { 139 if ((commit = get_revision(&rev)) != NULL) {
135 cgit_log_link("[next]", NULL, NULL, ctx.qry.head, 140 cgit_log_link("[next]", NULL, NULL, ctx.qry.head,
136 ctx.qry.sha1, ctx.qry.path, 141 ctx.qry.sha1, ctx.qry.path,
137 ofs + cnt, ctx.qry.grep, 142 ofs + cnt, ctx.qry.grep,
138 ctx.qry.search); 143 ctx.qry.search);
139 } 144 }
140 html("</div>"); 145 html("</div>");
146 } else if ((commit = get_revision(&rev)) != NULL) {
147 html("<tr class='nohover'><td colspan='3'>");
148 cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0,
149 NULL, NULL);
150 html("</td></tr>\n");
141 } 151 }
142} 152}
diff --git a/ui-refs.c b/ui-refs.c
index 12533cd..44c8f9a 100644
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -53,100 +53,100 @@ static int cmp_tag_age(const void *a, const void *b)
53static int print_branch(struct refinfo *ref) 53static int print_branch(struct refinfo *ref)
54{ 54{
55 struct commitinfo *info = ref->commit; 55 struct commitinfo *info = ref->commit;
56 char *name = (char *)ref->refname; 56 char *name = (char *)ref->refname;
57 57
58 if (!info) 58 if (!info)
59 return 1; 59 return 1;
60 html("<tr><td>"); 60 html("<tr><td>");
61 cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0, NULL, NULL); 61 cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0, NULL, NULL);
62 html("</td><td>"); 62 html("</td><td>");
63 63
64 if (ref->object->type == OBJ_COMMIT) { 64 if (ref->object->type == OBJ_COMMIT) {
65 cgit_print_age(info->commit->date, -1, NULL); 65 cgit_commit_link(info->subject, NULL, NULL, name, NULL);
66 html("</td><td>"); 66 html("</td><td>");
67 html_txt(info->author); 67 html_txt(info->author);
68 html("</td><td>"); 68 html("</td><td colspan='2'>");
69 cgit_commit_link(info->subject, NULL, NULL, name, NULL); 69 cgit_print_age(info->commit->date, -1, NULL);
70 } else { 70 } else {
71 html("</td><td></td><td>"); 71 html("</td><td></td><td>");
72 cgit_object_link(ref->object); 72 cgit_object_link(ref->object);
73 } 73 }
74 html("</td></tr>\n"); 74 html("</td></tr>\n");
75 return 0; 75 return 0;
76} 76}
77 77
78static void print_tag_header() 78static void print_tag_header()
79{ 79{
80 html("<tr class='nohover'><th class='left'>Tag</th>" 80 html("<tr class='nohover'><th class='left'>Tag</th>"
81 "<th class='left'>Age</th>" 81 "<th class='left'>Reference</th>"
82 "<th class='left'>Author</th>" 82 "<th class='left'>Author</th>"
83 "<th class='left'>Reference</th></tr>\n"); 83 "<th class='left' colspan='2'>Age</th></tr>\n");
84 header = 1; 84 header = 1;
85} 85}
86 86
87static int print_tag(struct refinfo *ref) 87static int print_tag(struct refinfo *ref)
88{ 88{
89 struct tag *tag; 89 struct tag *tag;
90 struct taginfo *info; 90 struct taginfo *info;
91 char *url, *name = (char *)ref->refname; 91 char *url, *name = (char *)ref->refname;
92 92
93 if (ref->object->type == OBJ_TAG) { 93 if (ref->object->type == OBJ_TAG) {
94 tag = (struct tag *)ref->object; 94 tag = (struct tag *)ref->object;
95 info = ref->tag; 95 info = ref->tag;
96 if (!tag || !info) 96 if (!tag || !info)
97 return 1; 97 return 1;
98 html("<tr><td>"); 98 html("<tr><td>");
99 url = cgit_pageurl(ctx.qry.repo, "tag", 99 url = cgit_pageurl(ctx.qry.repo, "tag",
100 fmt("id=%s", name)); 100 fmt("id=%s", name));
101 html_link_open(url, NULL, NULL); 101 html_link_open(url, NULL, NULL);
102 html_txt(name); 102 html_txt(name);
103 html_link_close(); 103 html_link_close();
104 html("</td><td>"); 104 html("</td><td>");
105 if (info->tagger_date > 0) 105 cgit_object_link(tag->tagged);
106 cgit_print_age(info->tagger_date, -1, NULL);
107 html("</td><td>"); 106 html("</td><td>");
108 if (info->tagger) 107 if (info->tagger)
109 html(info->tagger); 108 html(info->tagger);
110 html("</td><td>"); 109 html("</td><td colspan='2'>");
111 cgit_object_link(tag->tagged); 110 if (info->tagger_date > 0)
111 cgit_print_age(info->tagger_date, -1, NULL);
112 html("</td></tr>\n"); 112 html("</td></tr>\n");
113 } else { 113 } else {
114 if (!header) 114 if (!header)
115 print_tag_header(); 115 print_tag_header();
116 html("<tr><td>"); 116 html("<tr><td>");
117 html_txt(name); 117 html_txt(name);
118 html("</td><td colspan='2'/><td>"); 118 html("</td><td>");
119 cgit_object_link(ref->object); 119 cgit_object_link(ref->object);
120 html("</td></tr>\n"); 120 html("</td></tr>\n");
121 } 121 }
122 return 0; 122 return 0;
123} 123}
124 124
125static void print_refs_link(char *path) 125static void print_refs_link(char *path)
126{ 126{
127 html("<tr class='nohover'><td colspan='4'>"); 127 html("<tr class='nohover'><td colspan='4'>");
128 cgit_refs_link("[...]", NULL, NULL, ctx.qry.head, NULL, path); 128 cgit_refs_link("[...]", NULL, NULL, ctx.qry.head, NULL, path);
129 html("</td></tr>"); 129 html("</td></tr>");
130} 130}
131 131
132void cgit_print_branches(int maxcount) 132void cgit_print_branches(int maxcount)
133{ 133{
134 struct reflist list; 134 struct reflist list;
135 int i; 135 int i;
136 136
137 html("<tr class='nohover'><th class='left'>Branch</th>" 137 html("<tr class='nohover'><th class='left'>Branch</th>"
138 "<th class='left'>Idle</th>" 138 "<th class='left'>Commit message</th>"
139 "<th class='left'>Author</th>" 139 "<th class='left'>Author</th>"
140 "<th class='left'>Head commit</th></tr>\n"); 140 "<th class='left' colspan='2'>Age</th></tr>\n");
141 141
142 list.refs = NULL; 142 list.refs = NULL;
143 list.alloc = list.count = 0; 143 list.alloc = list.count = 0;
144 for_each_branch_ref(cgit_refs_cb, &list); 144 for_each_branch_ref(cgit_refs_cb, &list);
145 145
146 if (maxcount == 0 || maxcount > list.count) 146 if (maxcount == 0 || maxcount > list.count)
147 maxcount = list.count; 147 maxcount = list.count;
148 148
149 if (maxcount < list.count) { 149 if (maxcount < list.count) {
150 qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); 150 qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age);
151 qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); 151 qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name);
152 } 152 }
@@ -187,15 +187,14 @@ void cgit_print_refs()
187 187
188 html("<table class='list nowrap'>"); 188 html("<table class='list nowrap'>");
189 189
190 if (ctx.qry.path && !strncmp(ctx.qry.path, "heads", 5)) 190 if (ctx.qry.path && !strncmp(ctx.qry.path, "heads", 5))
191 cgit_print_branches(0); 191 cgit_print_branches(0);
192 else if (ctx.qry.path && !strncmp(ctx.qry.path, "tags", 4)) 192 else if (ctx.qry.path && !strncmp(ctx.qry.path, "tags", 4))
193 cgit_print_tags(0); 193 cgit_print_tags(0);
194 else { 194 else {
195 cgit_print_branches(0); 195 cgit_print_branches(0);
196 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); 196 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
197 cgit_print_tags(0); 197 cgit_print_tags(0);
198 } 198 }
199
200 html("</table>"); 199 html("</table>");
201} 200}
diff --git a/ui-summary.c b/ui-summary.c
index 0b66b52..318148a 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -9,23 +9,23 @@
9#include "cgit.h" 9#include "cgit.h"
10#include "html.h" 10#include "html.h"
11#include "ui-log.h" 11#include "ui-log.h"
12#include "ui-refs.h" 12#include "ui-refs.h"
13 13
14void cgit_print_summary() 14void cgit_print_summary()
15{ 15{
16 if (ctx.repo->readme) { 16 if (ctx.repo->readme) {
17 html("<div id='summary'>"); 17 html("<div id='summary'>");
18 html_include(ctx.repo->readme); 18 html_include(ctx.repo->readme);
19 html("</div>"); 19 html("</div>");
20 } 20 }
21 if (ctx.cfg.summary_log > 0)
22 cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL,
23 NULL, NULL, 0);
24 html("<table summary='repository info' class='list nowrap'>"); 21 html("<table summary='repository info' class='list nowrap'>");
25 if (ctx.cfg.summary_log > 0)
26 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
27 cgit_print_branches(ctx.cfg.summary_branches); 22 cgit_print_branches(ctx.cfg.summary_branches);
28 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); 23 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
29 cgit_print_tags(ctx.cfg.summary_tags); 24 cgit_print_tags(ctx.cfg.summary_tags);
25 if (ctx.cfg.summary_log > 0) {
26 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
27 cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL,
28 NULL, NULL, 0);
29 }
30 html("</table>"); 30 html("</table>");
31} 31}