|
diff --git a/ui-log.c b/ui-log.c index adc9a66..00ecd4e 100644 --- a/ ui-log.c+++ b/ ui-log.c |
|
@@ -1,178 +1,176 @@ |
1 | /* ui-log.c: functions for log output |
1 | /* ui-log.c: functions for log output |
2 | * |
2 | * |
3 | * Copyright (C) 2006 Lars Hjemli |
3 | * Copyright (C) 2006 Lars Hjemli |
4 | * |
4 | * |
5 | * Licensed under GNU General Public License v2 |
5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) |
6 | * (see COPYING for full license text) |
7 | */ |
7 | */ |
8 | |
8 | |
9 | #include "cgit.h" |
9 | #include "cgit.h" |
10 | #include "html.h" |
10 | #include "html.h" |
11 | #include "ui-shared.h" |
11 | #include "ui-shared.h" |
12 | |
12 | |
13 | int files, add_lines, rem_lines; |
13 | int files, add_lines, rem_lines; |
14 | |
14 | |
15 | void count_lines(char *line, int size) |
15 | void count_lines(char *line, int size) |
16 | { |
16 | { |
17 | if (size <= 0) |
17 | if (size <= 0) |
18 | return; |
18 | return; |
19 | |
19 | |
20 | if (line[0] == '+') |
20 | if (line[0] == '+') |
21 | add_lines++; |
21 | add_lines++; |
22 | |
22 | |
23 | else if (line[0] == '-') |
23 | else if (line[0] == '-') |
24 | rem_lines++; |
24 | rem_lines++; |
25 | } |
25 | } |
26 | |
26 | |
27 | void inspect_files(struct diff_filepair *pair) |
27 | void inspect_files(struct diff_filepair *pair) |
28 | { |
28 | { |
29 | files++; |
29 | files++; |
30 | if (ctx.repo->enable_log_linecount) |
30 | if (ctx.repo->enable_log_linecount) |
31 | cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines); |
31 | cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines); |
32 | } |
32 | } |
33 | |
33 | |
34 | void print_commit(struct commit *commit) |
34 | void print_commit(struct commit *commit) |
35 | { |
35 | { |
36 | struct commitinfo *info; |
36 | struct commitinfo *info; |
37 | char *tmp; |
37 | char *tmp; |
38 | int cols = 2; |
38 | int cols = 2; |
39 | |
39 | |
40 | info = cgit_parse_commit(commit); |
40 | info = cgit_parse_commit(commit); |
41 | html("<tr><td>"); |
41 | htmlf("<tr%s><td>", |
| |
42 | ctx.qry.showmsg ? " class='logheader'" : ""); |
42 | tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1)); |
43 | tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1)); |
43 | tmp = cgit_pageurl(ctx.repo->url, "commit", tmp); |
44 | tmp = cgit_pageurl(ctx.repo->url, "commit", tmp); |
44 | html_link_open(tmp, NULL, NULL); |
45 | html_link_open(tmp, NULL, NULL); |
45 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); |
46 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); |
46 | html_link_close(); |
47 | html_link_close(); |
47 | html("</td><td>"); |
48 | htmlf("</td><td%s>", |
48 | if (ctx.qry.showmsg) |
49 | ctx.qry.showmsg ? " class='logsubject'" : ""); |
49 | html("<u>"); |
| |
50 | cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, |
50 | cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, |
51 | sha1_to_hex(commit->object.sha1)); |
51 | sha1_to_hex(commit->object.sha1)); |
52 | if (ctx.qry.showmsg) |
| |
53 | html("</u>"); |
| |
54 | html("</td><td>"); |
52 | html("</td><td>"); |
55 | html_txt(info->author); |
53 | html_txt(info->author); |
56 | if (ctx.repo->enable_log_filecount) { |
54 | if (ctx.repo->enable_log_filecount) { |
57 | files = 0; |
55 | files = 0; |
58 | add_lines = 0; |
56 | add_lines = 0; |
59 | rem_lines = 0; |
57 | rem_lines = 0; |
60 | cgit_diff_commit(commit, inspect_files); |
58 | cgit_diff_commit(commit, inspect_files); |
61 | html("</td><td>"); |
59 | html("</td><td>"); |
62 | htmlf("%d", files); |
60 | htmlf("%d", files); |
63 | if (ctx.repo->enable_log_linecount) { |
61 | if (ctx.repo->enable_log_linecount) { |
64 | html("</td><td>"); |
62 | html("</td><td>"); |
65 | htmlf("-%d/+%d", rem_lines, add_lines); |
63 | htmlf("-%d/+%d", rem_lines, add_lines); |
66 | } |
64 | } |
67 | } |
65 | } |
68 | html("</td></tr>\n"); |
66 | html("</td></tr>\n"); |
69 | if (ctx.qry.showmsg) { |
67 | if (ctx.qry.showmsg) { |
70 | if (ctx.repo->enable_log_filecount) { |
68 | if (ctx.repo->enable_log_filecount) { |
71 | cols++; |
69 | cols++; |
72 | if (ctx.repo->enable_log_linecount) |
70 | if (ctx.repo->enable_log_linecount) |
73 | cols++; |
71 | cols++; |
74 | } |
72 | } |
75 | htmlf("<tr class='nohover'><td></td><td colspan='%d'><div class='commit-msg'>", |
73 | htmlf("<tr class='nohover'><td/><td colspan='%d' class='logmsg'>", |
76 | cols); |
74 | cols); |
77 | html_txt(info->msg); |
75 | html_txt(info->msg); |
78 | html("</div><br/></td></tr>\n"); |
76 | html("</td></tr>\n"); |
79 | } |
77 | } |
80 | cgit_free_commitinfo(info); |
78 | cgit_free_commitinfo(info); |
81 | } |
79 | } |
82 | |
80 | |
83 | |
81 | |
84 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, |
82 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, |
85 | char *path, int pager) |
83 | char *path, int pager) |
86 | { |
84 | { |
87 | struct rev_info rev; |
85 | struct rev_info rev; |
88 | struct commit *commit; |
86 | struct commit *commit; |
89 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; |
87 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; |
90 | int argc = 2; |
88 | int argc = 2; |
91 | int i, columns = 3; |
89 | int i, columns = 3; |
92 | |
90 | |
93 | if (!tip) |
91 | if (!tip) |
94 | argv[1] = ctx.qry.head; |
92 | argv[1] = ctx.qry.head; |
95 | |
93 | |
96 | if (grep && pattern && (!strcmp(grep, "grep") || |
94 | if (grep && pattern && (!strcmp(grep, "grep") || |
97 | !strcmp(grep, "author") || |
95 | !strcmp(grep, "author") || |
98 | !strcmp(grep, "committer"))) |
96 | !strcmp(grep, "committer"))) |
99 | argv[argc++] = fmt("--%s=%s", grep, pattern); |
97 | argv[argc++] = fmt("--%s=%s", grep, pattern); |
100 | |
98 | |
101 | if (path) { |
99 | if (path) { |
102 | argv[argc++] = "--"; |
100 | argv[argc++] = "--"; |
103 | argv[argc++] = path; |
101 | argv[argc++] = path; |
104 | } |
102 | } |
105 | init_revisions(&rev, NULL); |
103 | init_revisions(&rev, NULL); |
106 | rev.abbrev = DEFAULT_ABBREV; |
104 | rev.abbrev = DEFAULT_ABBREV; |
107 | rev.commit_format = CMIT_FMT_DEFAULT; |
105 | rev.commit_format = CMIT_FMT_DEFAULT; |
108 | rev.verbose_header = 1; |
106 | rev.verbose_header = 1; |
109 | rev.show_root_diff = 0; |
107 | rev.show_root_diff = 0; |
110 | setup_revisions(argc, argv, &rev, NULL); |
108 | setup_revisions(argc, argv, &rev, NULL); |
111 | rev.grep_filter.regflags |= REG_ICASE; |
109 | rev.grep_filter.regflags |= REG_ICASE; |
112 | compile_grep_patterns(&rev.grep_filter); |
110 | compile_grep_patterns(&rev.grep_filter); |
113 | prepare_revision_walk(&rev); |
111 | prepare_revision_walk(&rev); |
114 | |
112 | |
115 | if (pager) |
113 | if (pager) |
116 | html("<table class='list nowrap'>"); |
114 | html("<table class='list nowrap'>"); |
117 | |
115 | |
118 | html("<tr class='nohover'><th class='left'>Age</th>" |
116 | html("<tr class='nohover'><th class='left'>Age</th>" |
119 | "<th class='left'>Commit message"); |
117 | "<th class='left'>Commit message"); |
120 | if (pager) { |
118 | if (pager) { |
121 | html(" ("); |
119 | html(" ("); |
122 | cgit_log_link("toggle", NULL, NULL, ctx.qry.head, ctx.qry.sha1, |
120 | cgit_log_link("toggle", NULL, NULL, ctx.qry.head, ctx.qry.sha1, |
123 | ctx.qry.path, ctx.qry.ofs, ctx.qry.grep, |
121 | ctx.qry.path, ctx.qry.ofs, ctx.qry.grep, |
124 | ctx.qry.search, ctx.qry.showmsg ? 0 : 1); |
122 | ctx.qry.search, ctx.qry.showmsg ? 0 : 1); |
125 | html(")"); |
123 | html(")"); |
126 | } |
124 | } |
127 | html("</th><th class='left'>Author</th>"); |
125 | html("</th><th class='left'>Author</th>"); |
128 | if (ctx.repo->enable_log_filecount) { |
126 | if (ctx.repo->enable_log_filecount) { |
129 | html("<th class='left'>Files</th>"); |
127 | html("<th class='left'>Files</th>"); |
130 | columns++; |
128 | columns++; |
131 | if (ctx.repo->enable_log_linecount) { |
129 | if (ctx.repo->enable_log_linecount) { |
132 | html("<th class='left'>Lines</th>"); |
130 | html("<th class='left'>Lines</th>"); |
133 | columns++; |
131 | columns++; |
134 | } |
132 | } |
135 | } |
133 | } |
136 | html("</tr>\n"); |
134 | html("</tr>\n"); |
137 | |
135 | |
138 | if (ofs<0) |
136 | if (ofs<0) |
139 | ofs = 0; |
137 | ofs = 0; |
140 | |
138 | |
141 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
139 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
142 | free(commit->buffer); |
140 | free(commit->buffer); |
143 | commit->buffer = NULL; |
141 | commit->buffer = NULL; |
144 | free_commit_list(commit->parents); |
142 | free_commit_list(commit->parents); |
145 | commit->parents = NULL; |
143 | commit->parents = NULL; |
146 | } |
144 | } |
147 | |
145 | |
148 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { |
146 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { |
149 | print_commit(commit); |
147 | print_commit(commit); |
150 | free(commit->buffer); |
148 | free(commit->buffer); |
151 | commit->buffer = NULL; |
149 | commit->buffer = NULL; |
152 | free_commit_list(commit->parents); |
150 | free_commit_list(commit->parents); |
153 | commit->parents = NULL; |
151 | commit->parents = NULL; |
154 | } |
152 | } |
155 | if (pager) { |
153 | if (pager) { |
156 | htmlf("</table><div class='pager'>", |
154 | htmlf("</table><div class='pager'>", |
157 | columns); |
155 | columns); |
158 | if (ofs > 0) { |
156 | if (ofs > 0) { |
159 | cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, |
157 | cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, |
160 | ctx.qry.sha1, ctx.qry.path, |
158 | ctx.qry.sha1, ctx.qry.path, |
161 | ofs - cnt, ctx.qry.grep, |
159 | ofs - cnt, ctx.qry.grep, |
162 | ctx.qry.search, ctx.qry.showmsg); |
160 | ctx.qry.search, ctx.qry.showmsg); |
163 | html(" "); |
161 | html(" "); |
164 | } |
162 | } |
165 | if ((commit = get_revision(&rev)) != NULL) { |
163 | if ((commit = get_revision(&rev)) != NULL) { |
166 | cgit_log_link("[next]", NULL, NULL, ctx.qry.head, |
164 | cgit_log_link("[next]", NULL, NULL, ctx.qry.head, |
167 | ctx.qry.sha1, ctx.qry.path, |
165 | ctx.qry.sha1, ctx.qry.path, |
168 | ofs + cnt, ctx.qry.grep, |
166 | ofs + cnt, ctx.qry.grep, |
169 | ctx.qry.search, ctx.qry.showmsg); |
167 | ctx.qry.search, ctx.qry.showmsg); |
170 | } |
168 | } |
171 | html("</div>"); |
169 | html("</div>"); |
172 | } else if ((commit = get_revision(&rev)) != NULL) { |
170 | } else if ((commit = get_revision(&rev)) != NULL) { |
173 | html("<tr class='nohover'><td colspan='3'>"); |
171 | html("<tr class='nohover'><td colspan='3'>"); |
174 | cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0, |
172 | cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0, |
175 | NULL, NULL, ctx.qry.showmsg); |
173 | NULL, NULL, ctx.qry.showmsg); |
176 | html("</td></tr>\n"); |
174 | html("</td></tr>\n"); |
177 | } |
175 | } |
178 | } |
176 | } |
|