diff options
| -rw-r--r-- | Makefile | 14 | ||||
| -rw-r--r-- | cgit.c | 67 | ||||
| -rw-r--r-- | cgit.css | 64 | ||||
| -rw-r--r-- | cgit.h | 12 | ||||
| -rw-r--r-- | cgit.png | bin | 3790 -> 5406 bytes | |||
| -rw-r--r-- | cgitrc | 12 | ||||
| m--------- | git | 0 | ||||
| -rw-r--r-- | html.c | 2 | ||||
| -rw-r--r-- | parsing.c | 25 | ||||
| -rw-r--r-- | shared.c | 14 | ||||
| -rw-r--r-- | tests/.gitignore | 2 | ||||
| -rw-r--r-- | tests/Makefile | 13 | ||||
| -rwxr-xr-x | tests/setup.sh | 108 | ||||
| -rwxr-xr-x | tests/t0010-validate-html.sh | 31 | ||||
| -rwxr-xr-x | tests/t0101-index.sh | 13 | ||||
| -rwxr-xr-x | tests/t0102-summary.sh | 20 | ||||
| -rwxr-xr-x | tests/t0103-log.sh | 15 | ||||
| -rwxr-xr-x | tests/t0104-tree.sh | 21 | ||||
| -rwxr-xr-x | tests/t0105-commit.sh | 22 | ||||
| -rwxr-xr-x | tests/t0106-diff.sh | 20 | ||||
| -rwxr-xr-x | tests/t0107-snapshot.sh | 36 | ||||
| -rw-r--r-- | ui-commit.c | 6 | ||||
| -rw-r--r-- | ui-diff.c | 2 | ||||
| -rw-r--r-- | ui-log.c | 23 | ||||
| -rw-r--r-- | ui-patch.c | 110 | ||||
| -rw-r--r-- | ui-repolist.c | 2 | ||||
| -rw-r--r-- | ui-shared.c | 67 | ||||
| -rw-r--r-- | ui-summary.c | 2 | ||||
| -rw-r--r-- | ui-tree.c | 6 |
29 files changed, 653 insertions, 76 deletions
| @@ -4,7 +4,7 @@ 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.8 | 7 | GIT_VER = 1.5.4.1 |
| 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 | # |
| @@ -16,10 +16,15 @@ GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 | |||
| 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 ui-refs.o | 19 | ui-snapshot.o ui-blob.o ui-tag.o ui-refs.o ui-patch.o |
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | .PHONY: all git install clean distclean emptycache force-version get-git | 22 | ifdef NEEDS_LIBICONV |
| 23 | EXTLIBS += -liconv | ||
| 24 | endif | ||
| 25 | |||
| 26 | |||
| 27 | .PHONY: all git test install clean distclean emptycache force-version get-git | ||
| 23 | 28 | ||
| 24 | all: cgit git | 29 | all: cgit git |
| 25 | 30 | ||
| @@ -49,6 +54,9 @@ git: | |||
| 49 | cd git && $(MAKE) xdiff/lib.a | 54 | cd git && $(MAKE) xdiff/lib.a |
| 50 | cd git && $(MAKE) libgit.a | 55 | cd git && $(MAKE) libgit.a |
| 51 | 56 | ||
| 57 | test: all | ||
| 58 | $(MAKE) -C tests | ||
| 59 | |||
| 52 | install: all | 60 | install: all |
| 53 | mkdir -p $(DESTDIR)$(CGIT_SCRIPT_PATH) | 61 | mkdir -p $(DESTDIR)$(CGIT_SCRIPT_PATH) |
| 54 | install cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) | 62 | install cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) |
| @@ -45,13 +45,44 @@ static int cgit_prepare_cache(struct cacheitem *item) | |||
| 45 | return 1; | 45 | return 1; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | struct refmatch { | ||
| 49 | char *req_ref; | ||
| 50 | char *first_ref; | ||
| 51 | int match; | ||
| 52 | }; | ||
| 53 | |||
| 54 | int find_current_ref(const char *refname, const unsigned char *sha1, | ||
| 55 | int flags, void *cb_data) | ||
| 56 | { | ||
| 57 | struct refmatch *info; | ||
| 58 | |||
| 59 | info = (struct refmatch *)cb_data; | ||
| 60 | if (!strcmp(refname, info->req_ref)) | ||
| 61 | info->match = 1; | ||
| 62 | if (!info->first_ref) | ||
| 63 | info->first_ref = xstrdup(refname); | ||
| 64 | return info->match; | ||
| 65 | } | ||
| 66 | |||
| 67 | char *find_default_branch(struct repoinfo *repo) | ||
| 68 | { | ||
| 69 | struct refmatch info; | ||
| 70 | |||
| 71 | info.req_ref = repo->defbranch; | ||
| 72 | info.first_ref = NULL; | ||
| 73 | info.match = 0; | ||
| 74 | for_each_branch_ref(find_current_ref, &info); | ||
| 75 | if (info.match) | ||
| 76 | return info.req_ref; | ||
| 77 | else | ||
| 78 | return info.first_ref; | ||
| 79 | } | ||
| 80 | |||
| 48 | static void cgit_print_repo_page(struct cacheitem *item) | 81 | static void cgit_print_repo_page(struct cacheitem *item) |
| 49 | { | 82 | { |
| 50 | char *title; | 83 | char *title, *tmp; |
| 51 | int show_search; | 84 | int show_search; |
| 52 | 85 | unsigned char sha1[20]; | |
| 53 | if (!cgit_query_head) | ||
| 54 | cgit_query_head = cgit_repo->defbranch; | ||
| 55 | 86 | ||
| 56 | if (chdir(cgit_repo->path)) { | 87 | if (chdir(cgit_repo->path)) { |
| 57 | title = fmt("%s - %s", cgit_root_title, "Bad request"); | 88 | title = fmt("%s - %s", cgit_root_title, "Bad request"); |
| @@ -67,6 +98,29 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
| 67 | show_search = 0; | 98 | show_search = 0; |
| 68 | setenv("GIT_DIR", cgit_repo->path, 1); | 99 | setenv("GIT_DIR", cgit_repo->path, 1); |
| 69 | 100 | ||
| 101 | if (!cgit_query_head) { | ||
| 102 | cgit_query_head = xstrdup(find_default_branch(cgit_repo)); | ||
| 103 | cgit_repo->defbranch = cgit_query_head; | ||
| 104 | } | ||
| 105 | |||
| 106 | if (!cgit_query_head) { | ||
| 107 | cgit_print_docstart(title, item); | ||
| 108 | cgit_print_pageheader(title, 0); | ||
| 109 | cgit_print_error("Repository seems to be empty"); | ||
| 110 | cgit_print_docend(); | ||
| 111 | return; | ||
| 112 | } | ||
| 113 | |||
| 114 | if (get_sha1(cgit_query_head, sha1)) { | ||
| 115 | tmp = xstrdup(cgit_query_head); | ||
| 116 | cgit_query_head = cgit_repo->defbranch; | ||
| 117 | cgit_print_docstart(title, item); | ||
| 118 | cgit_print_pageheader(title, 0); | ||
| 119 | cgit_print_error(fmt("Invalid branch: %s", tmp)); | ||
| 120 | cgit_print_docend(); | ||
| 121 | return; | ||
| 122 | } | ||
| 123 | |||
| 70 | if ((cgit_cmd == CMD_SNAPSHOT) && cgit_repo->snapshots) { | 124 | if ((cgit_cmd == CMD_SNAPSHOT) && cgit_repo->snapshots) { |
| 71 | cgit_print_snapshot(item, cgit_query_head, cgit_query_sha1, | 125 | cgit_print_snapshot(item, cgit_query_head, cgit_query_sha1, |
| 72 | cgit_repobasename(cgit_repo->url), | 126 | cgit_repobasename(cgit_repo->url), |
| @@ -75,6 +129,11 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
| 75 | return; | 129 | return; |
| 76 | } | 130 | } |
| 77 | 131 | ||
| 132 | if (cgit_cmd == CMD_PATCH) { | ||
| 133 | cgit_print_patch(cgit_query_sha1, item); | ||
| 134 | return; | ||
| 135 | } | ||
| 136 | |||
| 78 | if (cgit_cmd == CMD_BLOB) { | 137 | if (cgit_cmd == CMD_BLOB) { |
| 79 | cgit_print_blob(item, cgit_query_sha1, cgit_query_path); | 138 | cgit_print_blob(item, cgit_query_sha1, cgit_query_path); |
| 80 | return; | 139 | return; |
| @@ -8,7 +8,7 @@ body { | |||
| 8 | font-size: 10pt; | 8 | font-size: 10pt; |
| 9 | color: #333; | 9 | color: #333; |
| 10 | background: white; | 10 | background: white; |
| 11 | padding-left: 4px; | 11 | padding: 4px; |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | table { | 14 | table { |
| @@ -78,29 +78,39 @@ img { | |||
| 78 | border: none; | 78 | border: none; |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | div#sidebar { | 81 | table#layout { |
| 82 | border-collapse: collapse; | ||
| 83 | border: none; | ||
| 84 | margin: 0px; | ||
| 85 | } | ||
| 86 | |||
| 87 | td#sidebar { | ||
| 82 | vertical-align: top; | 88 | vertical-align: top; |
| 83 | width: 162px; | 89 | width: 162px; |
| 84 | padding: 0px 0px 0px 0px; | 90 | padding: 0px 0px 0px 0px; |
| 85 | margin: 4px; | 91 | margin: 0px; |
| 86 | float: left; | ||
| 87 | } | 92 | } |
| 88 | 93 | ||
| 89 | div#logo { | 94 | td#sidebar table { |
| 95 | border-collapse: separate; | ||
| 96 | border-spacing: 0px; | ||
| 90 | margin: 0px; | 97 | margin: 0px; |
| 91 | padding: 4px 0px 4px 0px; | 98 | padding: 0px; |
| 92 | text-align: center; | ||
| 93 | background-color: #ccc; | 99 | background-color: #ccc; |
| 100 | } | ||
| 101 | |||
| 102 | td#sidebar table.sidebar td.sidebar { | ||
| 103 | padding: 4px; | ||
| 94 | border-top: solid 1px #eee; | 104 | border-top: solid 1px #eee; |
| 95 | border-left: solid 1px #eee; | 105 | border-left: solid 1px #eee; |
| 96 | border-right: solid 1px #aaa; | 106 | border-right: solid 1px #aaa; |
| 97 | border-bottom: solid 1px #aaa; | 107 | border-bottom: solid 1px #aaa; |
| 98 | } | 108 | } |
| 99 | 109 | ||
| 100 | div#sidebar div.infobox { | 110 | div#logo { |
| 101 | margin: 0px 0px 0px 0px; | 111 | margin: 0px; |
| 102 | padding: 0.5em; | 112 | padding: 4px 0px 4px 0px; |
| 103 | text-align: left; | 113 | text-align: center; |
| 104 | background-color: #ccc; | 114 | background-color: #ccc; |
| 105 | border-top: solid 1px #eee; | 115 | border-top: solid 1px #eee; |
| 106 | border-left: solid 1px #eee; | 116 | border-left: solid 1px #eee; |
| @@ -108,50 +118,44 @@ div#sidebar div.infobox { | |||
| 108 | border-bottom: solid 1px #aaa; | 118 | border-bottom: solid 1px #aaa; |
| 109 | } | 119 | } |
| 110 | 120 | ||
| 111 | div#sidebar div.infobox h1 { | 121 | td#sidebar h1 { |
| 112 | font-size: 11pt; | 122 | font-size: 10pt; |
| 113 | font-weight: bold; | 123 | font-weight: bold; |
| 114 | margin: 0px; | 124 | margin: 8px 0px 0px 0px; |
| 115 | } | 125 | } |
| 116 | 126 | ||
| 117 | div#sidebar div.infobox a.menu { | 127 | td#sidebar h1.first { |
| 128 | margin-top: 0px; | ||
| 129 | } | ||
| 130 | |||
| 131 | td#sidebar a.menu { | ||
| 118 | display: block; | 132 | display: block; |
| 119 | background-color: #ccc; | 133 | background-color: #ccc; |
| 120 | padding: 0.1em 0.5em; | 134 | padding: 0.1em 0.5em; |
| 121 | text-decoration: none; | 135 | text-decoration: none; |
| 122 | } | 136 | } |
| 123 | 137 | ||
| 124 | div#sidebar div.infobox a.menu:hover { | 138 | td#sidebar a.menu:hover { |
| 125 | background-color: #bbb; | 139 | background-color: #bbb; |
| 126 | text-decoration: none; | 140 | text-decoration: none; |
| 127 | } | 141 | } |
| 128 | 142 | ||
| 129 | div#sidebar div.infobox select { | 143 | td#sidebar select { |
| 130 | width: 100%; | 144 | width: 100%; |
| 131 | border: solid 1px #aaa; | ||
| 132 | background-color: #bbb; | ||
| 133 | margin: 2px 0px 0px 0px; | 145 | margin: 2px 0px 0px 0px; |
| 134 | padding: 0px; | ||
| 135 | } | 146 | } |
| 136 | 147 | ||
| 137 | td#branch-dropdown-cell { | 148 | td#sidebar form { |
| 138 | width: 99%; | 149 | text-align: right; |
| 139 | } | 150 | } |
| 140 | 151 | ||
| 141 | input#switch-btn { | 152 | input#switch-btn { |
| 142 | width: 20px; | ||
