-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | cgit.c | 3 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | shared.c | 2 | ||||
-rw-r--r-- | ui-refs.c | 30 |
5 files changed, 37 insertions, 2 deletions
@@ -3,33 +3,33 @@ CGIT_SCRIPT_NAME = cgit.cgi | |||
3 | CGIT_SCRIPT_PATH = /var/www/htdocs/cgit | 3 | CGIT_SCRIPT_PATH = /var/www/htdocs/cgit |
4 | CGIT_CONFIG = /etc/cgitrc | 4 | CGIT_CONFIG = /etc/cgitrc |
5 | CACHE_ROOT = /var/cache/cgit | 5 | CACHE_ROOT = /var/cache/cgit |
6 | SHA1_HEADER = <openssl/sha.h> | 6 | SHA1_HEADER = <openssl/sha.h> |
7 | GIT_VER = 1.5.3.3 | 7 | GIT_VER = 1.5.3.3 |
8 | GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 | 8 | GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 |
9 | 9 | ||
10 | # | 10 | # |
11 | # Let the user override the above settings. | 11 | # Let the user override the above settings. |
12 | # | 12 | # |
13 | -include cgit.conf | 13 | -include cgit.conf |
14 | 14 | ||
15 | 15 | ||
16 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto | 16 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto |
17 | OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \ | 17 | OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \ |
18 | ui-summary.o ui-log.o ui-tree.o ui-commit.o ui-diff.o \ | 18 | ui-summary.o ui-log.o ui-tree.o ui-commit.o ui-diff.o \ |
19 | ui-snapshot.o ui-blob.o ui-tag.o | 19 | ui-snapshot.o ui-blob.o ui-tag.o ui-refs.o |
20 | 20 | ||
21 | 21 | ||
22 | .PHONY: all git install clean distclean force-version get-git | 22 | .PHONY: all git install clean distclean force-version get-git |
23 | 23 | ||
24 | all: cgit git | 24 | all: cgit git |
25 | 25 | ||
26 | VERSION: force-version | 26 | VERSION: force-version |
27 | @./gen-version.sh "$(CGIT_VERSION)" | 27 | @./gen-version.sh "$(CGIT_VERSION)" |
28 | -include VERSION | 28 | -include VERSION |
29 | 29 | ||
30 | 30 | ||
31 | CFLAGS += -g -Wall -Igit | 31 | CFLAGS += -g -Wall -Igit |
32 | CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' | 32 | CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' |
33 | CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' | 33 | CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' |
34 | CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' | 34 | CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' |
35 | CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' | 35 | CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' |
@@ -90,32 +90,35 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
90 | } | 90 | } |
91 | 91 | ||
92 | cgit_print_pageheader(cgit_query_page, show_search); | 92 | cgit_print_pageheader(cgit_query_page, show_search); |
93 | 93 | ||
94 | switch(cgit_cmd) { | 94 | switch(cgit_cmd) { |
95 | case CMD_LOG: | 95 | case CMD_LOG: |
96 | cgit_print_log(cgit_query_sha1, cgit_query_ofs, | 96 | cgit_print_log(cgit_query_sha1, cgit_query_ofs, |
97 | cgit_max_commit_count, cgit_query_search, | 97 | cgit_max_commit_count, cgit_query_search, |
98 | cgit_query_path, 1); | 98 | cgit_query_path, 1); |
99 | break; | 99 | break; |
100 | case CMD_TREE: | 100 | case CMD_TREE: |
101 | cgit_print_tree(cgit_query_sha1, cgit_query_path); | 101 | cgit_print_tree(cgit_query_sha1, cgit_query_path); |
102 | break; | 102 | break; |
103 | case CMD_COMMIT: | 103 | case CMD_COMMIT: |
104 | cgit_print_commit(cgit_query_sha1); | 104 | cgit_print_commit(cgit_query_sha1); |
105 | break; | 105 | break; |
106 | case CMD_REFS: | ||
107 | cgit_print_refs(); | ||
108 | break; | ||
106 | case CMD_TAG: | 109 | case CMD_TAG: |
107 | cgit_print_tag(cgit_query_sha1); | 110 | cgit_print_tag(cgit_query_sha1); |
108 | break; | 111 | break; |
109 | case CMD_DIFF: | 112 | case CMD_DIFF: |
110 | cgit_print_diff(cgit_query_sha1, cgit_query_sha2, cgit_query_path); | 113 | cgit_print_diff(cgit_query_sha1, cgit_query_sha2, cgit_query_path); |
111 | break; | 114 | break; |
112 | default: | 115 | default: |
113 | cgit_print_error("Invalid request"); | 116 | cgit_print_error("Invalid request"); |
114 | } | 117 | } |
115 | cgit_print_docend(); | 118 | cgit_print_docend(); |
116 | } | 119 | } |
117 | 120 | ||
118 | static void cgit_fill_cache(struct cacheitem *item, int use_cache) | 121 | static void cgit_fill_cache(struct cacheitem *item, int use_cache) |
119 | { | 122 | { |
120 | static char buf[PATH_MAX]; | 123 | static char buf[PATH_MAX]; |
121 | int stdout2; | 124 | int stdout2; |
@@ -15,32 +15,33 @@ | |||
15 | #include <revision.h> | 15 | #include <revision.h> |
16 | #include <log-tree.h> | 16 | #include <log-tree.h> |
17 | #include <archive.h> | 17 | #include <archive.h> |
18 | #include <xdiff/xdiff.h> | 18 | #include <xdiff/xdiff.h> |
19 | 19 | ||
20 | 20 | ||
21 | /* | 21 | /* |
22 | * The valid cgit repo-commands | 22 | * The valid cgit repo-commands |
23 | */ | 23 | */ |
24 | #define CMD_LOG 1 | 24 | #define CMD_LOG 1 |
25 | #define CMD_COMMIT 2 | 25 | #define CMD_COMMIT 2 |
26 | #define CMD_DIFF 3 | 26 | #define CMD_DIFF 3 |
27 | #define CMD_TREE 4 | 27 | #define CMD_TREE 4 |
28 | #define CMD_BLOB 5 | 28 | #define CMD_BLOB 5 |
29 | #define CMD_SNAPSHOT 6 | 29 | #define CMD_SNAPSHOT 6 |
30 | #define CMD_TAG 7 | 30 | #define CMD_TAG 7 |
31 | #define CMD_REFS 8 | ||
31 | 32 | ||
32 | /* | 33 | /* |
33 | * Dateformats used on misc. pages | 34 | * Dateformats used on misc. pages |
34 | */ | 35 | */ |
35 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" | 36 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" |
36 | #define FMT_SHORTDATE "%Y-%m-%d" | 37 | #define FMT_SHORTDATE "%Y-%m-%d" |
37 | 38 | ||
38 | 39 | ||
39 | /* | 40 | /* |
40 | * Limits used for relative dates | 41 | * Limits used for relative dates |
41 | */ | 42 | */ |
42 | #define TM_MIN 60 | 43 | #define TM_MIN 60 |
43 | #define TM_HOUR (TM_MIN * 60) | 44 | #define TM_HOUR (TM_MIN * 60) |
44 | #define TM_DAY (TM_HOUR * 24) | 45 | #define TM_DAY (TM_HOUR * 24) |
45 | #define TM_WEEK (TM_DAY * 7) | 46 | #define TM_WEEK (TM_DAY * 7) |
46 | #define TM_YEAR (TM_DAY * 365) | 47 | #define TM_YEAR (TM_DAY * 365) |
@@ -247,26 +248,27 @@ extern void cgit_print_date(time_t secs, char *format); | |||
247 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); | 248 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); |
248 | extern void cgit_print_docstart(char *title, struct cacheitem *item); | 249 | extern void cgit_print_docstart(char *title, struct cacheitem *item); |
249 | extern void cgit_print_docend(); | 250 | extern void cgit_print_docend(); |
250 | extern void cgit_print_pageheader(char *title, int show_search); | 251 | extern void cgit_print_pageheader(char *title, int show_search); |
251 | extern void cgit_print_snapshot_start(const char *mimetype, | 252 | extern void cgit_print_snapshot_start(const char *mimetype, |
252 | const char *filename, | 253 | const char *filename, |
253 | struct cacheitem *item); | 254 | struct cacheitem *item); |
254 | extern void cgit_print_branches(int maxcount); | 255 | extern void cgit_print_branches(int maxcount); |
255 | extern void cgit_print_tags(int maxcount); | 256 | extern void cgit_print_tags(int maxcount); |
256 | 257 | ||
257 | extern void cgit_print_repolist(struct cacheitem *item); | 258 | extern void cgit_print_repolist(struct cacheitem *item); |
258 | extern void cgit_print_summary(); | 259 | extern void cgit_print_summary(); |
259 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager); | 260 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager); |
260 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); | 261 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); |
261 | extern void cgit_print_tree(const char *rev, char *path); | 262 | extern void cgit_print_tree(const char *rev, char *path); |
262 | extern void cgit_print_commit(char *hex); | 263 | extern void cgit_print_commit(char *hex); |
264 | extern void cgit_print_refs(); | ||
263 | extern void cgit_print_tag(char *revname); | 265 | extern void cgit_print_tag(char *revname); |
264 | extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix); | 266 | extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix); |
265 | extern void cgit_print_snapshot(struct cacheitem *item, const char *head, | 267 | extern void cgit_print_snapshot(struct cacheitem *item, const char *head, |
266 | const char *hex, const char *prefix, | 268 | const char *hex, const char *prefix, |
267 | const char *filename, int snapshot); | 269 | const char *filename, int snapshot); |
268 | extern void cgit_print_snapshot_links(const char *repo, const char *head, | 270 | extern void cgit_print_snapshot_links(const char *repo, const char *head, |
269 | const char *hex, int snapshots); | 271 | const char *hex, int snapshots); |
270 | extern int cgit_parse_snapshots_mask(const char *str); | 272 | extern int cgit_parse_snapshots_mask(const char *str); |
271 | 273 | ||
272 | #endif /* CGIT_H */ | 274 | #endif /* CGIT_H */ |
@@ -53,33 +53,33 @@ char *cgit_querystring = NULL; | |||
53 | char *cgit_query_repo = NULL; | 53 | char *cgit_query_repo = NULL; |
54 | char *cgit_query_page = NULL; | 54 | char *cgit_query_page = NULL; |
55 | char *cgit_query_head = NULL; | 55 | char *cgit_query_head = NULL; |
56 | char *cgit_query_search = NULL; | 56 | char *cgit_query_search = NULL; |
57 | char *cgit_query_sha1 = NULL; | 57 | char *cgit_query_sha1 = NULL; |
58 | char *cgit_query_sha2 = NULL; | 58 | char *cgit_query_sha2 = NULL; |
59 | char *cgit_query_path = NULL; | 59 | char *cgit_query_path = NULL; |
60 | char *cgit_query_name = NULL; | 60 | char *cgit_query_name = NULL; |
61 | int cgit_query_ofs = 0; | 61 | int cgit_query_ofs = 0; |
62 | 62 | ||
63 | int htmlfd = 0; | 63 | int htmlfd = 0; |
64 | 64 | ||
65 | 65 | ||
66 | int cgit_get_cmd_index(const char *cmd) | 66 | int cgit_get_cmd_index(const char *cmd) |
67 | { | 67 | { |
68 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", | 68 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", |
69 | "snapshot", "tag", NULL}; | 69 | "snapshot", "tag", "refs", NULL}; |
70 | int i; | 70 | int i; |
71 | 71 | ||
72 | for(i = 0; cmds[i]; i++) | 72 | for(i = 0; cmds[i]; i++) |
73 | if (!strcmp(cmd, cmds[i])) | 73 | if (!strcmp(cmd, cmds[i])) |
74 | return i + 1; | 74 | return i + 1; |
75 | return 0; | 75 | return 0; |
76 | } | 76 | } |
77 | 77 | ||
78 | int chk_zero(int result, char *msg) | 78 | int chk_zero(int result, char *msg) |
79 | { | 79 | { |
80 | if (result != 0) | 80 | if (result != 0) |
81 | die("%s: %s", msg, strerror(errno)); | 81 | die("%s: %s", msg, strerror(errno)); |
82 | return result; | 82 | return result; |
83 | } | 83 | } |
84 | 84 | ||
85 | int chk_positive(int result, char *msg) | 85 | int chk_positive(int result, char *msg) |
diff --git a/ui-refs.c b/ui-refs.c new file mode 100644 index 0000000..295f5ba --- a/dev/null +++ b/ui-refs.c | |||
@@ -0,0 +1,30 @@ | |||
1 | /* ui-refs.c: browse symbolic refs | ||
2 | * | ||
3 | * Copyright (C) 2006 Lars Hjemli | ||
4 | * | ||
5 | * Licensed under GNU General Public License v2 | ||
6 | * (see COPYING for full license text) | ||
7 | */ | ||
8 | |||
9 | #include "cgit.h" | ||
10 | |||
11 | |||
12 | |||
13 | |||
14 | void cgit_print_refs() | ||
15 | { | ||
16 | |||
17 | html("<table class='list nowrap'>"); | ||
18 | |||
19 | if (cgit_query_path && !strncmp(cgit_query_path, "heads", 5)) | ||
20 | cgit_print_branches(0); | ||
21 | else if (cgit_query_path && !strncmp(cgit_query_path, "tags", 4)) | ||
22 | cgit_print_tags(0); | ||
23 | else { | ||
24 | cgit_print_branches(0); | ||
25 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | ||
26 | cgit_print_tags(0); | ||
27 | } | ||
28 | |||
29 | html("</table>"); | ||
30 | } | ||