summaryrefslogtreecommitdiffabout
path: root/ui-log.c
Unidiff
Diffstat (limited to 'ui-log.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-log.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/ui-log.c b/ui-log.c
index 0536b23..41b5225 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -103,151 +103,150 @@ void print_commit(struct commit *commit)
103 rem_lines = 0; 103 rem_lines = 0;
104 cgit_diff_commit(commit, inspect_files); 104 cgit_diff_commit(commit, inspect_files);
105 html("</td><td>"); 105 html("</td><td>");
106 htmlf("%d", files); 106 htmlf("%d", files);
107 if (ctx.repo->enable_log_linecount) { 107 if (ctx.repo->enable_log_linecount) {
108 html("</td><td>"); 108 html("</td><td>");
109 htmlf("-%d/+%d", rem_lines, add_lines); 109 htmlf("-%d/+%d", rem_lines, add_lines);
110 } 110 }
111 } 111 }
112 html("</td></tr>\n"); 112 html("</td></tr>\n");
113 if (ctx.qry.showmsg) { 113 if (ctx.qry.showmsg) {
114 struct strbuf notes = STRBUF_INIT; 114 struct strbuf notes = STRBUF_INIT;
115 format_note(NULL, commit->object.sha1, &notes, PAGE_ENCODING, 0); 115 format_note(NULL, commit->object.sha1, &notes, PAGE_ENCODING, 0);
116 116
117 if (ctx.repo->enable_log_filecount) { 117 if (ctx.repo->enable_log_filecount) {
118 cols++; 118 cols++;
119 if (ctx.repo->enable_log_linecount) 119 if (ctx.repo->enable_log_linecount)
120 cols++; 120 cols++;
121 } 121 }
122 htmlf("<tr class='nohover'><td/><td colspan='%d' class='logmsg'>", 122 htmlf("<tr class='nohover'><td/><td colspan='%d' class='logmsg'>",
123 cols); 123 cols);
124 html_txt(info->msg); 124 html_txt(info->msg);
125 html("</td></tr>\n"); 125 html("</td></tr>\n");
126 if (notes.len != 0) { 126 if (notes.len != 0) {
127 html("<tr class='nohover'>"); 127 html("<tr class='nohover'>");
128 html("<td class='lognotes-label'>Notes:</td>"); 128 html("<td class='lognotes-label'>Notes:</td>");
129 htmlf("<td colspan='%d' class='lognotes'>", 129 htmlf("<td colspan='%d' class='lognotes'>",
130 cols); 130 cols);
131 html_txt(notes.buf); 131 html_txt(notes.buf);
132 html("</td></tr>\n"); 132 html("</td></tr>\n");
133 } 133 }
134 strbuf_release(&notes); 134 strbuf_release(&notes);
135 } 135 }
136 cgit_free_commitinfo(info); 136 cgit_free_commitinfo(info);
137} 137}
138 138
139static const char *disambiguate_ref(const char *ref) 139static const char *disambiguate_ref(const char *ref)
140{ 140{
141 unsigned char sha1[20]; 141 unsigned char sha1[20];
142 const char *longref; 142 const char *longref;
143 143
144 longref = fmt("refs/heads/%s", ref); 144 longref = fmt("refs/heads/%s", ref);
145 if (get_sha1(longref, sha1) == 0) 145 if (get_sha1(longref, sha1) == 0)
146 return longref; 146 return longref;
147 147
148 return ref; 148 return ref;
149} 149}
150 150
151void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, 151void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern,
152 char *path, int pager) 152 char *path, int pager)
153{ 153{
154 struct rev_info rev; 154 struct rev_info rev;
155 struct commit *commit; 155 struct commit *commit;
156 const char *argv[] = {NULL, NULL, NULL, NULL, NULL}; 156 const char *argv[] = {NULL, NULL, NULL, NULL, NULL};
157 int argc = 2; 157 int argc = 2;
158 int i, columns = 3; 158 int i, columns = 3;
159 159
160 if (!tip) 160 if (!tip)
161 tip = ctx.qry.head; 161 tip = ctx.qry.head;
162 162
163 argv[1] = disambiguate_ref(tip); 163 argv[1] = disambiguate_ref(tip);
164 164
165 if (grep && pattern) { 165 if (grep && pattern) {
166 if (!strcmp(grep, "grep") || !strcmp(grep, "author") || 166 if (!strcmp(grep, "grep") || !strcmp(grep, "author") ||
167 !strcmp(grep, "committer")) 167 !strcmp(grep, "committer"))
168 argv[argc++] = fmt("--%s=%s", grep, pattern); 168 argv[argc++] = fmt("--%s=%s", grep, pattern);
169 if (!strcmp(grep, "range")) 169 if (!strcmp(grep, "range"))
170 argv[1] = pattern; 170 argv[1] = pattern;
171 } 171 }
172 172
173 if (path) { 173 if (path) {
174 argv[argc++] = "--"; 174 argv[argc++] = "--";
175 argv[argc++] = path; 175 argv[argc++] = path;
176 } 176 }
177 init_revisions(&rev, NULL); 177 init_revisions(&rev, NULL);
178 rev.abbrev = DEFAULT_ABBREV; 178 rev.abbrev = DEFAULT_ABBREV;
179 rev.commit_format = CMIT_FMT_DEFAULT; 179 rev.commit_format = CMIT_FMT_DEFAULT;
180 rev.verbose_header = 1; 180 rev.verbose_header = 1;
181 rev.show_root_diff = 0; 181 rev.show_root_diff = 0;
182 setup_revisions(argc, argv, &rev, NULL); 182 setup_revisions(argc, argv, &rev, NULL);
183 load_ref_decorations(DECORATE_FULL_REFS); 183 load_ref_decorations(DECORATE_FULL_REFS);
184 rev.show_decorations = 1; 184 rev.show_decorations = 1;
185 rev.grep_filter.regflags |= REG_ICASE; 185 rev.grep_filter.regflags |= REG_ICASE;
186 compile_grep_patterns(&rev.grep_filter); 186 compile_grep_patterns(&rev.grep_filter);
187 prepare_revision_walk(&rev); 187 prepare_revision_walk(&rev);
188 188
189 if (pager) 189 if (pager)
190 html("<table class='list nowrap'>"); 190 html("<table class='list nowrap'>");
191 191
192 html("<tr class='nohover'><th class='left'>Age</th>" 192 html("<tr class='nohover'><th class='left'>Age</th>"
193 "<th class='left'>Commit message"); 193 "<th class='left'>Commit message");
194 if (pager) { 194 if (pager) {
195 html(" ("); 195 html(" (");
196 cgit_log_link(ctx.qry.showmsg ? "Collapse" : "Expand", NULL, 196 cgit_log_link(ctx.qry.showmsg ? "Collapse" : "Expand", NULL,
197 NULL, ctx.qry.head, ctx.qry.sha1, 197 NULL, ctx.qry.head, ctx.qry.sha1,
198 ctx.qry.vpath, ctx.qry.ofs, ctx.qry.grep, 198 ctx.qry.vpath, ctx.qry.ofs, ctx.qry.grep,
199 ctx.qry.search, ctx.qry.showmsg ? 0 : 1); 199 ctx.qry.search, ctx.qry.showmsg ? 0 : 1);
200 html(")"); 200 html(")");
201 } 201 }
202 html("</th><th class='left'>Author</th>"); 202 html("</th><th class='left'>Author</th>");
203 if (ctx.repo->enable_log_filecount) { 203 if (ctx.repo->enable_log_filecount) {
204 html("<th class='left'>Files</th>"); 204 html("<th class='left'>Files</th>");
205 columns++; 205 columns++;
206 if (ctx.repo->enable_log_linecount) { 206 if (ctx.repo->enable_log_linecount) {
207 html("<th class='left'>Lines</th>"); 207 html("<th class='left'>Lines</th>");
208 columns++; 208 columns++;
209 } 209 }
210 } 210 }
211 html("</tr>\n"); 211 html("</tr>\n");
212 212
213 if (ofs<0) 213 if (ofs<0)
214 ofs = 0; 214 ofs = 0;
215 215
216 for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { 216 for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) {
217 free(commit->buffer); 217 free(commit->buffer);
218 commit->buffer = NULL; 218 commit->buffer = NULL;
219 free_commit_list(commit->parents); 219 free_commit_list(commit->parents);
220 commit->parents = NULL; 220 commit->parents = NULL;
221 } 221 }
222 222
223 for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { 223 for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) {
224 print_commit(commit); 224 print_commit(commit);
225 free(commit->buffer); 225 free(commit->buffer);
226 commit->buffer = NULL; 226 commit->buffer = NULL;
227 free_commit_list(commit->parents); 227 free_commit_list(commit->parents);
228 commit->parents = NULL; 228 commit->parents = NULL;
229 } 229 }
230 if (pager) { 230 if (pager) {
231 htmlf("</table><div class='pager'>", 231 html("</table><div class='pager'>");
232 columns);
233 if (ofs > 0) { 232 if (ofs > 0) {
234 cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, 233 cgit_log_link("[prev]", NULL, NULL, ctx.qry.head,
235 ctx.qry.sha1, ctx.qry.vpath, 234 ctx.qry.sha1, ctx.qry.vpath,
236 ofs - cnt, ctx.qry.grep, 235 ofs - cnt, ctx.qry.grep,
237 ctx.qry.search, ctx.qry.showmsg); 236 ctx.qry.search, ctx.qry.showmsg);
238 html("&nbsp;"); 237 html("&nbsp;");
239 } 238 }
240 if ((commit = get_revision(&rev)) != NULL) { 239 if ((commit = get_revision(&rev)) != NULL) {
241 cgit_log_link("[next]", NULL, NULL, ctx.qry.head, 240 cgit_log_link("[next]", NULL, NULL, ctx.qry.head,
242 ctx.qry.sha1, ctx.qry.vpath, 241 ctx.qry.sha1, ctx.qry.vpath,
243 ofs + cnt, ctx.qry.grep, 242 ofs + cnt, ctx.qry.grep,
244 ctx.qry.search, ctx.qry.showmsg); 243 ctx.qry.search, ctx.qry.showmsg);
245 } 244 }
246 html("</div>"); 245 html("</div>");
247 } else if ((commit = get_revision(&rev)) != NULL) { 246 } else if ((commit = get_revision(&rev)) != NULL) {
248 html("<tr class='nohover'><td colspan='3'>"); 247 html("<tr class='nohover'><td colspan='3'>");
249 cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, 248 cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL,
250 ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg); 249 ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg);
251 html("</td></tr>\n"); 250 html("</td></tr>\n");
252 } 251 }
253} 252}