aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar YAEGASHI Takeshi <yaegashi@debian.org>2014-03-02 17:00:16 (JST)
committerGravatar YAEGASHI Takeshi <yaegashi@debian.org>2014-03-02 17:00:16 (JST)
commit667bf9f6ed38daac4e4d7e88903eb0f28319c165 (patch)
treed7d36d505fb3c183bdec673c6e294b27e1a12310
parent1f57ee005551ae7ee2b387f14eb7dd104a120ee3 (diff)
parentf2fa9c56e29ae32bbe5841e7bfe0217ada4e3df9 (diff)
downloadcgit-667bf9f6ed38daac4e4d7e88903eb0f28319c165.zip
cgit-667bf9f6ed38daac4e4d7e88903eb0f28319c165.tar.gz
Merge tag 'v0.10.1'
CGIT 0.10.1
-rw-r--r--Makefile5
-rw-r--r--README13
-rw-r--r--cache.c28
-rw-r--r--cgit.c23
-rw-r--r--cgit.h1
-rw-r--r--cgit.mk44
-rw-r--r--cgitrc.5.txt42
-rw-r--r--cmd.c2
-rw-r--r--filters/simple-authentication.lua2
-rwxr-xr-xgen-version.sh2
m---------git0
-rw-r--r--shared.c1
-rwxr-xr-xtests/setup.sh12
-rwxr-xr-xtests/t0111-filter.sh7
-rw-r--r--ui-refs.c16
-rw-r--r--ui-snapshot.c2
-rw-r--r--ui-snapshot.h2
17 files changed, 133 insertions, 69 deletions
diff --git a/Makefile b/Makefile
index 2dc92df..6fac5bd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
1all:: 1all::
2 2
3CGIT_VERSION = v0.10 3CGIT_VERSION = v0.10.1
4CGIT_SCRIPT_NAME = cgit.cgi 4CGIT_SCRIPT_NAME = cgit.cgi
5CGIT_SCRIPT_PATH = /var/www/htdocs/cgit 5CGIT_SCRIPT_PATH = /var/www/htdocs/cgit
6CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) 6CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH)
@@ -14,7 +14,7 @@ htmldir = $(docdir)
14pdfdir = $(docdir) 14pdfdir = $(docdir)
15mandir = $(prefix)/share/man 15mandir = $(prefix)/share/man
16SHA1_HEADER = <openssl/sha.h> 16SHA1_HEADER = <openssl/sha.h>
17GIT_VER = 1.8.5 17GIT_VER = 1.9.0
18GIT_URL = https://git-core.googlecode.com/files/git-$(GIT_VER).tar.gz 18GIT_URL = https://git-core.googlecode.com/files/git-$(GIT_VER).tar.gz
19INSTALL = install 19INSTALL = install
20COPYTREE = cp -r 20COPYTREE = cp -r
@@ -29,6 +29,7 @@ DOC_PDF = $(patsubst %.txt,%.pdf,$(MAN_TXT))
29# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t). 29# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
30# some C compilers supported these specifiers prior to C99 as an extension. 30# some C compilers supported these specifiers prior to C99 as an extension.
31# 31#
32# Define HAVE_LINUX_SENDFILE to use sendfile()
32 33
33#-include config.mak 34#-include config.mak
34 35
diff --git a/README b/README
index 7b72842..faf1851 100644
--- a/README
+++ b/README
@@ -38,14 +38,11 @@ If you'd like to compile without Lua support, you may use:
38 38
39And if you'd like to specify a Lua implementation, you may use: 39And if you'd like to specify a Lua implementation, you may use:
40 40
41 $ make LUA_IMPLEMENTATION=JIT 41 $ make LUA_PKGCONFIG=lua5.1
42 42
43for using the LuaJIT project. Or: 43If this is not specified, the Lua implementation will be auto-detected,
44 44preferring LuaJIT if many are present. Acceptable values are generally "lua",
45 $ make LUA_IMPLEMENTATION=VANILLA 45"luajit", "lua5.1", and "lua5.2".
46
47for the mainline Lua project. If you specify neither implementation, it will
48be auto-detected, preferring LuaJIT if both are present.
49 46
50 47
51Dependencies 48Dependencies
@@ -54,7 +51,7 @@ Dependencies
54* libzip 51* libzip
55* libcrypto (OpenSSL) 52* libcrypto (OpenSSL)
56* libssl (OpenSSL) 53* libssl (OpenSSL)
57* optional: luajit or lua 54* optional: luajit or lua, most reliably used when pkg-config is available
58 55
59Apache configuration 56Apache configuration
60-------------------- 57--------------------
diff --git a/cache.c b/cache.c
index fcd461f..801e63f 100644
--- a/cache.c
+++ b/cache.c
@@ -13,6 +13,9 @@
13 * 13 *
14 */ 14 */
15 15
16#ifdef HAVE_LINUX_SENDFILE
17#include <sys/sendfile.h>
18#endif
16#include "cgit.h" 19#include "cgit.h"
17#include "cache.h" 20#include "cache.h"
18#include "html.h" 21#include "html.h"
@@ -30,7 +33,6 @@ struct cache_slot {
30 const char *lock_name; 33 const char *lock_name;
31 int match; 34 int match;
32 struct stat cache_st; 35 struct stat cache_st;
33 struct stat lock_st;
34 int bufsize; 36 int bufsize;
35 char buf[CACHE_BUFSIZE]; 37 char buf[CACHE_BUFSIZE];
36}; 38};
@@ -81,6 +83,23 @@ static int close_slot(struct cache_slot *slot)
81/* Print the content of the active cache slot (but skip the key). */ 83/* Print the content of the active cache slot (but skip the key). */
82static int print_slot(struct cache_slot *slot) 84static int print_slot(struct cache_slot *slot)
83{ 85{
86#ifdef HAVE_LINUX_SENDFILE
87 off_t start_off;
88 int ret;
89
90 start_off = slot->keylen + 1;
91
92 do {
93 ret = sendfile(STDOUT_FILENO, slot->cache_fd, &start_off,
94 slot->cache_st.st_size - start_off);
95 if (ret < 0) {
96 if (errno == EAGAIN || errno == EINTR)
97 continue;
98 return errno;
99 }
100 return 0;
101 } while (1);
102#else
84 ssize_t i, j; 103 ssize_t i, j;
85 104
86 i = lseek(slot->cache_fd, slot->keylen + 1, SEEK_SET); 105 i = lseek(slot->cache_fd, slot->keylen + 1, SEEK_SET);
@@ -97,6 +116,7 @@ static int print_slot(struct cache_slot *slot)
97 return errno; 116 return errno;
98 else 117 else
99 return 0; 118 return 0;
119#endif
100} 120}
101 121
102/* Check if the slot has expired */ 122/* Check if the slot has expired */
@@ -188,6 +208,10 @@ static int fill_slot(struct cache_slot *slot)
188 /* Generate cache content */ 208 /* Generate cache content */
189 slot->fn(); 209 slot->fn();
190 210
211 /* update stat info */
212 if (fstat(slot->lock_fd, &slot->cache_st))
213 return errno;
214
191 /* Restore stdout */ 215 /* Restore stdout */
192 if (dup2(tmp, STDOUT_FILENO) == -1) 216 if (dup2(tmp, STDOUT_FILENO) == -1)
193 return errno; 217 return errno;
@@ -319,7 +343,7 @@ int cache_process(int size, const char *path, const char *key, int ttl,
319 int result; 343 int result;
320 344
321 /* If the cache is disabled, just generate the content */ 345 /* If the cache is disabled, just generate the content */
322 if (size <= 0) { 346 if (size <= 0 || ttl == 0) {
323 fn(); 347 fn();
324 return 0; 348 return 0;
325 } 349 }
diff --git a/cgit.c b/cgit.c
index 09fce0c..f488ebf 100644
--- a/cgit.c
+++ b/cgit.c
@@ -184,6 +184,8 @@ static void config_cb(const char *name, const char *value)
184 ctx.cfg.cache_dynamic_ttl = atoi(value); 184 ctx.cfg.cache_dynamic_ttl = atoi(value);
185 else if (!strcmp(name, "cache-about-ttl")) 185 else if (!strcmp(name, "cache-about-ttl"))
186 ctx.cfg.cache_about_ttl = atoi(value); 186 ctx.cfg.cache_about_ttl = atoi(value);
187 else if (!strcmp(name, "cache-snapshot-ttl"))
188 ctx.cfg.cache_snapshot_ttl = atoi(value);
187 else if (!strcmp(name, "case-sensitive-sort")) 189 else if (!strcmp(name, "case-sensitive-sort"))
188 ctx.cfg.case_sensitive_sort = atoi(value); 190 ctx.cfg.case_sensitive_sort = atoi(value);
189 else if (!strcmp(name, "about-filter")) 191 else if (!strcmp(name, "about-filter"))
@@ -331,6 +333,7 @@ static void prepare_context(void)
331 ctx.cfg.cache_max_create_time = 5; 333 ctx.cfg.cache_max_create_time = 5;
332 ctx.cfg.cache_root = CGIT_CACHE_ROOT; 334 ctx.cfg.cache_root = CGIT_CACHE_ROOT;
333 ctx.cfg.cache_about_ttl = 15; 335 ctx.cfg.cache_about_ttl = 15;
336 ctx.cfg.cache_snapshot_ttl = 5;
334 ctx.cfg.cache_repo_ttl = 5; 337 ctx.cfg.cache_repo_ttl = 5;
335 ctx.cfg.cache_root_ttl = 5; 338 ctx.cfg.cache_root_ttl = 5;
336 ctx.cfg.cache_scanrc_ttl = 15; 339 ctx.cfg.cache_scanrc_ttl = 15;
@@ -921,6 +924,23 @@ static void cgit_parse_args(int argc, const char **argv)
921 int scan = 0; 924 int scan = 0;
922 925
923 for (i = 1; i < argc; i++) { 926 for (i = 1; i < argc; i++) {
927 if (!strcmp(argv[i], "--version")) {
928 printf("CGit %s | http://git.zx2c4.com/cgit/\n\nCompiled in features:\n", CGIT_VERSION);
929#ifdef NO_LUA
930 printf("[-] ");
931#else
932 printf("[+] ");
933#endif
934 printf("Lua scripting\n");
935#ifndef HAVE_LINUX_SENDFILE
936 printf("[-] ");
937#else
938 printf("[+] ");
939#endif
940 printf("Linux sendfile() usage\n");
941
942 exit(0);
943 }
924 if (!prefixcmp(argv[i], "--cache=")) { 944 if (!prefixcmp(argv[i], "--cache=")) {
925 ctx.cfg.cache_root = xstrdup(argv[i] + 8); 945 ctx.cfg.cache_root = xstrdup(argv[i] + 8);
926 } else if (!strcmp(argv[i], "--nocache")) { 946 } else if (!strcmp(argv[i], "--nocache")) {
@@ -978,6 +998,9 @@ static int calc_ttl()
978 if (!strcmp(ctx.qry.page, "about")) 998 if (!strcmp(ctx.qry.page, "about"))
979 return ctx.cfg.cache_about_ttl; 999 return ctx.cfg.cache_about_ttl;
980 1000
1001 if (!strcmp(ctx.qry.page, "snapshot"))
1002 return ctx.cfg.cache_snapshot_ttl;
1003
981 if (ctx.qry.has_sha1) 1004 if (ctx.qry.has_sha1)
982 return ctx.cfg.cache_static_ttl; 1005 return ctx.cfg.cache_static_ttl;
983 1006
diff --git a/cgit.h b/cgit.h
index 496d0f6..0badc64 100644
--- a/cgit.h
+++ b/cgit.h
@@ -210,6 +210,7 @@ struct cgit_config {
210 int cache_scanrc_ttl; 210 int cache_scanrc_ttl;
211 int cache_static_ttl; 211 int cache_static_ttl;
212 int cache_about_ttl; 212 int cache_about_ttl;
213 int cache_snapshot_ttl;
213 int case_sensitive_sort; 214 int case_sensitive_sort;
214 int embedded; 215 int embedded;
215 int enable_filter_overrides; 216 int enable_filter_overrides;
diff --git a/cgit.mk b/cgit.mk
index 056c3f9..5048b09 100644
--- a/cgit.mk
+++ b/cgit.mk
@@ -29,30 +29,18 @@ ifdef NO_LUA
29 LUA_MESSAGE := linking without specified Lua support 29 LUA_MESSAGE := linking without specified Lua support
30 CGIT_CFLAGS += -DNO_LUA 30 CGIT_CFLAGS += -DNO_LUA
31else 31else
32LUAJIT_CFLAGS := $(shell pkg-config --cflags luajit 2>/dev/null) 32ifeq ($(LUA_PKGCONFIG),)
33LUAJIT_LIBS := $(shell pkg-config --libs luajit 2>/dev/null) 33 LUA_PKGCONFIG := $(shell for pc in luajit lua lua5.2 lua5.1; do \
34LUA_LIBS := $(shell pkg-config --libs lua 2>/dev/null) 34 pkg-config --exists $$pc 2>/dev/null && echo $$pc && break; \
35LUA_CFLAGS := $(shell pkg-config --cflags lua 2>/dev/null) 35 done)
36ifeq (JIT,$(LUA_IMPLEMENTATION)) 36 LUA_MODE := autodetected
37 ifeq ($(strip $(LUAJIT_LIBS)),) 37else
38 $(error LuaJIT specified via LUA_IMPLEMENTATION=JIT, but library could not be found.) 38 LUA_MODE := specified
39 endif 39endif
40 LUA_MESSAGE := linking with selected LuaJIT 40ifneq ($(LUA_PKGCONFIG),)
41 CGIT_LIBS += $(LUAJIT_LIBS) 41 LUA_MESSAGE := linking with $(LUA_MODE) $(LUA_PKGCONFIG)
42 CGIT_CFLAGS += $(LUAJIT_CFLAGS) 42 LUA_LIBS := $(shell pkg-config --libs $(LUA_PKGCONFIG) 2>/dev/null)
43else ifeq (VANILLA,$(LUA_IMPLEMENTATION)) 43 LUA_CFLAGS := $(shell pkg-config --cflags $(LUA_PKGCONFIG) 2>/dev/null)
44 ifeq ($(strip $(LUA_LIBS)),)
45 $(error Lua specified via LUA_IMPLEMENTATION=VANILLA, but library could not be found.)
46 endif
47 LUA_MESSAGE := linking with selected Lua
48 CGIT_LIBS += $(LUA_LIBS)
49 CGIT_LIBS += $(LUA_CFLAGS)
50else ifneq ($(strip $(LUAJIT_LIBS)),)
51 LUA_MESSAGE := linking with autodetected LuaJIT
52 CGIT_LIBS += $(LUAJIT_LIBS)
53 CGIT_CFLAGS += $(LUAJIT_CFLAGS)
54else ifneq ($(strip $(LUA_LIBS)),)
55 LUA_MESSAGE := linking with autodetected Lua
56 CGIT_LIBS += $(LUA_LIBS) 44 CGIT_LIBS += $(LUA_LIBS)
57 CGIT_CFLAGS += $(LUA_CFLAGS) 45 CGIT_CFLAGS += $(LUA_CFLAGS)
58else 46else
@@ -68,6 +56,14 @@ ifeq ($(findstring BSD,$(uname_S)),)
68 CGIT_LIBS += -ldl 56 CGIT_LIBS += -ldl
69endif 57endif
70 58
59# glibc 2.1+ offers sendfile which the most common C library on Linux
60ifeq ($(uname_S),Linux)
61 HAVE_LINUX_SENDFILE = YesPlease
62endif
63
64ifdef HAVE_LINUX_SENDFILE
65 CGIT_CFLAGS += -DHAVE_LINUX_SENDFILE
66endif
71 67
72CGIT_OBJ_NAMES += cgit.o 68CGIT_OBJ_NAMES += cgit.o
73CGIT_OBJ_NAMES += cache.o 69CGIT_OBJ_NAMES += cache.o
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 8eafc4a..cbaebca 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -60,37 +60,41 @@ cache-root::
60 60
61cache-static-ttl:: 61cache-static-ttl::
62 Number which specifies the time-to-live, in minutes, for the cached 62 Number which specifies the time-to-live, in minutes, for the cached
63 version of repository pages accessed with a fixed SHA1. Negative 63 version of repository pages accessed with a fixed SHA1. See also:
64 values have infinite ttl. Default value: -1". 64 "CACHE". Default value: -1".
65 65
66cache-dynamic-ttl:: 66cache-dynamic-ttl::
67 Number which specifies the time-to-live, in minutes, for the cached 67 Number which specifies the time-to-live, in minutes, for the cached
68 version of repository pages accessed without a fixed SHA1. Negative 68 version of repository pages accessed without a fixed SHA1. See also:
69 values have infinite ttl. Default value: "5". 69 "CACHE". Default value: "5".
70 70
71cache-repo-ttl:: 71cache-repo-ttl::
72 Number which specifies the time-to-live, in minutes, for the cached 72 Number which specifies the time-to-live, in minutes, for the cached
73 version of the repository summary page. Negative values have infinite 73 version of the repository summary page. See also: "CACHE". Default
74 ttl. Default value: "5". 74 value: "5".
75 75
76cache-root-ttl:: 76cache-root-ttl::
77 Number which specifies the time-to-live, in minutes, for the cached 77 Number which specifies the time-to-live, in minutes, for the cached
78 version of the repository index page. Negative values have infinite 78 version of the repository index page. See also: "CACHE". Default
79 ttl. Default value: "5". 79 value: "5".
80 80
81cache-scanrc-ttl:: 81cache-scanrc-ttl::
82 Number which specifies the time-to-live, in minutes, for the result 82 Number which specifies the time-to-live, in minutes, for the result
83 of scanning a path for git repositories. Negative values have infinite 83 of scanning a path for git repositories. See also: "CACHE". Default
84 ttl. Default value: "15". 84 value: "15".
85 85
86cache-about-ttl:: 86cache-about-ttl::
87 Number which specifies the time-to-live, in minutes, for the cached 87 Number which specifies the time-to-live, in minutes, for the cached
88 version of the repository about page. Negative values have infinite 88 version of the repository about page. See also: "CACHE". Default
89 ttl. Default value: "15". 89 value: "15".
90
91cache-snapshot-ttl::
92 Number which specifies the time-to-live, in minutes, for the cached
93 version of snapshots. See also: "CACHE". Default value: "5".
90 94
91cache-size:: 95cache-size::
92 The maximum number of entries in the cgit cache. Default value: "0" 96 The maximum number of entries in the cgit cache. When set to "0",
93 (i.e. caching is disabled). 97 caching is disabled. See also: "CACHE". Default value: "0"
94 98
95case-sensitive-sort:: 99case-sensitive-sort::
96 Sort items in the repo list case sensitively. Default value: "1". 100 Sort items in the repo list case sensitively. Default value: "1".
@@ -712,6 +716,16 @@ the environment variables defined in "FILTER API":
712- repo.clone-url 716- repo.clone-url
713 717
714 718
719CACHE
720------
721
722All cache ttl values are in minutes. Negative ttl values indicate that a page
723type will never expire, and thus the first time a URL is accessed, the result
724will be cached indefinitely, even if the underlying git repository changes.
725Conversely, when a ttl value is zero, the cache is disabled for that
726particular page type, and the page type is never cached.
727
728
715EXAMPLE CGITRC FILE 729EXAMPLE CGITRC FILE
716------------------- 730-------------------
717 731
diff --git a/cmd.c b/cmd.c
index cbd235c..188cd56 100644
--- a/cmd.c
+++ b/cmd.c
@@ -113,7 +113,7 @@ static void refs_fn(void)
113static void snapshot_fn(void) 113static void snapshot_fn(void)
114{ 114{
115 cgit_print_snapshot(ctx.qry.head, ctx.qry.sha1, ctx.qry.path, 115 cgit_print_snapshot(ctx.qry.head, ctx.qry.sha1, ctx.qry.path,
116 ctx.repo->snapshots, ctx.qry.nohead); 116 ctx.qry.nohead);
117} 117}
118 118
119static void stats_fn(void) 119static void stats_fn(void)
diff --git a/filters/simple-authentication.lua b/filters/simple-authentication.lua
index 230d3a3..cc86b7e 100644
--- a/filters/simple-authentication.lua
+++ b/filters/simple-authentication.lua
@@ -166,7 +166,7 @@ function url_encode(str)
166 return "" 166 return ""
167 end 167 end
168 str = string.gsub(str, "\n", "\r\n") 168 str = string.gsub(str, "\n", "\r\n")
169 str = string.gsub(str, "([^%w ])", function (c) return string.format("%%%02X", string.byte(c)) end) 169 str = string.gsub(str, "([^%w ])", function(c) return string.format("%%%02X", string.byte(c)) end)
170 str = string.gsub(str, " ", "+") 170 str = string.gsub(str, " ", "+")
171 return str 171 return str
172end 172end
diff --git a/gen-version.sh b/gen-version.sh
index 3a08015..80cf49a 100755
--- a/gen-version.sh
+++ b/gen-version.sh
@@ -4,7 +4,7 @@
4V=$1 4V=$1
5 5
6# Use `git describe` to get current version if we're inside a git repo 6# Use `git describe` to get current version if we're inside a git repo
7if test -d .git 7if test "$(git rev-parse --git-dir 2>/dev/null)" = '.git'
8then 8then
9 V=$(git describe --abbrev=4 HEAD 2>/dev/null) 9 V=$(git describe --abbrev=4 HEAD 2>/dev/null)
10fi 10fi
diff --git a/git b/git
Subproject d2446dfd7f3b3f8948142cfb07a0270e2497d93 Subproject 5f95c9f850b19b368c43ae399cc831b17a26a5a
diff --git a/shared.c b/shared.c
index 7e88bbd..8ed14c0 100644
--- a/shared.c
+++ b/shared.c
@@ -368,6 +368,7 @@ void cgit_diff_tree(const unsigned char *old_sha1,
368 struct diff_options opt; 368 struct diff_options opt;
369 struct pathspec_item item; 369 struct pathspec_item item;
370 370
371 memset(&item, 0, sizeof(item));
371 diff_setup(&opt); 372 diff_setup(&opt);
372 opt.output_format = DIFF_FORMAT_CALLBACK; 373 opt.output_format = DIFF_FORMAT_CALLBACK;
373 opt.detect_rename = 1; 374 opt.detect_rename = 1;
diff --git a/tests/setup.sh b/tests/setup.sh
index 785edd7..7590f04 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -60,6 +60,12 @@ fi
60 60
61FILTER_DIRECTORY=$(cd ../filters && pwd) 61FILTER_DIRECTORY=$(cd ../filters && pwd)
62 62
63if cgit --version | grep -F -q "[+] Lua scripting"; then
64 export CGIT_HAS_LUA=1
65else
66 export CGIT_HAS_LUA=0
67fi
68
63mkrepo() { 69mkrepo() {
64 name=$1 70 name=$1
65 count=$2 71 count=$2
@@ -133,7 +139,10 @@ repo.commit-filter=exec:$FILTER_DIRECTORY/dump.sh
133repo.email-filter=exec:$FILTER_DIRECTORY/dump.sh 139repo.email-filter=exec:$FILTER_DIRECTORY/dump.sh
134repo.source-filter=exec:$FILTER_DIRECTORY/dump.sh 140repo.source-filter=exec:$FILTER_DIRECTORY/dump.sh
135repo.readme=master:a+b 141repo.readme=master:a+b
142EOF
136 143
144 if [ $CGIT_HAS_LUA -eq 1 ]; then
145 cat >>cgitrc <<EOF
137repo.url=filter-lua 146repo.url=filter-lua
138repo.path=$PWD/repos/filter/.git 147repo.path=$PWD/repos/filter/.git
139repo.desc=filtered repo 148repo.desc=filtered repo
@@ -143,6 +152,7 @@ repo.email-filter=lua:$FILTER_DIRECTORY/dump.lua
143repo.source-filter=lua:$FILTER_DIRECTORY/dump.lua 152repo.source-filter=lua:$FILTER_DIRECTORY/dump.lua
144repo.readme=master:a+b 153repo.readme=master:a+b
145EOF 154EOF
155 fi
146} 156}
147 157
148cgit_query() 158cgit_query()
@@ -155,7 +165,7 @@ cgit_url()
155 CGIT_CONFIG="$PWD/cgitrc" QUERY_STRING="url=$1" cgit 165 CGIT_CONFIG="$PWD/cgitrc" QUERY_STRING="url=$1" cgit
156} 166}
157 167
158strip_headers () { 168strip_headers() {
159 while read -r line 169 while read -r line
160 do 170 do
161 test -z "$line" && break 171 test -z "$line" && break
diff --git a/tests/t0111-filter.sh b/tests/t0111-filter.sh
index 730f1c0..2fdc366 100755
--- a/tests/t0111-filter.sh
+++ b/tests/t0111-filter.sh
@@ -3,7 +3,12 @@
3test_description='Check filtered content' 3test_description='Check filtered content'
4. ./setup.sh 4. ./setup.sh
5 5
6for prefix in exec lua 6prefixes="exec"
7if [ $CGIT_HAS_LUA -eq 1 ]; then
8 prefixes="$prefixes lua"
9fi
10
11for prefix in $prefixes
7do 12do
8 test_expect_success "generate filter-$prefix/tree/a%2bb" " 13 test_expect_success "generate filter-$prefix/tree/a%2bb" "
9 cgit_url 'filter-$prefix/tree/a%2bb' >tmp 14 cgit_url 'filter-$prefix/tree/a%2bb' >tmp
diff --git a/ui-refs.c b/ui-refs.c
index 147b665..0da063f 100644
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -11,18 +11,10 @@
11#include "html.h" 11#include "html.h"
12#include "ui-shared.h" 12#include "ui-shared.h"
13 13
14static int cmp_age(int age1, int age2) 14static inline int cmp_age(int age1, int age2)
15{ 15{
16 if (age1 != 0 && age2 != 0) 16 /* age1 and age2 are assumed to be non-negative */
17 return age2 - age1; 17 return age2 - age1;
18
19 if (age1 == 0 && age2 == 0)
20 return 0;
21
22 if (age1 == 0)
23 return +1;
24
25 return -1;
26} 18}
27 19
28static int cmp_ref_name(const void *a, const void *b) 20static int cmp_ref_name(const void *a, const void *b)
@@ -105,7 +97,7 @@ static void print_tag_downloads(const struct cgit_repo *repo, const char *ref)
105 const char *basename; 97 const char *basename;
106 int free_ref = 0; 98 int free_ref = 0;
107 99
108 if (!ref || strlen(ref) < 2) 100 if (!ref || strlen(ref) < 1)
109 return; 101 return;
110 102
111 basename = cgit_repobasename(repo->url); 103 basename = cgit_repobasename(repo->url);
diff --git a/ui-snapshot.c b/ui-snapshot.c
index 582dc31..3107b05 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -193,7 +193,7 @@ static void show_error(char *fmt, ...)
193} 193}
194 194
195void cgit_print_snapshot(const char *head, const char *hex, 195void cgit_print_snapshot(const char *head, const char *hex,
196 const char *filename, int snapshots, int dwim) 196 const char *filename, int dwim)
197{ 197{
198 const struct cgit_snapshot_format* f; 198 const struct cgit_snapshot_format* f;
199 char *prefix = NULL; 199 char *prefix = NULL;
diff --git a/ui-snapshot.h b/ui-snapshot.h
index b6ede52..a8deec3 100644
--- a/ui-snapshot.h
+++ b/ui-snapshot.h
@@ -2,6 +2,6 @@
2#define UI_SNAPSHOT_H 2#define UI_SNAPSHOT_H
3 3
4extern void cgit_print_snapshot(const char *head, const char *hex, 4extern void cgit_print_snapshot(const char *head, const char *hex,
5 const char *filename, int snapshot, int dwim); 5 const char *filename, int dwim);
6 6
7#endif /* UI_SNAPSHOT_H */ 7#endif /* UI_SNAPSHOT_H */