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