-rw-r--r-- | ui-snapshot.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c index d6be55b..f9879ed 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c | |||
@@ -66,14 +66,17 @@ static const struct snapshot_archive_t { | |||
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)) |
@@ -84,4 +87,6 @@ void cgit_print_snapshot(struct cacheitem *item, const char *hex, | |||
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)); |
@@ -106,15 +111,20 @@ void cgit_print_snapshot(struct cacheitem *item, const char *hex, | |||
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 | } |