-rw-r--r-- | Makefile | 15 | ||||
-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | ui-shared.c | 9 | ||||
-rw-r--r-- | ui-tag.c | 24 |
4 files changed, 39 insertions, 11 deletions
@@ -1,37 +1,40 @@ | |||
1 | CGIT_VERSION = v0.8.3 | 1 | CGIT_VERSION = v0.8.3 |
2 | CGIT_SCRIPT_NAME = cgit.cgi | 2 | CGIT_SCRIPT_NAME = cgit.cgi |
3 | CGIT_SCRIPT_PATH = /var/www/htdocs/cgit | 3 | CGIT_SCRIPT_PATH = /var/www/htdocs/cgit |
4 | CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) | 4 | CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) |
5 | CGIT_CONFIG = /etc/cgitrc | 5 | CGIT_CONFIG = /etc/cgitrc |
6 | CACHE_ROOT = /var/cache/cgit | 6 | CACHE_ROOT = /var/cache/cgit |
7 | SHA1_HEADER = <openssl/sha.h> | 7 | SHA1_HEADER = <openssl/sha.h> |
8 | GIT_VER = 1.6.4.3 | 8 | GIT_VER = 1.6.4.3 |
9 | GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 | 9 | GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 |
10 | INSTALL = install | 10 | INSTALL = install |
11 | 11 | ||
12 | # Define NO_STRCASESTR if you don't have strcasestr. | 12 | # Define NO_STRCASESTR if you don't have strcasestr. |
13 | # | 13 | # |
14 | # Define NO_OPENSSL to disable linking with OpenSSL and use bundled SHA1 | ||
15 | # implementation (slower). | ||
16 | # | ||
14 | # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin). | 17 | # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin). |
15 | # | 18 | # |
16 | 19 | ||
17 | #-include config.mak | 20 | #-include config.mak |
18 | 21 | ||
19 | # | 22 | # |
20 | # Platform specific tweaks | 23 | # Platform specific tweaks |
21 | # | 24 | # |
22 | 25 | ||
23 | uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') | 26 | uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') |
24 | uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not') | 27 | uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not') |
25 | uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not') | 28 | uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not') |
26 | 29 | ||
27 | ifeq ($(uname_O),Cygwin) | 30 | ifeq ($(uname_O),Cygwin) |
28 | NO_STRCASESTR = YesPlease | 31 | NO_STRCASESTR = YesPlease |
29 | NEEDS_LIBICONV = YesPlease | 32 | NEEDS_LIBICONV = YesPlease |
30 | endif | 33 | endif |
31 | 34 | ||
32 | # | 35 | # |
33 | # Let the user override the above settings. | 36 | # Let the user override the above settings. |
34 | # | 37 | # |
35 | -include cgit.conf | 38 | -include cgit.conf |
36 | 39 | ||
37 | # | 40 | # |
@@ -47,49 +50,49 @@ else # "make -w" | |||
47 | NO_SUBDIR = : | 50 | NO_SUBDIR = : |
48 | endif | 51 | endif |
49 | 52 | ||
50 | ifndef V | 53 | ifndef V |
51 | QUIET_CC = @echo ' ' CC $@; | 54 | QUIET_CC = @echo ' ' CC $@; |
52 | QUIET_MM = @echo ' ' MM $@; | 55 | QUIET_MM = @echo ' ' MM $@; |
53 | QUIET_SUBDIR0 = +@subdir= | 56 | QUIET_SUBDIR0 = +@subdir= |
54 | QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ | 57 | QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ |
55 | $(MAKE) $(PRINT_DIR) -C $$subdir | 58 | $(MAKE) $(PRINT_DIR) -C $$subdir |
56 | endif | 59 | endif |
57 | 60 | ||
58 | # | 61 | # |
59 | # Define a pattern rule for automatic dependency building | 62 | # Define a pattern rule for automatic dependency building |
60 | # | 63 | # |
61 | %.d: %.c | 64 | %.d: %.c |
62 | $(QUIET_MM)$(CC) $(CFLAGS) -MM $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@ | 65 | $(QUIET_MM)$(CC) $(CFLAGS) -MM $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@ |
63 | 66 | ||
64 | # | 67 | # |
65 | # Define a pattern rule for silent object building | 68 | # Define a pattern rule for silent object building |
66 | # | 69 | # |
67 | %.o: %.c | 70 | %.o: %.c |
68 | $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $< | 71 | $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $< |
69 | 72 | ||
70 | 73 | ||
71 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto | 74 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz |
72 | OBJECTS = | 75 | OBJECTS = |
73 | OBJECTS += cache.o | 76 | OBJECTS += cache.o |
74 | OBJECTS += cgit.o | 77 | OBJECTS += cgit.o |
75 | OBJECTS += cmd.o | 78 | OBJECTS += cmd.o |
76 | OBJECTS += configfile.o | 79 | OBJECTS += configfile.o |
77 | OBJECTS += html.o | 80 | OBJECTS += html.o |
78 | OBJECTS += parsing.o | 81 | OBJECTS += parsing.o |
79 | OBJECTS += scan-tree.o | 82 | OBJECTS += scan-tree.o |
80 | OBJECTS += shared.o | 83 | OBJECTS += shared.o |
81 | OBJECTS += ui-atom.o | 84 | OBJECTS += ui-atom.o |
82 | OBJECTS += ui-blob.o | 85 | OBJECTS += ui-blob.o |
83 | OBJECTS += ui-clone.o | 86 | OBJECTS += ui-clone.o |
84 | OBJECTS += ui-commit.o | 87 | OBJECTS += ui-commit.o |
85 | OBJECTS += ui-diff.o | 88 | OBJECTS += ui-diff.o |
86 | OBJECTS += ui-log.o | 89 | OBJECTS += ui-log.o |
87 | OBJECTS += ui-patch.o | 90 | OBJECTS += ui-patch.o |
88 | OBJECTS += ui-plain.o | 91 | OBJECTS += ui-plain.o |
89 | OBJECTS += ui-refs.o | 92 | OBJECTS += ui-refs.o |
90 | OBJECTS += ui-repolist.o | 93 | OBJECTS += ui-repolist.o |
91 | OBJECTS += ui-shared.o | 94 | OBJECTS += ui-shared.o |
92 | OBJECTS += ui-snapshot.o | 95 | OBJECTS += ui-snapshot.o |
93 | OBJECTS += ui-stats.o | 96 | OBJECTS += ui-stats.o |
94 | OBJECTS += ui-summary.o | 97 | OBJECTS += ui-summary.o |
95 | OBJECTS += ui-tag.o | 98 | OBJECTS += ui-tag.o |
@@ -102,59 +105,65 @@ endif | |||
102 | 105 | ||
103 | .PHONY: all libgit test install uninstall clean force-version get-git \ | 106 | .PHONY: all libgit test install uninstall clean force-version get-git \ |
104 | doc man-doc html-doc clean-doc | 107 | doc man-doc html-doc clean-doc |
105 | 108 | ||
106 | all: cgit | 109 | all: cgit |
107 | 110 | ||
108 | VERSION: force-version | 111 | VERSION: force-version |
109 | @./gen-version.sh "$(CGIT_VERSION)" | 112 | @./gen-version.sh "$(CGIT_VERSION)" |
110 | -include VERSION | 113 | -include VERSION |
111 | 114 | ||
112 | 115 | ||
113 | CFLAGS += -g -Wall -Igit | 116 | CFLAGS += -g -Wall -Igit |
114 | CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' | 117 | CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' |
115 | CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' | 118 | CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' |
116 | CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' | 119 | CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' |
117 | CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' | 120 | CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' |
118 | CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"' | 121 | CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"' |
119 | 122 | ||
120 | ifdef NO_ICONV | 123 | ifdef NO_ICONV |
121 | CFLAGS += -DNO_ICONV | 124 | CFLAGS += -DNO_ICONV |
122 | endif | 125 | endif |
123 | ifdef NO_STRCASESTR | 126 | ifdef NO_STRCASESTR |
124 | CFLAGS += -DNO_STRCASESTR | 127 | CFLAGS += -DNO_STRCASESTR |
125 | endif | 128 | endif |
129 | ifdef NO_OPENSSL | ||
130 | CFLAGS += -DNO_OPENSSL | ||
131 | GIT_OPTIONS += NO_OPENSSL=1 | ||
132 | else | ||
133 | EXTLIBS += -lcrypto | ||
134 | endif | ||
126 | 135 | ||
127 | cgit: $(OBJECTS) libgit | 136 | cgit: $(OBJECTS) libgit |
128 | $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS) | 137 | $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS) |
129 | 138 | ||
130 | cgit.o: VERSION | 139 | cgit.o: VERSION |
131 | 140 | ||
132 | -include $(OBJECTS:.o=.d) | 141 | -include $(OBJECTS:.o=.d) |
133 | 142 | ||
134 | libgit: | 143 | libgit: |
135 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 libgit.a | 144 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) libgit.a |
136 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 xdiff/lib.a | 145 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) xdiff/lib.a |
137 | 146 | ||
138 | test: all | 147 | test: all |
139 | $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all | 148 | $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all |
140 | 149 | ||
141 | install: all | 150 | install: all |
142 | $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_SCRIPT_PATH) | 151 | $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_SCRIPT_PATH) |
143 | $(INSTALL) -m 0755 cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) | 152 | $(INSTALL) -m 0755 cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) |
144 | $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_DATA_PATH) | 153 | $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_DATA_PATH) |
145 | $(INSTALL) -m 0644 cgit.css $(DESTDIR)$(CGIT_DATA_PATH)/cgit.css | 154 | $(INSTALL) -m 0644 cgit.css $(DESTDIR)$(CGIT_DATA_PATH)/cgit.css |
146 | $(INSTALL) -m 0644 cgit.png $(DESTDIR)$(CGIT_DATA_PATH)/cgit.png | 155 | $(INSTALL) -m 0644 cgit.png $(DESTDIR)$(CGIT_DATA_PATH)/cgit.png |
147 | 156 | ||
148 | uninstall: | 157 | uninstall: |
149 | rm -f $(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) | 158 | rm -f $(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) |
150 | rm -f $(CGIT_DATA_PATH)/cgit.css | 159 | rm -f $(CGIT_DATA_PATH)/cgit.css |
151 | rm -f $(CGIT_DATA_PATH)/cgit.png | 160 | rm -f $(CGIT_DATA_PATH)/cgit.png |
152 | 161 | ||
153 | doc: man-doc html-doc pdf-doc | 162 | doc: man-doc html-doc pdf-doc |
154 | 163 | ||
155 | man-doc: cgitrc.5.txt | 164 | man-doc: cgitrc.5.txt |
156 | a2x -f manpage cgitrc.5.txt | 165 | a2x -f manpage cgitrc.5.txt |
157 | 166 | ||
158 | html-doc: cgitrc.5.txt | 167 | html-doc: cgitrc.5.txt |
159 | a2x -f xhtml --stylesheet=cgit-doc.css cgitrc.5.txt | 168 | a2x -f xhtml --stylesheet=cgit-doc.css cgitrc.5.txt |
160 | 169 | ||
@@ -188,48 +188,50 @@ void config_cb(const char *name, const char *value) | |||
188 | ctx.cfg.renamelimit = atoi(value); | 188 | ctx.cfg.renamelimit = atoi(value); |
189 | else if (!strcmp(name, "robots")) | 189 | else if (!strcmp(name, "robots")) |
190 | ctx.cfg.robots = xstrdup(value); | 190 | ctx.cfg.robots = xstrdup(value); |
191 | else if (!strcmp(name, "clone-prefix")) | 191 | else if (!strcmp(name, "clone-prefix")) |
192 | ctx.cfg.clone_prefix = xstrdup(value); | 192 | ctx.cfg.clone_prefix = xstrdup(value); |
193 | else if (!strcmp(name, "local-time")) | 193 | else if (!strcmp(name, "local-time")) |
194 | ctx.cfg.local_time = atoi(value); | 194 | ctx.cfg.local_time = atoi(value); |
195 | else if (!prefixcmp(name, "mimetype.")) | 195 | else if (!prefixcmp(name, "mimetype.")) |
196 | add_mimetype(name + 9, value); | 196 | add_mimetype(name + 9, value); |
197 | else if (!strcmp(name, "include")) | 197 | else if (!strcmp(name, "include")) |
198 | parse_configfile(value, config_cb); | 198 | parse_configfile(value, config_cb); |
199 | } | 199 | } |
200 | 200 | ||
201 | static void querystring_cb(const char *name, const char *value) | 201 | static void querystring_cb(const char *name, const char *value) |
202 | { | 202 | { |
203 | if (!value) | 203 | if (!value) |
204 | value = ""; | 204 | value = ""; |
205 | 205 | ||
206 | if (!strcmp(name,"r")) { | 206 | if (!strcmp(name,"r")) { |
207 | ctx.qry.repo = xstrdup(value); | 207 | ctx.qry.repo = xstrdup(value); |
208 | ctx.repo = cgit_get_repoinfo(value); | 208 | ctx.repo = cgit_get_repoinfo(value); |
209 | } else if (!strcmp(name, "p")) { | 209 | } else if (!strcmp(name, "p")) { |
210 | ctx.qry.page = xstrdup(value); | 210 | ctx.qry.page = xstrdup(value); |
211 | } else if (!strcmp(name, "url")) { | 211 | } else if (!strcmp(name, "url")) { |
212 | if (*value == '/') | ||
213 | value++; | ||
212 | ctx.qry.url = xstrdup(value); | 214 | ctx.qry.url = xstrdup(value); |
213 | cgit_parse_url(value); | 215 | cgit_parse_url(value); |
214 | } else if (!strcmp(name, "qt")) { | 216 | } else if (!strcmp(name, "qt")) { |
215 | ctx.qry.grep = xstrdup(value); | 217 | ctx.qry.grep = xstrdup(value); |
216 | } else if (!strcmp(name, "q")) { | 218 | } else if (!strcmp(name, "q")) { |
217 | ctx.qry.search = xstrdup(value); | 219 | ctx.qry.search = xstrdup(value); |
218 | } else if (!strcmp(name, "h")) { | 220 | } else if (!strcmp(name, "h")) { |
219 | ctx.qry.head = xstrdup(value); | 221 | ctx.qry.head = xstrdup(value); |
220 | ctx.qry.has_symref = 1; | 222 | ctx.qry.has_symref = 1; |
221 | } else if (!strcmp(name, "id")) { | 223 | } else if (!strcmp(name, "id")) { |
222 | ctx.qry.sha1 = xstrdup(value); | 224 | ctx.qry.sha1 = xstrdup(value); |
223 | ctx.qry.has_sha1 = 1; | 225 | ctx.qry.has_sha1 = 1; |
224 | } else if (!strcmp(name, "id2")) { | 226 | } else if (!strcmp(name, "id2")) { |
225 | ctx.qry.sha2 = xstrdup(value); | 227 | ctx.qry.sha2 = xstrdup(value); |
226 | ctx.qry.has_sha1 = 1; | 228 | ctx.qry.has_sha1 = 1; |
227 | } else if (!strcmp(name, "ofs")) { | 229 | } else if (!strcmp(name, "ofs")) { |
228 | ctx.qry.ofs = atoi(value); | 230 | ctx.qry.ofs = atoi(value); |
229 | } else if (!strcmp(name, "path")) { | 231 | } else if (!strcmp(name, "path")) { |
230 | ctx.qry.path = trim_end(value, '/'); | 232 | ctx.qry.path = trim_end(value, '/'); |
231 | } else if (!strcmp(name, "name")) { | 233 | } else if (!strcmp(name, "name")) { |
232 | ctx.qry.name = xstrdup(value); | 234 | ctx.qry.name = xstrdup(value); |
233 | } else if (!strcmp(name, "mimetype")) { | 235 | } else if (!strcmp(name, "mimetype")) { |
234 | ctx.qry.mimetype = xstrdup(value); | 236 | ctx.qry.mimetype = xstrdup(value); |
235 | } else if (!strcmp(name, "s")){ | 237 | } else if (!strcmp(name, "s")){ |
diff --git a/ui-shared.c b/ui-shared.c index 4049a2b..3a9e67b 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -739,35 +739,40 @@ void cgit_print_pageheader(struct cgit_context *ctx) | |||
739 | } | 739 | } |
740 | html("</td></tr></table>\n"); | 740 | html("</td></tr></table>\n"); |
741 | html("<div class='content'>"); | 741 | html("<div class='content'>"); |
742 | } | 742 | } |
743 | 743 | ||
744 | void cgit_print_filemode(unsigned short mode) | 744 | void cgit_print_filemode(unsigned short mode) |
745 | { | 745 | { |
746 | if (S_ISDIR(mode)) | 746 | if (S_ISDIR(mode)) |
747 | html("d"); | 747 | html("d"); |
748 | else if (S_ISLNK(mode)) | 748 | else if (S_ISLNK(mode)) |
749 | html("l"); | 749 | html("l"); |
750 | else if (S_ISGITLINK(mode)) | 750 | else if (S_ISGITLINK(mode)) |
751 | html("m"); | 751 | html("m"); |
752 | else | 752 | else |
753 | html("-"); | 753 | html("-"); |
754 | html_fileperm(mode >> 6); | 754 | html_fileperm(mode >> 6); |
755 | html_fileperm(mode >> 3); | 755 | html_fileperm(mode >> 3); |
756 | html_fileperm(mode); | 756 | html_fileperm(mode); |
757 | } | 757 | } |
758 | 758 | ||
759 | void cgit_print_snapshot_links(const char *repo, const char *head, | 759 | void cgit_print_snapshot_links(const char *repo, const char *head, |
760 | const char *hex, int snapshots) | 760 | const char *hex, int snapshots) |
761 | { | 761 | { |
762 | const struct cgit_snapshot_format* f; | 762 | const struct cgit_snapshot_format* f; |
763 | char *prefix; | ||
763 | char *filename; | 764 | char *filename; |
765 | unsigned char sha1[20]; | ||
764 | 766 | ||
767 | if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 && | ||
768 | (hex[0] == 'v' || hex[0] == 'V') && isdigit(hex[1])) | ||
769 | hex++; | ||
770 | prefix = xstrdup(fmt("%s-%s", cgit_repobasename(repo), hex)); | ||
765 | for (f = cgit_snapshot_formats; f->suffix; f++) { | 771 | for (f = cgit_snapshot_formats; f->suffix; f++) { |
766 | if (!(snapshots & f->bit)) | 772 | if (!(snapshots & f->bit)) |
767 | continue; | 773 | continue; |
768 | filename = fmt("%s-%s%s", cgit_repobasename(repo), hex, | 774 | filename = fmt("%s%s", prefix, f->suffix); |
769 | f->suffix); | ||
770 | cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename); | 775 | cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename); |
771 | html("<br/>"); | 776 | html("<br/>"); |
772 | } | 777 | } |
773 | } | 778 | } |
@@ -9,84 +9,96 @@ | |||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | #include "html.h" | 10 | #include "html.h" |
11 | #include "ui-shared.h" | 11 | #include "ui-shared.h" |
12 | 12 | ||
13 | static void print_tag_content(char *buf) | 13 | static void print_tag_content(char *buf) |
14 | { | 14 | { |
15 | char *p; | 15 | char *p; |
16 | 16 | ||
17 | if (!buf) | 17 | if (!buf) |
18 | return; | 18 | return; |
19 | 19 | ||
20 | html("<div class='commit-subject'>"); | 20 | html("<div class='commit-subject'>"); |
21 | p = strchr(buf, '\n'); | 21 | p = strchr(buf, '\n'); |
22 | if (p) | 22 | if (p) |
23 | *p = '\0'; | 23 | *p = '\0'; |
24 | html_txt(buf); | 24 | html_txt(buf); |
25 | html("</div>"); | 25 | html("</div>"); |
26 | if (p) { | 26 | if (p) { |
27 | html("<div class='commit-msg'>"); | 27 | html("<div class='commit-msg'>"); |
28 | html_txt(++p); | 28 | html_txt(++p); |
29 | html("</div>"); | 29 | html("</div>"); |
30 | } | 30 | } |
31 | } | 31 | } |
32 | 32 | ||
33 | void print_download_links(char *revname) | ||
34 | { | ||
35 | html("<tr><th>download</th><td class='sha1'>"); | ||
36 | cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head, | ||
37 | revname, ctx.repo->snapshots); | ||
38 | html("</td></tr>"); | ||
39 | } | ||
40 | |||
33 | void cgit_print_tag(char *revname) | 41 | void cgit_print_tag(char *revname) |
34 | { | 42 | { |
35 | unsigned char sha1[20]; | 43 | unsigned char sha1[20]; |
36 | struct object *obj; | 44 | struct object *obj; |
37 | struct tag *tag; | 45 | struct tag *tag; |
38 | struct taginfo *info; | 46 | struct taginfo *info; |
39 | 47 | ||
40 | if (!revname) | 48 | if (!revname) |
41 | revname = ctx.qry.head; | 49 | revname = ctx.qry.head; |
42 | 50 | ||
43 | if (get_sha1(fmt("refs/tags/%s", revname), sha1)) { | 51 | if (get_sha1(fmt("refs/tags/%s", revname), sha1)) { |
44 | cgit_print_error(fmt("Bad tag reference: %s", revname)); | 52 | cgit_print_error(fmt("Bad tag reference: %s", revname)); |
45 | return; | 53 | return; |
46 | } | 54 | } |
47 | obj = parse_object(sha1); | 55 | obj = parse_object(sha1); |
48 | if (!obj) { | 56 | if (!obj) { |
49 | cgit_print_error(fmt("Bad object id: %s", sha1_to_hex(sha1))); | 57 | cgit_print_error(fmt("Bad object id: %s", sha1_to_hex(sha1))); |
50 | return; | 58 | return; |
51 | } | 59 | } |
52 | if (obj->type == OBJ_TAG) { | 60 | if (obj->type == OBJ_TAG) { |
53 | tag = lookup_tag(sha1); | 61 | tag = lookup_tag(sha1); |
54 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { | 62 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { |
55 | cgit_print_error(fmt("Bad tag object: %s", revname)); | 63 | cgit_print_error(fmt("Bad tag object: %s", revname)); |
56 | return; | 64 | return; |
57 | } | 65 | } |
58 | html("<table class='commit-info'>\n"); | 66 | html("<table class='commit-info'>\n"); |
59 | htmlf("<tr><td>Tag name</td><td>"); | 67 | htmlf("<tr><td>tag name</td><td>"); |
60 | html_txt(revname); | 68 | html_txt(revname); |
61 | htmlf(" (%s)</td></tr>\n", sha1_to_hex(sha1)); | 69 | htmlf(" (%s)</td></tr>\n", sha1_to_hex(sha1)); |
62 | if (info->tagger_date > 0) { | 70 | if (info->tagger_date > 0) { |
63 | html("<tr><td>Tag date</td><td>"); | 71 | html("<tr><td>tag date</td><td>"); |
64 | cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time); | 72 | cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time); |
65 | html("</td></tr>\n"); | 73 | html("</td></tr>\n"); |
66 | } | 74 | } |
67 | if (info->tagger) { | 75 | if (info->tagger) { |
68 | html("<tr><td>Tagged by</td><td>"); | 76 | html("<tr><td>tagged by</td><td>"); |
69 | html_txt(info->tagger); | 77 | html_txt(info->tagger); |
70 | if (info->tagger_email && !ctx.cfg.noplainemail) { | 78 | if (info->tagger_email && !ctx.cfg.noplainemail) { |
71 | html(" "); | 79 | html(" "); |
72 | html_txt(info->tagger_email); | 80 | html_txt(info->tagger_email); |
73 | } | 81 | } |
74 | html("</td></tr>\n"); | 82 | html("</td></tr>\n"); |
75 | } | 83 | } |
76 | html("<tr><td>Tagged object</td><td>"); | 84 | html("<tr><td>tagged object</td><td class='sha1'>"); |
77 | cgit_object_link(tag->tagged); | 85 | cgit_object_link(tag->tagged); |
78 | html("</td></tr>\n"); | 86 | html("</td></tr>\n"); |
87 | if (ctx.repo->snapshots) | ||
88 | print_download_links(revname); | ||
79 | html("</table>\n"); | 89 | html("</table>\n"); |
80 | print_tag_content(info->msg); | 90 | print_tag_content(info->msg); |
81 | } else { | 91 | } else { |
82 | html("<table class='commit-info'>\n"); | 92 | html("<table class='commit-info'>\n"); |
83 | htmlf("<tr><td>Tag name</td><td>"); | 93 | htmlf("<tr><td>tag name</td><td>"); |
84 | html_txt(revname); | 94 | html_txt(revname); |
85 | html("</td></tr>\n"); | 95 | html("</td></tr>\n"); |
86 | html("<tr><td>Tagged object</td><td>"); | 96 | html("<tr><td>Tagged object</td><td class='sha1'>"); |
87 | cgit_object_link(obj); | 97 | cgit_object_link(obj); |
88 | html("</td></tr>\n"); | 98 | html("</td></tr>\n"); |
99 | if (ctx.repo->snapshots) | ||
100 | print_download_links(revname); | ||
89 | html("</table>\n"); | 101 | html("</table>\n"); |
90 | } | 102 | } |
91 | return; | 103 | return; |
92 | } | 104 | } |