summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c2
-rw-r--r--cgit.h2
-rw-r--r--ui-commit.c3
-rw-r--r--ui-log.c7
-rw-r--r--ui-shared.c16
-rw-r--r--ui-summary.c18
-rw-r--r--ui-tree.c1
7 files changed, 31 insertions, 18 deletions
diff --git a/cgit.c b/cgit.c
index 1c213c7..f5135d9 100644
--- a/cgit.c
+++ b/cgit.c
@@ -97,13 +97,13 @@ static void cgit_print_repo_page(struct cacheitem *item)
97 cgit_query_path, 1); 97 cgit_query_path, 1);
98 break; 98 break;
99 case CMD_TREE: 99 case CMD_TREE:
100 cgit_print_tree(cgit_query_sha1, cgit_query_path); 100 cgit_print_tree(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_sha1);
104 break; 104 break;
105 case CMD_DIFF: 105 case CMD_DIFF:
106 cgit_print_diff(cgit_query_head, cgit_query_sha1, cgit_query_sha2, 106 cgit_print_diff(cgit_query_head, cgit_query_sha1, cgit_query_sha2,
107 cgit_query_path); 107 cgit_query_path);
108 break; 108 break;
109 default: 109 default:
diff --git a/cgit.h b/cgit.h
index b2f6361..c276a24 100644
--- a/cgit.h
+++ b/cgit.h
@@ -202,12 +202,14 @@ extern char *cgit_pageurl(const char *reponame, const char *pagename,
202 const char *query); 202 const char *query);
203 203
204extern void cgit_tree_link(char *name, char *title, char *class, char *head, 204extern void cgit_tree_link(char *name, char *title, char *class, char *head,
205 char *rev, char *path); 205 char *rev, char *path);
206extern void cgit_log_link(char *name, char *title, char *class, char *head, 206extern void cgit_log_link(char *name, char *title, char *class, char *head,
207 char *rev, char *path); 207 char *rev, char *path);
208extern void cgit_commit_link(char *name, char *title, char *class, char *head,
209 char *rev);
208 210
209extern void cgit_print_error(char *msg); 211extern void cgit_print_error(char *msg);
210extern void cgit_print_date(time_t secs, char *format); 212extern void cgit_print_date(time_t secs, char *format);
211extern void cgit_print_age(time_t t, time_t max_relative, char *format); 213extern void cgit_print_age(time_t t, time_t max_relative, char *format);
212extern void cgit_print_docstart(char *title, struct cacheitem *item); 214extern void cgit_print_docstart(char *title, struct cacheitem *item);
213extern void cgit_print_docend(); 215extern void cgit_print_docend();
diff --git a/ui-commit.c b/ui-commit.c
index 885f870..8864fc6 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -153,12 +153,15 @@ void cgit_print_commit(const char *hex)
153 unsigned char sha1[20]; 153 unsigned char sha1[20];
154 char *query; 154 char *query;
155 char *filename; 155 char *filename;
156 char *tmp; 156 char *tmp;
157 int i; 157 int i;
158 158
159 if (!hex)
160 hex = cgit_query_head;
161
159 if (get_sha1(hex, sha1)) { 162 if (get_sha1(hex, sha1)) {
160 cgit_print_error(fmt("Bad object id: %s", hex)); 163 cgit_print_error(fmt("Bad object id: %s", hex));
161 return; 164 return;
162 } 165 }
163 commit = lookup_commit_reference(sha1); 166 commit = lookup_commit_reference(sha1);
164 if (!commit) { 167 if (!commit) {
diff --git a/ui-log.c b/ui-log.c
index bb17e1d..8d774b0 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -28,17 +28,14 @@ void print_commit(struct commit *commit)
28 struct commitinfo *info; 28 struct commitinfo *info;
29 29
30 info = cgit_parse_commit(commit); 30 info = cgit_parse_commit(commit);
31 html("<tr><td>"); 31 html("<tr><td>");
32 cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); 32 cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE);
33 html("</td><td>"); 33 html("</td><td>");
34 char *qry = fmt("h=%s", sha1_to_hex(commit->object.sha1)); 34 cgit_commit_link(info->subject, NULL, NULL, cgit_query_head,
35 char *url = cgit_pageurl(cgit_query_repo, "commit", qry); 35 sha1_to_hex(commit->object.sha1));
36 html_link_open(url, NULL, NULL);
37 html_ntxt(cgit_max_msg_len, info->subject);
38 html_link_close();
39 if (cgit_repo->enable_log_filecount) { 36 if (cgit_repo->enable_log_filecount) {
40 files = 0; 37 files = 0;
41 lines = 0; 38 lines = 0;
42 cgit_diff_commit(commit, inspect_files); 39 cgit_diff_commit(commit, inspect_files);
43 html("</td><td class='right'>"); 40 html("</td><td class='right'>");
44 htmlf("%d", files); 41 htmlf("%d", files);
diff --git a/ui-shared.c b/ui-shared.c
index 64ee79c..71c899a 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -133,14 +133,14 @@ static char *repolink(char *title, char *class, char *page, char *head,
133 html_attr(head); 133 html_attr(head);
134 delim = "&amp;"; 134 delim = "&amp;";
135 } 135 }
136 return fmt("%s", delim); 136 return fmt("%s", delim);
137} 137}
138 138
139static char *reporevlink(char *page, char *name, char *title, char *class, 139static void reporevlink(char *page, char *name, char *title, char *class,
140 char *head, char *rev, char *path) 140 char *head, char *rev, char *path)
141{ 141{
142 char *delim; 142 char *delim;
143 143
144 delim = repolink(title, class, page, head, path); 144 delim = repolink(title, class, page, head, path);
145 if (rev && strcmp(rev, cgit_query_head)) { 145 if (rev && strcmp(rev, cgit_query_head)) {
146 html(delim); 146 html(delim);
@@ -161,12 +161,24 @@ void cgit_tree_link(char *name, char *title, char *class, char *head,
161void cgit_log_link(char *name, char *title, char *class, char *head, 161void cgit_log_link(char *name, char *title, char *class, char *head,
162 char *rev, char *path) 162 char *rev, char *path)
163{ 163{
164 reporevlink("log", name, title, class, head, rev, path); 164 reporevlink("log", name, title, class, head, rev, path);
165} 165}
166 166
167void cgit_commit_link(char *name, char *title, char *class, char *head,
168 char *rev)
169{
170 if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) {
171 name[cgit_max_msg_len] = '\0';
172 name[cgit_max_msg_len - 1] = '.';
173 name[cgit_max_msg_len - 2] = '.';
174 name[cgit_max_msg_len - 3] = '.';
175 }
176 reporevlink("commit", name, title, class, head, rev, NULL);
177}
178
167void cgit_print_date(time_t secs, char *format) 179void cgit_print_date(time_t secs, char *format)
168{ 180{
169 char buf[64]; 181 char buf[64];
170 struct tm *time; 182 struct tm *time;
171 183
172 time = gmtime(&secs); 184 time = gmtime(&secs);
diff --git a/ui-summary.c b/ui-summary.c
index 29b76e3..03dd078 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -12,53 +12,53 @@ static int header;
12 12
13static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, 13static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
14 int flags, void *cb_data) 14 int flags, void *cb_data)
15{ 15{
16 struct commit *commit; 16 struct commit *commit;
17 struct commitinfo *info; 17 struct commitinfo *info;
18 char buf[256], *url; 18 char buf[256];
19 char *ref;
19 20
21 ref = xstrdup(refname);
20 strncpy(buf, refname, sizeof(buf)); 22 strncpy(buf, refname, sizeof(buf));
21 commit = lookup_commit(sha1); 23 commit = lookup_commit(sha1);
22 // object is not really parsed at this point, because of some fallout 24 // object is not really parsed at this point, because of some fallout
23 // from previous calls to git functions in cgit_print_log() 25 // from previous calls to git functions in cgit_print_log()
24 commit->object.parsed = 0; 26 commit->object.parsed = 0;
25 if (commit && !parse_commit(commit)){ 27 if (commit && !parse_commit(commit)){
26 info = cgit_parse_commit(commit); 28 info = cgit_parse_commit(commit);
27 html("<tr><td>"); 29 html("<tr><td>");
28 cgit_log_link(refname, NULL, NULL, refname, NULL, NULL); 30 cgit_log_link(ref, NULL, NULL, ref, NULL, NULL);
29 html("</td><td>"); 31 html("</td><td>");
30 cgit_print_age(commit->date, -1, NULL); 32 cgit_print_age(commit->date, -1, NULL);
31 html("</td><td>"); 33 html("</td><td>");
32 html_txt(info->author); 34 html_txt(info->author);
33 html("</td><td>"); 35 html("</td><td>");
34 url = cgit_pageurl(cgit_query_repo, "commit", 36 cgit_commit_link(info->subject, NULL, NULL, ref, NULL);
35 fmt("h=%s", sha1_to_hex(sha1)));
36 html_link_open(url, NULL, NULL);
37 html_ntxt(cgit_max_msg_len, info->subject);
38 html_link_close();
39 html("</td></tr>\n"); 37 html("</td></tr>\n");
40 cgit_free_commitinfo(info); 38 cgit_free_commitinfo(info);
41 } else { 39 } else {
42 html("<tr><td>"); 40 html("<tr><td>");
43 html_txt(buf); 41 html_txt(buf);
44 html("</td><td colspan='3'>"); 42 html("</td><td colspan='3'>");
45 htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); 43 htmlf("*** bad ref %s ***", sha1_to_hex(sha1));
46 html("</td></tr>\n"); 44 html("</td></tr>\n");
47 } 45 }
46 free(ref);
48 return 0; 47 return 0;
49} 48}
50 49
51 50
52static void cgit_print_object_ref(struct object *obj) 51static void cgit_print_object_ref(struct object *obj)
53{ 52{
54 char *page, *arg, *url; 53 char *page, *arg, *url;
55 54
56 if (obj->type == OBJ_COMMIT) { 55 if (obj->type == OBJ_COMMIT) {
57 page = "commit"; 56 cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL,
58 arg = "h"; 57 cgit_query_head, sha1_to_hex(obj->sha1));
58 return;
59 } else if (obj->type == OBJ_TREE) { 59 } else if (obj->type == OBJ_TREE) {
60 page = "tree"; 60 page = "tree";
61 arg = "id"; 61 arg = "id";
62 } else { 62 } else {
63 page = "view"; 63 page = "view";
64 arg = "id"; 64 arg = "id";
diff --git a/ui-tree.c b/ui-tree.c
index e16b638..1037c82 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -55,13 +55,12 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
55 const char *pathname, unsigned int mode, int stage) 55 const char *pathname, unsigned int mode, int stage)
56{ 56{
57 char *name; 57 char *name;
58 char *fullpath; 58 char *fullpath;
59 enum object_type type; 59 enum object_type type;
60 unsigned long size = 0; 60 unsigned long size = 0;
61 char *url, *qry;
62 61
63 name = xstrdup(pathname); 62 name = xstrdup(pathname);
64 fullpath = fmt("%s%s%s", cgit_query_path ? cgit_query_path : "", 63 fullpath = fmt("%s%s%s", cgit_query_path ? cgit_query_path : "",
65 cgit_query_path ? "/" : "", name); 64 cgit_query_path ? "/" : "", name);
66 65
67 type = sha1_object_info(sha1, &size); 66 type = sha1_object_info(sha1, &size);