diff options
author | John Keeping | 2018-03-31 15:11:05 +0100 |
---|---|---|
committer | Jason A. Donenfeld | 2018-06-27 18:11:19 +0200 |
commit | 71d14d9c98c39a6683780060f84429a3a7e5b348 (patch) | |
tree | 12c3a446f63c1e8ed756ffc8a76b4e4daa4f5d6b /ui-refs.c | |
parent | e491eaa5df3055dc419d9d3cb75421e8a8c43944 (diff) | |
download | cgit-71d14d9c98c39a6683780060f84429a3a7e5b348.tar.gz cgit-71d14d9c98c39a6683780060f84429a3a7e5b348.tar.bz2 cgit-71d14d9c98c39a6683780060f84429a3a7e5b348.zip |
ui-refs: use shared function to print tag downloads
cgit_compose_snapshot_prefix() is identical to print_tag_downloads(), so
remove the latter and use the function from ui-shared.c instead.
Signed-off-by: John Keeping <john@keeping.me.uk>
Reviewed-by: Christian Hesse <mail@eworm.de>
Diffstat (limited to 'ui-refs.c')
-rw-r--r-- | ui-refs.c | 27 |
1 files changed, 1 insertions, 26 deletions
@@ -90,31 +90,6 @@ static void print_tag_header(void) | |||
90 | "<th class='left' colspan='2'>Age</th></tr>\n"); | 90 | "<th class='left' colspan='2'>Age</th></tr>\n"); |
91 | } | 91 | } |
92 | 92 | ||
93 | static void print_tag_downloads(const struct cgit_repo *repo, const char *ref) | ||
94 | { | ||
95 | const struct cgit_snapshot_format* f; | ||
96 | const char *basename; | ||
97 | struct strbuf filename = STRBUF_INIT; | ||
98 | size_t prefixlen; | ||
99 | |||
100 | basename = cgit_snapshot_prefix(repo); | ||
101 | if (starts_with(ref, basename)) | ||
102 | strbuf_addstr(&filename, ref); | ||
103 | else | ||
104 | cgit_compose_snapshot_prefix(&filename, basename, ref); | ||
105 | prefixlen = filename.len; | ||
106 | for (f = cgit_snapshot_formats; f->suffix; f++) { | ||
107 | if (!(repo->snapshots & f->bit)) | ||
108 | continue; | ||
109 | strbuf_setlen(&filename, prefixlen); | ||
110 | strbuf_addstr(&filename, f->suffix); | ||
111 | cgit_snapshot_link(filename.buf, NULL, NULL, NULL, NULL, filename.buf); | ||
112 | html(" "); | ||
113 | } | ||
114 | |||
115 | strbuf_release(&filename); | ||
116 | } | ||
117 | |||
118 | static int print_tag(struct refinfo *ref) | 93 | static int print_tag(struct refinfo *ref) |
119 | { | 94 | { |
120 | struct tag *tag = NULL; | 95 | struct tag *tag = NULL; |
@@ -134,7 +109,7 @@ static int print_tag(struct refinfo *ref) | |||
134 | cgit_tag_link(name, NULL, NULL, name); | 109 | cgit_tag_link(name, NULL, NULL, name); |
135 | html("</td><td>"); | 110 | html("</td><td>"); |
136 | if (ctx.repo->snapshots && (obj->type == OBJ_COMMIT)) | 111 | if (ctx.repo->snapshots && (obj->type == OBJ_COMMIT)) |
137 | print_tag_downloads(ctx.repo, name); | 112 | cgit_print_snapshot_links(ctx.repo, name, " "); |
138 | else | 113 | else |
139 | cgit_object_link(obj); | 114 | cgit_object_link(obj); |
140 | html("</td><td>"); | 115 | html("</td><td>"); |