summaryrefslogtreecommitdiffabout
path: root/ui-log.c
authorLars Hjemli <hjemli@gmail.com>2008-02-23 21:45:33 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-03-18 07:13:10 (UTC)
commitb1f9b9c1459cb9a30ebf80721aff6ef788d1f891 (patch) (unidiff)
tree05796a741faef90c12aadd3a5c92b702ec870c48 /ui-log.c
parentb88fb016d0209f7041ac7d3b4d2c077318407a4d (diff)
downloadcgit-b1f9b9c1459cb9a30ebf80721aff6ef788d1f891.zip
cgit-b1f9b9c1459cb9a30ebf80721aff6ef788d1f891.tar.gz
cgit-b1f9b9c1459cb9a30ebf80721aff6ef788d1f891.tar.bz2
Introduce html.h
All html-functions can be quite easily separated from the rest of cgit, so lets do it; the only issue was html_filemode which uses some git-defined macros so the function is moved into ui-shared.c::cgit_print_filemode(). Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-log.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-log.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/ui-log.c b/ui-log.c
index 72e2a4b..e1d324d 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -1,105 +1,106 @@
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 11
11int files, add_lines, rem_lines; 12int files, add_lines, rem_lines;
12 13
13void count_lines(char *line, int size) 14void count_lines(char *line, int size)
14{ 15{
15 if (size <= 0) 16 if (size <= 0)
16 return; 17 return;
17 18
18 if (line[0] == '+') 19 if (line[0] == '+')
19 add_lines++; 20 add_lines++;
20 21
21 else if (line[0] == '-') 22 else if (line[0] == '-')
22 rem_lines++; 23 rem_lines++;
23} 24}
24 25
25void inspect_files(struct diff_filepair *pair) 26void inspect_files(struct diff_filepair *pair)
26{ 27{
27 files++; 28 files++;
28 if (ctx.repo->enable_log_linecount) 29 if (ctx.repo->enable_log_linecount)
29 cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines); 30 cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines);
30} 31}
31 32
32void print_commit(struct commit *commit) 33void print_commit(struct commit *commit)
33{ 34{
34 struct commitinfo *info; 35 struct commitinfo *info;
35 36
36 info = cgit_parse_commit(commit); 37 info = cgit_parse_commit(commit);
37 html("<tr><td>"); 38 html("<tr><td>");
38 cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); 39 cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE);
39 html("</td><td>"); 40 html("</td><td>");
40 cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, 41 cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
41 sha1_to_hex(commit->object.sha1)); 42 sha1_to_hex(commit->object.sha1));
42 if (ctx.repo->enable_log_filecount) { 43 if (ctx.repo->enable_log_filecount) {
43 files = 0; 44 files = 0;
44 add_lines = 0; 45 add_lines = 0;
45 rem_lines = 0; 46 rem_lines = 0;
46 cgit_diff_commit(commit, inspect_files); 47 cgit_diff_commit(commit, inspect_files);
47 html("</td><td class='right'>"); 48 html("</td><td class='right'>");
48 htmlf("%d", files); 49 htmlf("%d", files);
49 if (ctx.repo->enable_log_linecount) { 50 if (ctx.repo->enable_log_linecount) {
50 html("</td><td class='right'>"); 51 html("</td><td class='right'>");
51 htmlf("-%d/+%d", rem_lines, add_lines); 52 htmlf("-%d/+%d", rem_lines, add_lines);
52 } 53 }
53 } 54 }
54 html("</td><td>"); 55 html("</td><td>");
55 html_txt(info->author); 56 html_txt(info->author);
56 html("</td></tr>\n"); 57 html("</td></tr>\n");
57 cgit_free_commitinfo(info); 58 cgit_free_commitinfo(info);
58} 59}
59 60
60 61
61void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, char *path, int pager) 62void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, char *path, int pager)
62{ 63{
63 struct rev_info rev; 64 struct rev_info rev;
64 struct commit *commit; 65 struct commit *commit;
65 const char *argv[] = {NULL, tip, NULL, NULL, NULL}; 66 const char *argv[] = {NULL, tip, NULL, NULL, NULL};
66 int argc = 2; 67 int argc = 2;
67 int i; 68 int i;
68 69
69 if (!tip) 70 if (!tip)
70 argv[1] = ctx.qry.head; 71 argv[1] = ctx.qry.head;
71 72
72 if (grep && pattern && (!strcmp(grep, "grep") || 73 if (grep && pattern && (!strcmp(grep, "grep") ||
73 !strcmp(grep, "author") || 74 !strcmp(grep, "author") ||
74 !strcmp(grep, "committer"))) 75 !strcmp(grep, "committer")))
75 argv[argc++] = fmt("--%s=%s", grep, pattern); 76 argv[argc++] = fmt("--%s=%s", grep, pattern);
76 77
77 if (path) { 78 if (path) {
78 argv[argc++] = "--"; 79 argv[argc++] = "--";
79 argv[argc++] = path; 80 argv[argc++] = path;
80 } 81 }
81 init_revisions(&rev, NULL); 82 init_revisions(&rev, NULL);
82 rev.abbrev = DEFAULT_ABBREV; 83 rev.abbrev = DEFAULT_ABBREV;
83 rev.commit_format = CMIT_FMT_DEFAULT; 84 rev.commit_format = CMIT_FMT_DEFAULT;
84 rev.verbose_header = 1; 85 rev.verbose_header = 1;
85 rev.show_root_diff = 0; 86 rev.show_root_diff = 0;
86 setup_revisions(argc, argv, &rev, NULL); 87 setup_revisions(argc, argv, &rev, NULL);
87 if (rev.grep_filter) { 88 if (rev.grep_filter) {
88 rev.grep_filter->regflags |= REG_ICASE; 89 rev.grep_filter->regflags |= REG_ICASE;
89 compile_grep_patterns(rev.grep_filter); 90 compile_grep_patterns(rev.grep_filter);
90 } 91 }
91 prepare_revision_walk(&rev); 92 prepare_revision_walk(&rev);
92 93
93 html("<table summary='log' class='list nowrap'>"); 94 html("<table summary='log' class='list nowrap'>");
94 html("<tr class='nohover'><th class='left'>Age</th>" 95 html("<tr class='nohover'><th class='left'>Age</th>"
95 "<th class='left'>Message</th>"); 96 "<th class='left'>Message</th>");
96 97
97 if (ctx.repo->enable_log_filecount) { 98 if (ctx.repo->enable_log_filecount) {
98 html("<th class='right'>Files</th>"); 99 html("<th class='right'>Files</th>");
99 if (ctx.repo->enable_log_linecount) 100 if (ctx.repo->enable_log_linecount)
100 html("<th class='right'>Lines</th>"); 101 html("<th class='right'>Lines</th>");
101 } 102 }
102 html("<th class='left'>Author</th></tr>\n"); 103 html("<th class='left'>Author</th></tr>\n");
103 104
104 if (ofs<0) 105 if (ofs<0)
105 ofs = 0; 106 ofs = 0;