|
diff --git a/cgit.c b/cgit.c index e5d8fbd..34e590e 100644 --- a/ cgit.c+++ b/ cgit.c |
|
@@ -73,49 +73,49 @@ static void cgit_print_repo_page(struct cacheitem *item) |
73 | cgit_repo->url, cgit_query_name); |
73 | cgit_repo->url, cgit_query_name); |
74 | return; |
74 | return; |
75 | } |
75 | } |
76 | |
76 | |
77 | if (cgit_cmd == CMD_BLOB) { |
77 | if (cgit_cmd == CMD_BLOB) { |
78 | cgit_print_blob(item, cgit_query_sha1, cgit_query_path); |
78 | cgit_print_blob(item, cgit_query_sha1, cgit_query_path); |
79 | return; |
79 | return; |
80 | } |
80 | } |
81 | |
81 | |
82 | show_search = (cgit_cmd == CMD_LOG); |
82 | show_search = (cgit_cmd == CMD_LOG); |
83 | cgit_print_docstart(title, item); |
83 | cgit_print_docstart(title, item); |
84 | if (!cgit_cmd) { |
84 | if (!cgit_cmd) { |
85 | cgit_print_pageheader("summary", show_search); |
85 | cgit_print_pageheader("summary", show_search); |
86 | cgit_print_summary(); |
86 | cgit_print_summary(); |
87 | cgit_print_docend(); |
87 | cgit_print_docend(); |
88 | return; |
88 | return; |
89 | } |
89 | } |
90 | |
90 | |
91 | cgit_print_pageheader(cgit_query_page, show_search); |
91 | cgit_print_pageheader(cgit_query_page, show_search); |
92 | |
92 | |
93 | switch(cgit_cmd) { |
93 | switch(cgit_cmd) { |
94 | case CMD_LOG: |
94 | case CMD_LOG: |
95 | cgit_print_log(cgit_query_head, cgit_query_ofs, |
95 | cgit_print_log(cgit_query_head, cgit_query_ofs, |
96 | cgit_max_commit_count, cgit_query_search, |
96 | cgit_max_commit_count, cgit_query_search, |
97 | cgit_query_path); |
97 | cgit_query_path, 1); |
98 | break; |
98 | break; |
99 | case CMD_TREE: |
99 | case CMD_TREE: |
100 | cgit_print_tree(cgit_query_head, cgit_query_sha1, cgit_query_path); |
100 | cgit_print_tree(cgit_query_head, cgit_query_sha1, cgit_query_path); |
101 | break; |
101 | break; |
102 | case CMD_COMMIT: |
102 | case CMD_COMMIT: |
103 | cgit_print_commit(cgit_query_head); |
103 | cgit_print_commit(cgit_query_head); |
104 | break; |
104 | break; |
105 | case CMD_VIEW: |
105 | case CMD_VIEW: |
106 | cgit_print_view(cgit_query_sha1, cgit_query_path); |
106 | cgit_print_view(cgit_query_sha1, cgit_query_path); |
107 | break; |
107 | break; |
108 | case CMD_DIFF: |
108 | case CMD_DIFF: |
109 | cgit_print_diff(cgit_query_head, cgit_query_sha1, cgit_query_sha2, |
109 | cgit_print_diff(cgit_query_head, cgit_query_sha1, cgit_query_sha2, |
110 | cgit_query_path); |
110 | cgit_query_path); |
111 | break; |
111 | break; |
112 | default: |
112 | default: |
113 | cgit_print_error("Invalid request"); |
113 | cgit_print_error("Invalid request"); |
114 | } |
114 | } |
115 | cgit_print_docend(); |
115 | cgit_print_docend(); |
116 | } |
116 | } |
117 | |
117 | |
118 | static void cgit_fill_cache(struct cacheitem *item, int use_cache) |
118 | static void cgit_fill_cache(struct cacheitem *item, int use_cache) |
119 | { |
119 | { |
120 | static char buf[PATH_MAX]; |
120 | static char buf[PATH_MAX]; |
121 | int stdout2; |
121 | int stdout2; |
|
|
diff --git a/cgit.h b/cgit.h index 5c55bec..d6bcde2 100644 --- a/ cgit.h+++ b/ cgit.h |
|
@@ -192,36 +192,36 @@ extern void cgit_parse_url(const char *url); |
192 | |
192 | |
193 | extern char *cache_safe_filename(const char *unsafe); |
193 | extern char *cache_safe_filename(const char *unsafe); |
194 | extern int cache_lock(struct cacheitem *item); |
194 | extern int cache_lock(struct cacheitem *item); |
195 | extern int cache_unlock(struct cacheitem *item); |
195 | extern int cache_unlock(struct cacheitem *item); |
196 | extern int cache_cancel_lock(struct cacheitem *item); |
196 | extern int cache_cancel_lock(struct cacheitem *item); |
197 | extern int cache_exist(struct cacheitem *item); |
197 | extern int cache_exist(struct cacheitem *item); |
198 | extern int cache_expired(struct cacheitem *item); |
198 | extern int cache_expired(struct cacheitem *item); |
199 | |
199 | |
200 | extern char *cgit_repourl(const char *reponame); |
200 | extern char *cgit_repourl(const char *reponame); |
201 | extern char *cgit_pageurl(const char *reponame, const char *pagename, |
201 | extern char *cgit_pageurl(const char *reponame, const char *pagename, |
202 | const char *query); |
202 | const char *query); |
203 | |
203 | |
204 | extern void cgit_print_error(char *msg); |
204 | extern void cgit_print_error(char *msg); |
205 | extern void cgit_print_date(time_t secs, char *format); |
205 | extern void cgit_print_date(time_t secs, char *format); |
206 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); |
206 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); |
207 | extern void cgit_print_docstart(char *title, struct cacheitem *item); |
207 | extern void cgit_print_docstart(char *title, struct cacheitem *item); |
208 | extern void cgit_print_docend(); |
208 | extern void cgit_print_docend(); |
209 | extern void cgit_print_pageheader(char *title, int show_search); |
209 | extern void cgit_print_pageheader(char *title, int show_search); |
210 | extern void cgit_print_snapshot_start(const char *mimetype, |
210 | extern void cgit_print_snapshot_start(const char *mimetype, |
211 | const char *filename, |
211 | const char *filename, |
212 | struct cacheitem *item); |
212 | struct cacheitem *item); |
213 | |
213 | |
214 | extern void cgit_print_repolist(struct cacheitem *item); |
214 | extern void cgit_print_repolist(struct cacheitem *item); |
215 | extern void cgit_print_summary(); |
215 | extern void cgit_print_summary(); |
216 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path); |
216 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager); |
217 | extern void cgit_print_view(const char *hex, char *path); |
217 | extern void cgit_print_view(const char *hex, char *path); |
218 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); |
218 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); |
219 | extern void cgit_print_tree(const char *rev, const char *hex, char *path); |
219 | extern void cgit_print_tree(const char *rev, const char *hex, char *path); |
220 | extern void cgit_print_commit(const char *hex); |
220 | extern void cgit_print_commit(const char *hex); |
221 | extern void cgit_print_diff(const char *head, const char *old_hex, const char *new_hex, |
221 | extern void cgit_print_diff(const char *head, const char *old_hex, const char *new_hex, |
222 | char *path); |
222 | char *path); |
223 | extern void cgit_print_snapshot(struct cacheitem *item, const char *hex, |
223 | extern void cgit_print_snapshot(struct cacheitem *item, const char *hex, |
224 | const char *format, const char *prefix, |
224 | const char *format, const char *prefix, |
225 | const char *filename); |
225 | const char *filename); |
226 | |
226 | |
227 | #endif /* CGIT_H */ |
227 | #endif /* CGIT_H */ |
|
|
diff --git a/ui-log.c b/ui-log.c index 75bbbe4..bb17e1d 100644 --- a/ ui-log.c+++ b/ ui-log.c |
|
@@ -33,49 +33,49 @@ void print_commit(struct commit *commit) |
33 | html("</td><td>"); |
33 | html("</td><td>"); |
34 | char *qry = fmt("h=%s", sha1_to_hex(commit->object.sha1)); |
34 | char *qry = fmt("h=%s", sha1_to_hex(commit->object.sha1)); |
35 | char *url = cgit_pageurl(cgit_query_repo, "commit", qry); |
35 | char *url = cgit_pageurl(cgit_query_repo, "commit", qry); |
36 | html_link_open(url, NULL, NULL); |
36 | html_link_open(url, NULL, NULL); |
37 | html_ntxt(cgit_max_msg_len, info->subject); |
37 | html_ntxt(cgit_max_msg_len, info->subject); |
38 | html_link_close(); |
38 | html_link_close(); |
39 | if (cgit_repo->enable_log_filecount) { |
39 | if (cgit_repo->enable_log_filecount) { |
40 | files = 0; |
40 | files = 0; |
41 | lines = 0; |
41 | lines = 0; |
42 | cgit_diff_commit(commit, inspect_files); |
42 | cgit_diff_commit(commit, inspect_files); |
43 | html("</td><td class='right'>"); |
43 | html("</td><td class='right'>"); |
44 | htmlf("%d", files); |
44 | htmlf("%d", files); |
45 | if (cgit_repo->enable_log_linecount) { |
45 | if (cgit_repo->enable_log_linecount) { |
46 | html("</td><td class='right'>"); |
46 | html("</td><td class='right'>"); |
47 | htmlf("%d", lines); |
47 | htmlf("%d", lines); |
48 | } |
48 | } |
49 | } |
49 | } |
50 | html("</td><td>"); |
50 | html("</td><td>"); |
51 | html_txt(info->author); |
51 | html_txt(info->author); |
52 | html("</td></tr>\n"); |
52 | html("</td></tr>\n"); |
53 | cgit_free_commitinfo(info); |
53 | cgit_free_commitinfo(info); |
54 | } |
54 | } |
55 | |
55 | |
56 | |
56 | |
57 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path) |
57 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager) |
58 | { |
58 | { |
59 | struct rev_info rev; |
59 | struct rev_info rev; |
60 | struct commit *commit; |
60 | struct commit *commit; |
61 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; |
61 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; |
62 | int argc = 2; |
62 | int argc = 2; |
63 | int i; |
63 | int i; |
64 | |
64 | |
65 | if (grep) |
65 | if (grep) |
66 | argv[argc++] = fmt("--grep=%s", grep); |
66 | argv[argc++] = fmt("--grep=%s", grep); |
67 | if (path) { |
67 | if (path) { |
68 | argv[argc++] = "--"; |
68 | argv[argc++] = "--"; |
69 | argv[argc++] = path; |
69 | argv[argc++] = path; |
70 | } |
70 | } |
71 | init_revisions(&rev, NULL); |
71 | init_revisions(&rev, NULL); |
72 | rev.abbrev = DEFAULT_ABBREV; |
72 | rev.abbrev = DEFAULT_ABBREV; |
73 | rev.commit_format = CMIT_FMT_DEFAULT; |
73 | rev.commit_format = CMIT_FMT_DEFAULT; |
74 | rev.verbose_header = 1; |
74 | rev.verbose_header = 1; |
75 | rev.show_root_diff = 0; |
75 | rev.show_root_diff = 0; |
76 | setup_revisions(argc, argv, &rev, NULL); |
76 | setup_revisions(argc, argv, &rev, NULL); |
77 | if (rev.grep_filter) { |
77 | if (rev.grep_filter) { |
78 | rev.grep_filter->regflags |= REG_ICASE; |
78 | rev.grep_filter->regflags |= REG_ICASE; |
79 | compile_grep_patterns(rev.grep_filter); |
79 | compile_grep_patterns(rev.grep_filter); |
80 | } |
80 | } |
81 | prepare_revision_walk(&rev); |
81 | prepare_revision_walk(&rev); |
@@ -89,40 +89,42 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path) |
89 | if (cgit_repo->enable_log_linecount) |
89 | if (cgit_repo->enable_log_linecount) |
90 | html("<th class='left'>Lines</th>"); |
90 | html("<th class='left'>Lines</th>"); |
91 | } |
91 | } |
92 | html("<th class='left'>Author</th></tr>\n"); |
92 | html("<th class='left'>Author</th></tr>\n"); |
93 | |
93 | |
94 | if (ofs<0) |
94 | if (ofs<0) |
95 | ofs = 0; |
95 | ofs = 0; |
96 | |
96 | |
97 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
97 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
98 | free(commit->buffer); |
98 | free(commit->buffer); |
99 | commit->buffer = NULL; |
99 | commit->buffer = NULL; |
100 | free_commit_list(commit->parents); |
100 | free_commit_list(commit->parents); |
101 | commit->parents = NULL; |
101 | commit->parents = NULL; |
102 | } |
102 | } |
103 | |
103 | |
104 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { |
104 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { |
105 | print_commit(commit); |
105 | print_commit(commit); |
106 | free(commit->buffer); |
106 | free(commit->buffer); |
107 | commit->buffer = NULL; |
107 | commit->buffer = NULL; |
108 | free_commit_list(commit->parents); |
108 | free_commit_list(commit->parents); |
109 | commit->parents = NULL; |
109 | commit->parents = NULL; |
110 | } |
110 | } |
111 | html("</table>\n"); |
111 | html("</table>\n"); |
112 | |
112 | |
113 | html("<div class='pager'>"); |
113 | if (pager) { |
114 | if (ofs > 0) { |
114 | html("<div class='pager'>"); |
115 | html(" <a href='"); |
115 | if (ofs > 0) { |
116 | html(cgit_pageurl(cgit_query_repo, cgit_query_page, |
116 | html(" <a href='"); |
117 | fmt("h=%s&ofs=%d", tip, ofs-cnt))); |
117 | html(cgit_pageurl(cgit_query_repo, cgit_query_page, |
118 | html("'>[prev]</a> "); |
118 | fmt("h=%s&ofs=%d", tip, ofs-cnt))); |
119 | } |
119 | html("'>[prev]</a> "); |
120 | |
120 | } |
121 | if ((commit = get_revision(&rev)) != NULL) { |
121 | |
122 | html(" <a href='"); |
122 | if ((commit = get_revision(&rev)) != NULL) { |
123 | html(cgit_pageurl(cgit_query_repo, "log", |
123 | html(" <a href='"); |
124 | fmt("h=%s&ofs=%d", tip, ofs+cnt))); |
124 | html(cgit_pageurl(cgit_query_repo, "log", |
125 | html("'>[next]</a> "); |
125 | fmt("h=%s&ofs=%d", tip, ofs+cnt))); |
| |
126 | html("'>[next]</a> "); |
| |
127 | } |
| |
128 | html("</div>"); |
126 | } |
129 | } |
127 | html("</div>"); |
| |
128 | } |
130 | } |
|