From ea7210bef377be4ffb088a1a8e5a9dd354f82afb Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 18 Jan 2014 00:45:01 +0100 Subject: README: document pkg-config for luajit Signed-off-by: Jason A. Donenfeld diff --git a/README b/README index 7b72842..9f26959 100644 --- a/README +++ b/README @@ -54,7 +54,7 @@ Dependencies * libzip * libcrypto (OpenSSL) * libssl (OpenSSL) -* optional: luajit or lua +* optional: luajit or lua, most reliably used when pkg-config is available Apache configuration -------------------- -- cgit v0.10.1 From d3581b58890389794de5d5222c91a0129873e95c Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sat, 18 Jan 2014 21:24:58 +0100 Subject: cache: use sendfile() instead of a pair of read() + write() sendfile() does the same job and avoids to copy the content into userland and back. One has to define NO_SENDFILE in case the OS (kernel / libc) does not supported. It is disabled by default on non-linux environemnts. According to the glibc, sendfile64() was added in Linux 2.4 (so it has been there for a while) but after browsing over the mapage of FreeBSD's I noticed that the prototype is little different. Signed-off-by: Sebastian Andrzej Siewior diff --git a/Makefile b/Makefile index 2dc92df..05b97d7 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,7 @@ DOC_PDF = $(patsubst %.txt,%.pdf,$(MAN_TXT)) # j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t). # some C compilers supported these specifiers prior to C99 as an extension. # +# Define HAVE_LINUX_SENDFILE to use sendfile() #-include config.mak diff --git a/cache.c b/cache.c index fcd461f..9e7eeb0 100644 --- a/cache.c +++ b/cache.c @@ -13,6 +13,9 @@ * */ +#ifdef HAVE_LINUX_SENDFILE +#include +#endif #include "cgit.h" #include "cache.h" #include "html.h" @@ -30,7 +33,6 @@ struct cache_slot { const char *lock_name; int match; struct stat cache_st; - struct stat lock_st; int bufsize; char buf[CACHE_BUFSIZE]; }; @@ -81,6 +83,23 @@ static int close_slot(struct cache_slot *slot) /* Print the content of the active cache slot (but skip the key). */ static int print_slot(struct cache_slot *slot) { +#ifdef HAVE_LINUX_SENDFILE + off_t start_off; + int ret; + + start_off = slot->keylen + 1; + + do { + ret = sendfile(STDOUT_FILENO, slot->cache_fd, &start_off, + slot->cache_st.st_size - start_off); + if (ret < 0) { + if (errno == EAGAIN || errno == EINTR) + continue; + return errno; + } + return 0; + } while (1); +#else ssize_t i, j; i = lseek(slot->cache_fd, slot->keylen + 1, SEEK_SET); @@ -97,6 +116,7 @@ static int print_slot(struct cache_slot *slot) return errno; else return 0; +#endif } /* Check if the slot has expired */ @@ -188,6 +208,10 @@ static int fill_slot(struct cache_slot *slot) /* Generate cache content */ slot->fn(); + /* update stat info */ + if (fstat(slot->lock_fd, &slot->cache_st)) + return errno; + /* Restore stdout */ if (dup2(tmp, STDOUT_FILENO) == -1) return errno; diff --git a/cgit.mk b/cgit.mk index 056c3f9..3b8b79a 100644 --- a/cgit.mk +++ b/cgit.mk @@ -68,6 +68,14 @@ ifeq ($(findstring BSD,$(uname_S)),) CGIT_LIBS += -ldl endif +# glibc 2.1+ offers sendfile which the most common C library on Linux +ifeq ($(uname_S),Linux) + HAVE_LINUX_SENDFILE = YesPlease +endif + +ifdef HAVE_LINUX_SENDFILE + CGIT_CFLAGS += -DHAVE_LINUX_SENDFILE +endif CGIT_OBJ_NAMES += cgit.o CGIT_OBJ_NAMES += cache.o -- cgit v0.10.1 From 6a1563343c48f9e38b85f39f4a95c89ea0f46a60 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 20 Jan 2014 13:05:08 +0100 Subject: cgit: add --version argument for printing info We need this to do runtime tests for make test. Signed-off-by: Jason A. Donenfeld diff --git a/cgit.c b/cgit.c index 09fce0c..36251e7 100644 --- a/cgit.c +++ b/cgit.c @@ -921,6 +921,23 @@ static void cgit_parse_args(int argc, const char **argv) int scan = 0; for (i = 1; i < argc; i++) { + if (!strcmp(argv[i], "--version")) { + printf("CGit %s | http://git.zx2c4.com/cgit/\n\nCompiled in features:\n", CGIT_VERSION); +#ifdef NO_LUA + printf("[-] "); +#else + printf("[+] "); +#endif + printf("Lua scripting\n"); +#ifndef HAVE_LINUX_SENDFILE + printf("[-] "); +#else + printf("[+] "); +#endif + printf("Linux sendfile() usage\n"); + + exit(0); + } if (!prefixcmp(argv[i], "--cache=")) { ctx.cfg.cache_root = xstrdup(argv[i] + 8); } else if (!strcmp(argv[i], "--nocache")) { -- cgit v0.10.1 From f759cc0f08c195940de05d5394f7b1ad4d44365e Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 20 Jan 2014 13:11:10 +0100 Subject: tests: only do lua tests if lua is compiled-in Signed-off-by: Jason A. Donenfeld 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 FILTER_DIRECTORY=$(cd ../filters && pwd) +if cgit --version | grep -F -q "[+] Lua scripting"; then + export CGIT_HAS_LUA=1 +else + export CGIT_HAS_LUA=0 +fi + mkrepo() { name=$1 count=$2 @@ -133,7 +139,10 @@ repo.commit-filter=exec:$FILTER_DIRECTORY/dump.sh repo.email-filter=exec:$FILTER_DIRECTORY/dump.sh repo.source-filter=exec:$FILTER_DIRECTORY/dump.sh repo.readme=master:a+b +EOF + if [ $CGIT_HAS_LUA -eq 1 ]; then + cat >>cgitrc <tmp -- cgit v0.10.1 From 44ccae4227060f91c60ad45de1188e728ce8af0d Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 22 Jan 2014 13:15:08 +0100 Subject: makefile: use LUA_PKGCONFIG to set Lua implementation This breaks compat with the previous LUA_IMPLEMENTATION but gives more flexibility in that user can specify the pkg-config package name directly. Signed-off-by: Natanael Copa diff --git a/README b/README index 9f26959..faf1851 100644 --- a/README +++ b/README @@ -38,14 +38,11 @@ If you'd like to compile without Lua support, you may use: And if you'd like to specify a Lua implementation, you may use: - $ make LUA_IMPLEMENTATION=JIT + $ make LUA_PKGCONFIG=lua5.1 -for using the LuaJIT project. Or: - - $ make LUA_IMPLEMENTATION=VANILLA - -for the mainline Lua project. If you specify neither implementation, it will -be auto-detected, preferring LuaJIT if both are present. +If this is not specified, the Lua implementation will be auto-detected, +preferring LuaJIT if many are present. Acceptable values are generally "lua", +"luajit", "lua5.1", and "lua5.2". Dependencies diff --git a/cgit.mk b/cgit.mk index 3b8b79a..2e2992f 100644 --- a/cgit.mk +++ b/cgit.mk @@ -29,30 +29,18 @@ ifdef NO_LUA LUA_MESSAGE := linking without specified Lua support CGIT_CFLAGS += -DNO_LUA else -LUAJIT_CFLAGS := $(shell pkg-config --cflags luajit 2>/dev/null) -LUAJIT_LIBS := $(shell pkg-config --libs luajit 2>/dev/null) -LUA_LIBS := $(shell pkg-config --libs lua 2>/dev/null) -LUA_CFLAGS := $(shell pkg-config --cflags lua 2>/dev/null) -ifeq (JIT,$(LUA_IMPLEMENTATION)) - ifeq ($(strip $(LUAJIT_LIBS)),) - $(error LuaJIT specified via LUA_IMPLEMENTATION=JIT, but library could not be found.) - endif - LUA_MESSAGE := linking with selected LuaJIT - CGIT_LIBS += $(LUAJIT_LIBS) - CGIT_CFLAGS += $(LUAJIT_CFLAGS) -else ifeq (VANILLA,$(LUA_IMPLEMENTATION)) - ifeq ($(strip $(LUA_LIBS)),) - $(error Lua specified via LUA_IMPLEMENTATION=VANILLA, but library could not be found.) - endif - LUA_MESSAGE := linking with selected Lua - CGIT_LIBS += $(LUA_LIBS) - CGIT_LIBS += $(LUA_CFLAGS) -else ifneq ($(strip $(LUAJIT_LIBS)),) - LUA_MESSAGE := linking with autodetected LuaJIT - CGIT_LIBS += $(LUAJIT_LIBS) - CGIT_CFLAGS += $(LUAJIT_CFLAGS) -else ifneq ($(strip $(LUA_LIBS)),) - LUA_MESSAGE := linking with autodetected Lua +ifeq ($(LUA_PKGCONFIG),) + LUA_PKGCONFIG := $(shell for pc in luajit lua lua5.2 lua5.1; do \ + pkg-config --exists $$pc && echo $$pc && break; \ + done) + LUA_MODE := autodetected +else + LUA_MODE := specified +endif +ifneq ($(LUA_PKGCONFIG),) + LUA_MESSAGE := linking with $(LUA_MODE) $(LUA_PKGCONFIG) + LUA_LIBS := $(shell pkg-config --libs $(LUA_PKGCONFIG) 2>/dev/null) + LUA_CFLAGS := $(shell pkg-config --cflags $(LUA_PKGCONFIG) 2>/dev/null) CGIT_LIBS += $(LUA_LIBS) CGIT_CFLAGS += $(LUA_CFLAGS) else -- cgit v0.10.1 From aa6d5b105de9de6d01855c15217e46fd36890dbc Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 23 Jan 2014 00:58:07 +0100 Subject: simple-authentication: style Signed-off-by: Jason A. Donenfeld 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) return "" end str = string.gsub(str, "\n", "\r\n") - str = string.gsub(str, "([^%w ])", function (c) return string.format("%%%02X", string.byte(c)) end) + str = string.gsub(str, "([^%w ])", function(c) return string.format("%%%02X", string.byte(c)) end) str = string.gsub(str, " ", "+") return str end -- cgit v0.10.1 From e8cacb5981039e7e74921659ea50e287395ed411 Mon Sep 17 00:00:00 2001 From: Fabien C Date: Sat, 1 Feb 2014 16:07:46 +0100 Subject: gen-version.sh: check if git is available before trying to call it Some people may clone the cgit repository and compile within a sandbox or on another machine where git is not necessarily installed. When it happens, cgit is getting compiled with an empty version number. This commit fixes this. 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 @@ V=$1 # Use `git describe` to get current version if we're inside a git repo -if test -d .git +if test "$(git rev-parse --git-dir 2>/dev/null)" = '.git' then V=$(git describe --abbrev=4 HEAD 2>/dev/null) fi -- cgit v0.10.1 From 7e1c0ed2aa50ed2290f63912897a3724b224b7ea Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 20 Feb 2014 19:48:24 +0100 Subject: diffstat: do not rely on uninitialized data Right now if you visit: you'll see that if you reload the page a few times, a bunch of times the diffstat comes out with no lines being shown or changed. I'm not currently sure what the cause of this is, but I suspect it might have to do with this uninitialized data. Signed-off-by: Jason A. Donenfeld 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, struct diff_options opt; struct pathspec_item item; + memset(&item, 0, sizeof(item)); diff_setup(&opt); opt.output_format = DIFF_FORMAT_CALLBACK; opt.detect_rename = 1; -- cgit v0.10.1 From a3722ec3c6660ace9fe637d617a0ca225acfacbc Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 5 Feb 2014 10:23:58 +0100 Subject: Add a cache-snapshot-ttl configuration variable This can be used to specify the TTL for snapshots. Snapshots are usually static and do not ever change. On the other hand, tarball generation is CPU intensive. One use case of this setting (apart from increasing the lifetime of snapshot cache slots) is caching of snapshots while disabling the cache for static/dynamic HTML pages (by setting TTL to zero for everything except for snapshot requests). Signed-off-by: Lukas Fleischer diff --git a/cgit.c b/cgit.c index 36251e7..f488ebf 100644 --- a/cgit.c +++ b/cgit.c @@ -184,6 +184,8 @@ static void config_cb(const char *name, const char *value) ctx.cfg.cache_dynamic_ttl = atoi(value); else if (!strcmp(name, "cache-about-ttl")) ctx.cfg.cache_about_ttl = atoi(value); + else if (!strcmp(name, "cache-snapshot-ttl")) + ctx.cfg.cache_snapshot_ttl = atoi(value); else if (!strcmp(name, "case-sensitive-sort")) ctx.cfg.case_sensitive_sort = atoi(value); else if (!strcmp(name, "about-filter")) @@ -331,6 +333,7 @@ static void prepare_context(void) ctx.cfg.cache_max_create_time = 5; ctx.cfg.cache_root = CGIT_CACHE_ROOT; ctx.cfg.cache_about_ttl = 15; + ctx.cfg.cache_snapshot_ttl = 5; ctx.cfg.cache_repo_ttl = 5; ctx.cfg.cache_root_ttl = 5; ctx.cfg.cache_scanrc_ttl = 15; @@ -995,6 +998,9 @@ static int calc_ttl() if (!strcmp(ctx.qry.page, "about")) return ctx.cfg.cache_about_ttl; + if (!strcmp(ctx.qry.page, "snapshot")) + return ctx.cfg.cache_snapshot_ttl; + if (ctx.qry.has_sha1) return ctx.cfg.cache_static_ttl; 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 { int cache_scanrc_ttl; int cache_static_ttl; int cache_about_ttl; + int cache_snapshot_ttl; int case_sensitive_sort; int embedded; int enable_filter_overrides; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 8eafc4a..a437fc4 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -88,6 +88,11 @@ cache-about-ttl:: version of the repository about page. Negative values have infinite ttl. Default value: "15". +cache-snapshot-ttl:: + Number which specifies the time-to-live, in minutes, for the cached + version of snapshots. Negative values have infinite ttl. Default + value: "5". + cache-size:: The maximum number of entries in the cgit cache. Default value: "0" (i.e. caching is disabled). -- cgit v0.10.1 From 8acfa51a8b3c6011483132c933213231f7a4865b Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 20 Feb 2014 20:06:29 +0100 Subject: Makefile: suppress pkg-config error Signed-off-by: Jason A. Donenfeld diff --git a/cgit.mk b/cgit.mk index 2e2992f..5048b09 100644 --- a/cgit.mk +++ b/cgit.mk @@ -31,7 +31,7 @@ ifdef NO_LUA else ifeq ($(LUA_PKGCONFIG),) LUA_PKGCONFIG := $(shell for pc in luajit lua lua5.2 lua5.1; do \ - pkg-config --exists $$pc && echo $$pc && break; \ + pkg-config --exists $$pc 2>/dev/null && echo $$pc && break; \ done) LUA_MODE := autodetected else -- cgit v0.10.1 From 8033dc01f4ae1551c21769f580caa723fb176d9c Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Thu, 20 Feb 2014 20:58:13 +0100 Subject: git: Update to 1.9.0 No code changes required, just bump the submodule and Makefile versions. Signed-off-by: Lukas Fleischer diff --git a/Makefile b/Makefile index 05b97d7..3ee5f65 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 1.8.5 +GIT_VER = 1.9.0 GIT_URL = https://git-core.googlecode.com/files/git-$(GIT_VER).tar.gz INSTALL = install COPYTREE = cp -r diff --git a/git b/git index d2446df..5f95c9f 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit d2446dfd7f3b3f8948142cfb07a0270e2497d93f +Subproject commit 5f95c9f850b19b368c43ae399cc831b17a26a5ac -- cgit v0.10.1 From 6ceba453a27ead382d0116d95bdeb6b6be1149e2 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Thu, 20 Feb 2014 20:59:22 +0100 Subject: Skip cache slot when time-to-live is zero If time-to-live is set to zero, we don't need to regenerate the cache slots on every request. Instead, just skip the caching process and immediately provide the dynamically generated version of the page. Setting time-to-live to zero is useful when you want to disable caching for certain pages. Signed-off-by: Lukas Fleischer diff --git a/cache.c b/cache.c index 9e7eeb0..801e63f 100644 --- a/cache.c +++ b/cache.c @@ -343,7 +343,7 @@ int cache_process(int size, const char *path, const char *key, int ttl, int result; /* If the cache is disabled, just generate the content */ - if (size <= 0) { + if (size <= 0 || ttl == 0) { fn(); return 0; } diff --git a/cgitrc.5.txt b/cgitrc.5.txt index a437fc4..7158c10 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -61,37 +61,43 @@ cache-root:: cache-static-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of repository pages accessed with a fixed SHA1. Negative - values have infinite ttl. Default value: -1". + values have infinite ttl, zero means that the cache is disabled for + this type of pages. Default value: -1". cache-dynamic-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of repository pages accessed without a fixed SHA1. Negative - values have infinite ttl. Default value: "5". + values have infinite ttl, zero means that the cache is disabled for this + type of pages. Default value: "5". cache-repo-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of the repository summary page. Negative values have infinite - ttl. Default value: "5". + ttl, zero means that the cache is disabled for this type of pages. + Default value: "5". cache-root-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of the repository index page. Negative values have infinite - ttl. Default value: "5". + ttl, zero means that the cache is disabled for this type of pages. + Default value: "5". cache-scanrc-ttl:: Number which specifies the time-to-live, in minutes, for the result of scanning a path for git repositories. Negative values have infinite - ttl. Default value: "15". + ttl, zero means that the cache is disable for this type of pages. + Default value: "15". cache-about-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of the repository about page. Negative values have infinite - ttl. Default value: "15". + ttl, zero means that the cache is disable for this type of pages. + Default value: "15". cache-snapshot-ttl:: Number which specifies the time-to-live, in minutes, for the cached - version of snapshots. Negative values have infinite ttl. Default - value: "5". + version of snapshots. Negative values have infinite ttl, zero means + that the cache is disable for this type of pages. Default value: "5". cache-size:: The maximum number of entries in the cgit cache. Default value: "0" -- cgit v0.10.1 From 2e8e9af1d4161bfe1bfbf1e34b1631b7cc1c1b95 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 21 Feb 2014 01:36:20 +0100 Subject: Clean up cache documentation. Signed-off-by: Jason A. Donenfeld diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 7158c10..cbaebca 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -60,48 +60,41 @@ cache-root:: cache-static-ttl:: Number which specifies the time-to-live, in minutes, for the cached - version of repository pages accessed with a fixed SHA1. Negative - values have infinite ttl, zero means that the cache is disabled for - this type of pages. Default value: -1". + version of repository pages accessed with a fixed SHA1. See also: + "CACHE". Default value: -1". cache-dynamic-ttl:: Number which specifies the time-to-live, in minutes, for the cached - version of repository pages accessed without a fixed SHA1. Negative - values have infinite ttl, zero means that the cache is disabled for this - type of pages. Default value: "5". + version of repository pages accessed without a fixed SHA1. See also: + "CACHE". Default value: "5". cache-repo-ttl:: Number which specifies the time-to-live, in minutes, for the cached - version of the repository summary page. Negative values have infinite - ttl, zero means that the cache is disabled for this type of pages. - Default value: "5". + version of the repository summary page. See also: "CACHE". Default + value: "5". cache-root-ttl:: Number which specifies the time-to-live, in minutes, for the cached - version of the repository index page. Negative values have infinite - ttl, zero means that the cache is disabled for this type of pages. - Default value: "5". + version of the repository index page. See also: "CACHE". Default + value: "5". cache-scanrc-ttl:: Number which specifies the time-to-live, in minutes, for the result - of scanning a path for git repositories. Negative values have infinite - ttl, zero means that the cache is disable for this type of pages. - Default value: "15". + of scanning a path for git repositories. See also: "CACHE". Default + value: "15". cache-about-ttl:: Number which specifies the time-to-live, in minutes, for the cached - version of the repository about page. Negative values have infinite - ttl, zero means that the cache is disable for this type of pages. - Default value: "15". + version of the repository about page. See also: "CACHE". Default + value: "15". cache-snapshot-ttl:: Number which specifies the time-to-live, in minutes, for the cached - version of snapshots. Negative values have infinite ttl, zero means - that the cache is disable for this type of pages. Default value: "5". + version of snapshots. See also: "CACHE". Default value: "5". cache-size:: - The maximum number of entries in the cgit cache. Default value: "0" - (i.e. caching is disabled). + The maximum number of entries in the cgit cache. When set to "0", + caching is disabled. See also: "CACHE". Default value: "0" case-sensitive-sort:: Sort items in the repo list case sensitively. Default value: "1". @@ -723,6 +716,16 @@ the environment variables defined in "FILTER API": - repo.clone-url +CACHE +------ + +All cache ttl values are in minutes. Negative ttl values indicate that a page +type will never expire, and thus the first time a URL is accessed, the result +will be cached indefinitely, even if the underlying git repository changes. +Conversely, when a ttl value is zero, the cache is disabled for that +particular page type, and the page type is never cached. + + EXAMPLE CGITRC FILE ------------------- -- cgit v0.10.1 From e6749644bc60865cb560a532b14fb3a007fb00ea Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 20 Feb 2014 20:48:45 +0100 Subject: print download link for reference string length == 1 I have a number of repositories that start tagging with just '1' and count up. Actually references with sting length of one are skipped, this patch changes that. diff --git a/ui-refs.c b/ui-refs.c index 147b665..e8e308e 100644 --- a/ui-refs.c +++ b/ui-refs.c @@ -105,7 +105,7 @@ static void print_tag_downloads(const struct cgit_repo *repo, const char *ref) const char *basename; int free_ref = 0; - if (!ref || strlen(ref) < 2) + if (!ref || strlen(ref) < 1) return; basename = cgit_repobasename(repo->url); -- cgit v0.10.1 From 3e9578e9a3393eaebc658ad650a3241bf1930176 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sat, 8 Feb 2014 14:37:29 +0100 Subject: Remove unused parameter from cgit_print_snapshot() 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) static void snapshot_fn(void) { cgit_print_snapshot(ctx.qry.head, ctx.qry.sha1, ctx.qry.path, - ctx.repo->snapshots, ctx.qry.nohead); + ctx.qry.nohead); } static void stats_fn(void) 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, ...) } void cgit_print_snapshot(const char *head, const char *hex, - const char *filename, int snapshots, int dwim) + const char *filename, int dwim) { const struct cgit_snapshot_format* f; 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 @@ #define UI_SNAPSHOT_H extern void cgit_print_snapshot(const char *head, const char *hex, - const char *filename, int snapshot, int dwim); + const char *filename, int dwim); #endif /* UI_SNAPSHOT_H */ -- cgit v0.10.1 From 493061102653ac6483dc3c9649c726318e2488b6 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 26 Feb 2014 16:57:15 +0100 Subject: ui-refs: simplify cmp_age logic The check in parse_user that eventually makes it into committer_date and tagger_date is: else if (mode == 3 && isdigit(*p)) { *date = atol(p); mode++; } Since isdigit('-') is always false, date will never be negative. Thus the sign of this function: static int cmp_age(int age1, int age2) { if (age1 != 0 && age2 != 0) return age2 - age1; if (age1 == 0 && age2 == 0) return 0; if (age1 == 0) return +1; return -1; } Will always be the same as the sign of this function: static inline int cmp_age(int age1, int age2) { return age2 - age1; } Signed-off-by: Jason A. Donenfeld Idea-by: Lukas Fleischer diff --git a/ui-refs.c b/ui-refs.c index e8e308e..0da063f 100644 --- a/ui-refs.c +++ b/ui-refs.c @@ -11,18 +11,10 @@ #include "html.h" #include "ui-shared.h" -static int cmp_age(int age1, int age2) +static inline int cmp_age(int age1, int age2) { - if (age1 != 0 && age2 != 0) - return age2 - age1; - - if (age1 == 0 && age2 == 0) - return 0; - - if (age1 == 0) - return +1; - - return -1; + /* age1 and age2 are assumed to be non-negative */ + return age2 - age1; } static int cmp_ref_name(const void *a, const void *b) -- cgit v0.10.1 From f2fa9c56e29ae32bbe5841e7bfe0217ada4e3df9 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 28 Feb 2014 00:12:08 +0100 Subject: Bump version. diff --git a/Makefile b/Makefile index 3ee5f65..6fac5bd 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all:: -CGIT_VERSION = v0.10 +CGIT_VERSION = v0.10.1 CGIT_SCRIPT_NAME = cgit.cgi CGIT_SCRIPT_PATH = /var/www/htdocs/cgit CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) -- cgit v0.10.1