all repos — cgit @ 8c4c2c464b664228d4819af6ec1f8438af3c7c89

a hyperfast web frontend for git written in c

ui-snapshot.c: Prepend "V" when guessing ref names

In cgit_print_snapshot_links() we strip leading "v" and "V", while we
currently only prepend a lower case "v" when parsing a snapshot file
name. This results in broken snapshot links for tags that start with an
upper case "V". Avoid this by prepending a "V" as a fallback.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Lukas Fleischer cgit@cryptocrack.de
Wed, 10 Apr 2013 13:04:03 +0200
commit

8c4c2c464b664228d4819af6ec1f8438af3c7c89

parent

81bf4d32b377d3f2fdd7ab3ca651be99408f5c32

1 files changed, 6 insertions(+), 2 deletions(-)

jump to
M ui-snapshot.cui-snapshot.c

@@ -140,8 +140,8 @@ * Otherwise, if the snapshot name has a prefix matching the result from

* repo_basename(), we strip the basename and any following '-' and '_' * characters ("cgit-0.7.2" -> "0.7.2") and check the resulting name once * more. If this still isn't a valid commit object name, we check if pre- - * pending a 'v' to the remaining snapshot name ("0.7.2" -> "v0.7.2") gives - * us something valid. + * pending a 'v' or a 'V' to the remaining snapshot name ("0.7.2" -> + * "v0.7.2") gives us something valid. */ static const char *get_ref_from_filename(const char *url, const char *filename, const struct cgit_snapshot_format *format)

@@ -170,6 +170,10 @@ if (get_sha1(snapshot.buf, sha1) == 0)

goto out; strbuf_insert(&snapshot, 0, "v", 1); + if (get_sha1(snapshot.buf, sha1) == 0) + goto out; + + strbuf_splice(&snapshot, 0, 1, "V", 1); if (get_sha1(snapshot.buf, sha1) == 0) goto out;