diff options
Diffstat (limited to '')
-rw-r--r--source/cgit.c9
-rw-r--r--source/cgit.h1
-rwxr-xr-xtests/t0003-cache.sh19
3 files changed, 21 insertions, 8 deletions
diff --git a/source/cgit.c b/source/cgit.c
index 82c496e..b26a528 100644
--- a/source/cgit.c
+++ b/source/cgit.c
@@ -319,7 +319,6 @@ static void parse_args(int argc, const char **argv)
ctx.qry.page = xstrdup(arg);
} else if (skip_prefix(argv[i], "--head=", &arg)) {
ctx.qry.head = xstrdup(arg);
- ctx.qry.has_symref = 1;
} else if (skip_prefix(argv[i], "--oid=", &arg)) {
ctx.qry.oid = xstrdup(arg);
ctx.qry.has_oid = 1;
@@ -760,7 +759,6 @@ static void apply_query_param(const char *name, const char *value)
ctx.qry.search = xstrdup(value);
} else if (!strcmp(name, "h")) {
ctx.qry.head = xstrdup(value);
- ctx.qry.has_symref = 1;
} else if (!strcmp(name, "id")) {
ctx.qry.oid = xstrdup(value);
ctx.qry.has_oid = 1;
@@ -918,7 +916,7 @@ static int calc_ttl(void)
if (!ctx.repo)
return ctx.cfg.cache_index_ttl;
- if (!ctx.qry.page)
+ if (!ctx.qry.page || !strcmp(ctx.qry.page, "summary"))
return ctx.cfg.cache_summary_ttl;
// The dumb transport serves files that already sit on the disk, so a
@@ -944,10 +942,7 @@ static int calc_ttl(void)
if (!strcmp(ctx.qry.page, "snapshot"))
return ctx.cfg.cache_snapshot_ttl;
- if (ctx.qry.has_symref)
- return ctx.cfg.cache_dynamic_ttl;
-
- return ctx.cfg.cache_summary_ttl;
+ return ctx.cfg.cache_dynamic_ttl;
}
/*
diff --git a/source/cgit.h b/source/cgit.h
index b863e7b..a632fed 100644
--- a/source/cgit.h
+++ b/source/cgit.h
@@ -162,7 +162,6 @@ struct reflist {
};
struct cgit_query {
- int has_symref;
int has_oid;
int has_difftype;
char *raw;
diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh
index 3e2a971..bf38fbb 100755
--- a/tests/t0003-cache.sh
+++ b/tests/t0003-cache.sh
@@ -212,4 +212,23 @@ test_expect_success 'an expired slot is dropped when its refill is too large' '
test_line_count = 0 refill.slots
'
+# The summary page keeps a ttl of its own, while every other page that follows
+# a branch rather than a pinned id takes cache-dynamic-ttl, whether or not its
+# url names the branch.
+test_expect_success 'pages following a branch take the dynamic ttl' '
+ rm -rf cache3 && mkdir cache3 &&
+ {
+ echo "cache-dynamic-ttl=0" &&
+ cat bigkeyrc
+ } >dynamicrc &&
+ CGIT_CONFIG="$PWD/dynamicrc" QUERY_STRING="url=bigpage/log/" cgit >/dev/null &&
+ CGIT_CONFIG="$PWD/dynamicrc" QUERY_STRING="url=bigpage/log/&h=master" cgit >/dev/null &&
+ ls cache3 >dynamic.slots &&
+ test_line_count = 0 dynamic.slots &&
+ CGIT_CONFIG="$PWD/dynamicrc" QUERY_STRING="url=bigpage/" cgit >/dev/null &&
+ CGIT_CONFIG="$PWD/dynamicrc" QUERY_STRING="url=bigpage/summary/" cgit >/dev/null &&
+ ls cache3 >summary.slots &&
+ test_line_count = 2 summary.slots
+'
+
test_done