|
diff --git a/ui-log.c b/ui-log.c index 8dd8b89..631e46d 100644 --- a/ ui-log.c+++ b/ ui-log.c |
|
@@ -1,155 +1,177 @@ |
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 | |
38 | |
39 | info = cgit_parse_commit(commit); |
39 | info = cgit_parse_commit(commit); |
40 | html("<tr><td>"); |
40 | html("<tr><td>"); |
41 | tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1)); |
41 | tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1)); |
42 | tmp = cgit_pageurl(ctx.repo->url, "commit", tmp); |
42 | tmp = cgit_pageurl(ctx.repo->url, "commit", tmp); |
43 | html_link_open(tmp, NULL, NULL); |
43 | html_link_open(tmp, NULL, NULL); |
44 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); |
44 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); |
45 | html_link_close(); |
45 | html_link_close(); |
46 | html("</td><td>"); |
46 | html("</td><td>"); |
| |
47 | if (ctx.qry.showmsg) |
| |
48 | html("<u>"); |
47 | cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, |
49 | cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, |
48 | sha1_to_hex(commit->object.sha1)); |
50 | sha1_to_hex(commit->object.sha1)); |
| |
51 | if (ctx.qry.showmsg) |
| |
52 | html("</u>"); |
49 | html("</td><td>"); |
53 | html("</td><td>"); |
50 | html_txt(info->author); |
54 | html_txt(info->author); |
51 | if (ctx.repo->enable_log_filecount) { |
55 | if (ctx.repo->enable_log_filecount) { |
52 | files = 0; |
56 | files = 0; |
53 | add_lines = 0; |
57 | add_lines = 0; |
54 | rem_lines = 0; |
58 | rem_lines = 0; |
55 | cgit_diff_commit(commit, inspect_files); |
59 | cgit_diff_commit(commit, inspect_files); |
56 | html("</td><td>"); |
60 | html("</td><td>"); |
57 | htmlf("%d", files); |
61 | htmlf("%d", files); |
58 | if (ctx.repo->enable_log_linecount) { |
62 | if (ctx.repo->enable_log_linecount) { |
59 | html("</td><td>"); |
63 | html("</td><td>"); |
60 | htmlf("-%d/+%d", rem_lines, add_lines); |
64 | htmlf("-%d/+%d", rem_lines, add_lines); |
61 | } |
65 | } |
62 | } |
66 | } |
63 | html("</td></tr>\n"); |
67 | html("</td></tr>\n"); |
| |
68 | if (ctx.qry.showmsg) { |
| |
69 | html("<tr class='nohover'><td></td><td><div class='commit-msg'>"); |
| |
70 | html_txt(info->msg); |
| |
71 | html("</div><br/></td><td></td>"); |
| |
72 | if (ctx.repo->enable_log_filecount) { |
| |
73 | html("<td></td>"); |
| |
74 | if (ctx.repo->enable_log_linecount) |
| |
75 | html("<td></td>"); |
| |
76 | } |
| |
77 | html("</tr>\n"); |
| |
78 | } |
64 | cgit_free_commitinfo(info); |
79 | cgit_free_commitinfo(info); |
65 | } |
80 | } |
66 | |
81 | |
67 | |
82 | |
68 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, |
83 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, |
69 | char *path, int pager) |
84 | char *path, int pager) |
70 | { |
85 | { |
71 | struct rev_info rev; |
86 | struct rev_info rev; |
72 | struct commit *commit; |
87 | struct commit *commit; |
73 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; |
88 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; |
74 | int argc = 2; |
89 | int argc = 2; |
75 | int i, columns = 3; |
90 | int i, columns = 3; |
76 | |
91 | |
77 | if (!tip) |
92 | if (!tip) |
78 | argv[1] = ctx.qry.head; |
93 | argv[1] = ctx.qry.head; |
79 | |
94 | |
80 | if (grep && pattern && (!strcmp(grep, "grep") || |
95 | if (grep && pattern && (!strcmp(grep, "grep") || |
81 | !strcmp(grep, "author") || |
96 | !strcmp(grep, "author") || |
82 | !strcmp(grep, "committer"))) |
97 | !strcmp(grep, "committer"))) |
83 | argv[argc++] = fmt("--%s=%s", grep, pattern); |
98 | argv[argc++] = fmt("--%s=%s", grep, pattern); |
84 | |
99 | |
85 | if (path) { |
100 | if (path) { |
86 | argv[argc++] = "--"; |
101 | argv[argc++] = "--"; |
87 | argv[argc++] = path; |
102 | argv[argc++] = path; |
88 | } |
103 | } |
89 | init_revisions(&rev, NULL); |
104 | init_revisions(&rev, NULL); |
90 | rev.abbrev = DEFAULT_ABBREV; |
105 | rev.abbrev = DEFAULT_ABBREV; |
91 | rev.commit_format = CMIT_FMT_DEFAULT; |
106 | rev.commit_format = CMIT_FMT_DEFAULT; |
92 | rev.verbose_header = 1; |
107 | rev.verbose_header = 1; |
93 | rev.show_root_diff = 0; |
108 | rev.show_root_diff = 0; |
94 | setup_revisions(argc, argv, &rev, NULL); |
109 | setup_revisions(argc, argv, &rev, NULL); |
95 | rev.grep_filter.regflags |= REG_ICASE; |
110 | rev.grep_filter.regflags |= REG_ICASE; |
96 | compile_grep_patterns(&rev.grep_filter); |
111 | compile_grep_patterns(&rev.grep_filter); |
97 | prepare_revision_walk(&rev); |
112 | prepare_revision_walk(&rev); |
98 | |
113 | |
99 | if (pager) |
114 | if (pager) |
100 | html("<table class='list nowrap'>"); |
115 | html("<table class='list nowrap'>"); |
101 | |
116 | |
102 | html("<tr class='nohover'><th class='left'>Age</th>" |
117 | html("<tr class='nohover'><th class='left'>Age</th>" |
103 | "<th class='left'>Commit message</th>" |
118 | "<th class='left'>Commit message"); |
104 | "<th class='left'>Author</th>"); |
119 | if (pager) { |
| |
120 | html(" ("); |
| |
121 | cgit_log_link("toggle", NULL, NULL, ctx.qry.head, ctx.qry.sha1, |
| |
122 | ctx.qry.path, ctx.qry.ofs, ctx.qry.grep, |
| |
123 | ctx.qry.search, ctx.qry.showmsg ? 0 : 1); |
| |
124 | html(")"); |
| |
125 | } |
| |
126 | html("</th><th class='left'>Author</th>"); |
105 | if (ctx.repo->enable_log_filecount) { |
127 | if (ctx.repo->enable_log_filecount) { |
106 | html("<th class='left'>Files</th>"); |
128 | html("<th class='left'>Files</th>"); |
107 | columns++; |
129 | columns++; |
108 | if (ctx.repo->enable_log_linecount) { |
130 | if (ctx.repo->enable_log_linecount) { |
109 | html("<th class='left'>Lines</th>"); |
131 | html("<th class='left'>Lines</th>"); |
110 | columns++; |
132 | columns++; |
111 | } |
133 | } |
112 | } |
134 | } |
113 | html("</tr>\n"); |
135 | html("</tr>\n"); |
114 | |
136 | |
115 | if (ofs<0) |
137 | if (ofs<0) |
116 | ofs = 0; |
138 | ofs = 0; |
117 | |
139 | |
118 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
140 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
119 | free(commit->buffer); |
141 | free(commit->buffer); |
120 | commit->buffer = NULL; |
142 | commit->buffer = NULL; |
121 | free_commit_list(commit->parents); |
143 | free_commit_list(commit->parents); |
122 | commit->parents = NULL; |
144 | commit->parents = NULL; |
123 | } |
145 | } |
124 | |
146 | |
125 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { |
147 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { |
126 | print_commit(commit); |
148 | print_commit(commit); |
127 | free(commit->buffer); |
149 | free(commit->buffer); |
128 | commit->buffer = NULL; |
150 | commit->buffer = NULL; |
129 | free_commit_list(commit->parents); |
151 | free_commit_list(commit->parents); |
130 | commit->parents = NULL; |
152 | commit->parents = NULL; |
131 | } |
153 | } |
132 | if (pager) { |
154 | if (pager) { |
133 | htmlf("</table><div class='pager'>", |
155 | htmlf("</table><div class='pager'>", |
134 | columns); |
156 | columns); |
135 | if (ofs > 0) { |
157 | if (ofs > 0) { |
136 | cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, |
158 | cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, |
137 | ctx.qry.sha1, ctx.qry.path, |
159 | ctx.qry.sha1, ctx.qry.path, |
138 | ofs - cnt, ctx.qry.grep, |
160 | ofs - cnt, ctx.qry.grep, |
139 | ctx.qry.search); |
161 | ctx.qry.search, ctx.qry.showmsg); |
140 | html(" "); |
162 | html(" "); |
141 | } |
163 | } |
142 | if ((commit = get_revision(&rev)) != NULL) { |
164 | if ((commit = get_revision(&rev)) != NULL) { |
143 | cgit_log_link("[next]", NULL, NULL, ctx.qry.head, |
165 | cgit_log_link("[next]", NULL, NULL, ctx.qry.head, |
144 | ctx.qry.sha1, ctx.qry.path, |
166 | ctx.qry.sha1, ctx.qry.path, |
145 | ofs + cnt, ctx.qry.grep, |
167 | ofs + cnt, ctx.qry.grep, |
146 | ctx.qry.search); |
168 | ctx.qry.search, ctx.qry.showmsg); |
147 | } |
169 | } |
148 | html("</div>"); |
170 | html("</div>"); |
149 | } else if ((commit = get_revision(&rev)) != NULL) { |
171 | } else if ((commit = get_revision(&rev)) != NULL) { |
150 | html("<tr class='nohover'><td colspan='3'>"); |
172 | html("<tr class='nohover'><td colspan='3'>"); |
151 | cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0, |
173 | cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0, |
152 | NULL, NULL); |
174 | NULL, NULL, ctx.qry.showmsg); |
153 | html("</td></tr>\n"); |
175 | html("</td></tr>\n"); |
154 | } |
176 | } |
155 | } |
177 | } |
|