diff options
-rw-r--r-- | cgit.c | 4 | ||||
-rw-r--r-- | cgit.h | 11 | ||||
-rw-r--r-- | ui-commit.c | 3 | ||||
-rw-r--r-- | ui-shared.c | 6 | ||||
-rw-r--r-- | ui-snapshot.c | 38 |
5 files changed, 41 insertions, 21 deletions
@@ -68,9 +68,9 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
68 | setenv("GIT_DIR", cgit_repo->path, 1); | 68 | setenv("GIT_DIR", cgit_repo->path, 1); |
69 | 69 | ||
70 | if ((cgit_cmd == CMD_SNAPSHOT) && cgit_repo->snapshots) { | 70 | if ((cgit_cmd == CMD_SNAPSHOT) && cgit_repo->snapshots) { |
71 | cgit_print_snapshot(item, cgit_query_sha1, | 71 | cgit_print_snapshot(item, cgit_query_head, cgit_query_sha1, |
72 | cgit_repobasename(cgit_repo->url), | 72 | cgit_repobasename(cgit_repo->url), |
73 | cgit_query_name, | 73 | cgit_query_path, |
74 | cgit_repo->snapshots ); | 74 | cgit_repo->snapshots ); |
75 | return; | 75 | return; |
76 | } | 76 | } |
@@ -214,6 +214,8 @@ extern void cgit_log_link(char *name, char *title, char *class, char *head, | |||
214 | char *rev, char *path, int ofs); | 214 | char *rev, char *path, int ofs); |
215 | extern void cgit_commit_link(char *name, char *title, char *class, char *head, | 215 | extern void cgit_commit_link(char *name, char *title, char *class, char *head, |
216 | char *rev); | 216 | char *rev); |
217 | extern void cgit_snapshot_link(char *name, char *title, char *class, | ||
218 | char *head, char *rev, char *archivename); | ||
217 | extern void cgit_diff_link(char *name, char *title, char *class, char *head, | 219 | extern void cgit_diff_link(char *name, char *title, char *class, char *head, |
218 | char *new_rev, char *old_rev, char *path); | 220 | char *new_rev, char *old_rev, char *path); |
219 | 221 | ||
@@ -237,10 +239,11 @@ extern void cgit_print_tree(const char *rev, char *path); | |||
237 | extern void cgit_print_commit(char *hex); | 239 | extern void cgit_print_commit(char *hex); |
238 | extern void cgit_print_tag(char *revname); | 240 | extern void cgit_print_tag(char *revname); |
239 | extern void cgit_print_diff(const char *new_hex, const char *old_hex); | 241 | extern void cgit_print_diff(const char *new_hex, const char *old_hex); |
240 | extern void cgit_print_snapshot(struct cacheitem *item, const char *hex, | 242 | extern void cgit_print_snapshot(struct cacheitem *item, const char *head, |
241 | const char *prefix, const char *filename, | 243 | const char *hex, const char *prefix, |
242 | int snapshot); | 244 | const char *filename, int snapshot); |
243 | extern void cgit_print_snapshot_links(const char *repo, const char *hex,int snapshots); | 245 | extern void cgit_print_snapshot_links(const char *repo, const char *head, |
246 | const char *hex, int snapshots); | ||
244 | extern int cgit_parse_snapshots_mask(const char *str); | 247 | extern int cgit_parse_snapshots_mask(const char *str); |
245 | 248 | ||
246 | #endif /* CGIT_H */ | 249 | #endif /* CGIT_H */ |
diff --git a/ui-commit.c b/ui-commit.c index 50e9e11..90e09ed 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
@@ -196,7 +196,8 @@ void cgit_print_commit(char *hex) | |||
196 | } | 196 | } |
197 | if (cgit_repo->snapshots) { | 197 | if (cgit_repo->snapshots) { |
198 | html("<tr><th>download</th><td colspan='2' class='sha1'>"); | 198 | html("<tr><th>download</th><td colspan='2' class='sha1'>"); |
199 | cgit_print_snapshot_links(cgit_query_repo,hex,cgit_repo->snapshots); | 199 | cgit_print_snapshot_links(cgit_query_repo, cgit_query_head, |
200 | hex, cgit_repo->snapshots); | ||
200 | html("</td></tr>"); | 201 | html("</td></tr>"); |
201 | } | 202 | } |
202 | html("</table>\n"); | 203 | html("</table>\n"); |
diff --git a/ui-shared.c b/ui-shared.c index ca2ee82..5c5bcf3 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -227,6 +227,12 @@ void cgit_commit_link(char *name, char *title, char *class, char *head, | |||
227 | reporevlink("commit", name, title, class, head, rev, NULL); | 227 | reporevlink("commit", name, title, class, head, rev, NULL); |
228 | } | 228 | } |
229 | 229 | ||
230 | void cgit_snapshot_link(char *name, char *title, char *class, char *head, | ||
231 | char *rev, char *archivename) | ||
232 | { | ||
233 | reporevlink("snapshot", name, title, class, head, rev, archivename); | ||
234 | } | ||
235 | |||
230 | void cgit_diff_link(char *name, char *title, char *class, char *head, | 236 | void cgit_diff_link(char *name, char *title, char *class, char *head, |
231 | char *new_rev, char *old_rev, char *path) | 237 | char *new_rev, char *old_rev, char *path) |
232 | { | 238 | { |
diff --git a/ui-snapshot.c b/ui-snapshot.c index d6be55b..f9879ed 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c | |||
@@ -65,16 +65,19 @@ static const struct snapshot_archive_t { | |||
65 | { ".tar", "application/x-tar", write_tar_archive, 0x8 } | 65 | { ".tar", "application/x-tar", write_tar_archive, 0x8 } |
66 | }; | 66 | }; |
67 | 67 | ||
68 | void cgit_print_snapshot(struct cacheitem *item, const char *hex, | 68 | void cgit_print_snapshot(struct cacheitem *item, const char *head, |
69 | const char *prefix, const char *filename, | 69 | const char *hex, const char *prefix, |
70 | int snapshots) | 70 | const char *filename, int snapshots) |
71 | { | 71 | { |
72 | int fnl = strlen(filename); | 72 | int fnl = strlen(filename); |
73 | int f; | 73 | int f, n; |
74 | for(f=0;f<(sizeof(snapshot_archives)/sizeof(*snapshot_archives));++f) { | 74 | |
75 | n = sizeof(snapshot_archives) / sizeof(*snapshot_archives); | ||
76 | for(f=0; f<n; f++) { | ||
75 | const struct snapshot_archive_t* sat = &snapshot_archives[f]; | 77 | const struct snapshot_archive_t* sat = &snapshot_archives[f]; |
76 | int sl; | 78 | int sl; |
77 | if(!(snapshots&sat->bit)) continue; | 79 | if(!(snapshots & sat->bit)) |
80 | continue; | ||
78 | sl = strlen(sat->suffix); | 81 | sl = strlen(sat->suffix); |
79 | if(fnl<sl || strcmp(&filename[fnl-sl],sat->suffix)) | 82 | if(fnl<sl || strcmp(&filename[fnl-sl],sat->suffix)) |
80 | continue; | 83 | continue; |
@@ -83,6 +86,8 @@ void cgit_print_snapshot(struct cacheitem *item, const char *hex, | |||
83 | struct commit *commit; | 86 | struct commit *commit; |
84 | unsigned char sha1[20]; | 87 | unsigned char sha1[20]; |
85 | 88 | ||
89 | if (!hex) | ||
90 | hex = head; | ||
86 | if(get_sha1(hex, sha1)) { | 91 | if(get_sha1(hex, sha1)) { |
87 | cgit_print_error(fmt("Bad object id: %s", hex)); | 92 | cgit_print_error(fmt("Bad object id: %s", hex)); |
88 | return; | 93 | return; |
@@ -105,17 +110,22 @@ void cgit_print_snapshot(struct cacheitem *item, const char *hex, | |||
105 | cgit_print_error(fmt("Unsupported snapshot format: %s", filename)); | 110 | cgit_print_error(fmt("Unsupported snapshot format: %s", filename)); |
106 | } | 111 | } |
107 | 112 | ||
108 | void cgit_print_snapshot_links(const char *repo,const char *hex,int snapshots) | 113 | void cgit_print_snapshot_links(const char *repo, const char *head, |
114 | const char *hex, int snapshots) | ||
109 | { | 115 | { |
110 | char *filename; | 116 | char *filename; |
111 | int f; | 117 | int f, n; |
112 | for(f=0;f<(sizeof(snapshot_archives)/sizeof(*snapshot_archives));++f) { | 118 | |
119 | n = sizeof(snapshot_archives) / sizeof(*snapshot_archives); | ||
120 | for(f=0; f<n ;f++) { | ||
113 | const struct snapshot_archive_t* sat = &snapshot_archives[f]; | 121 | const struct snapshot_archive_t* sat = &snapshot_archives[f]; |
114 | if(!(snapshots&sat->bit)) continue; | 122 | if(!(snapshots & sat->bit)) |
115 | filename = fmt("%s-%s%s",cgit_repobasename(repo),hex,sat->suffix); | 123 | continue; |
116 | htmlf("<a href='%s'>%s</a><br/>", | 124 | filename = fmt("%s-%s%s", cgit_repobasename(repo), hex, |
117 | cgit_fileurl(repo,"snapshot",filename, | 125 | sat->suffix); |
118 | fmt("id=%s&name=%s",hex,filename)), filename); | 126 | cgit_snapshot_link(filename, NULL, NULL, (char *)head, |
127 | (char *)hex, filename); | ||
128 | html("<br/>"); | ||
119 | } | 129 | } |
120 | } | 130 | } |
121 | 131 | ||