Diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/cgit.c | 30 | |
| -rw-r--r-- | source/cmd.c | 20 | |
| -rw-r--r-- | source/cmd.h | 4 |
3 files changed, 16 insertions, 38 deletions
diff --git a/source/cgit.c b/source/cgit.c index 715db59..3788d8a 100644 --- a/source/cgit.c +++ b/source/cgit.c @@ -886,33 +886,6 @@ static int is_full_oid(const char *rev) } /* - * Only these pages render the same bytes for the same id for ever. A log or - * refs page named with an id still lists branches and tags, which move. - */ -static int page_is_static(void) -{ - static const char *const pages[] = { - "blame", - "blob", - "commit", - "diff", - "patch", - "plain", - "rawdiff", - "snapshot", - "tag", - "tree", - }; - size_t i; - - for (i = 0; i < ARRAY_SIZE(pages); i++) { - if (!strcmp(ctx.qry.page, pages[i])) - return 1; - } - return 0; -} - -/* * Every cache-*-ttl setting is written in minutes, and so is this. */ static int calc_ttl(void) @@ -939,7 +912,8 @@ static int calc_ttl(void) // page to rebuild. if ( ctx.qry.has_oid && - page_is_static() && + cmd && + cmd->is_static && (!ctx.qry.oid || is_full_oid(ctx.qry.oid)) && (!ctx.qry.oid2 || is_full_oid(ctx.qry.oid2)) ) diff --git a/source/cmd.c b/source/cmd.c index 676e144..7470c1d 100644 --- a/source/cmd.c +++ b/source/cmd.c @@ -159,24 +159,24 @@ static const struct cgit_cmd commands[] = { { .name = "HEAD", .fn = cgit_clone_head, .want_repo = 1, .is_clone = 1 }, { .name = "about", .fn = about_fn }, { .name = "atom", .fn = atom_fn, .want_repo = 1 }, - { .name = "blame", .fn = blame_fn, .want_repo = 1, .want_vpath = 1 }, - { .name = "blob", .fn = blob_fn, .want_repo = 1 }, - { .name = "commit", .fn = commit_fn, .want_repo = 1, .want_vpath = 1 }, - { .name = "diff", .fn = diff_fn, .want_repo = 1, .want_vpath = 1 }, + { .name = "blame", .fn = blame_fn, .want_repo = 1, .want_vpath = 1, .is_static = 1 }, + { .name = "blob", .fn = blob_fn, .want_repo = 1, .is_static = 1 }, + { .name = "commit", .fn = commit_fn, .want_repo = 1, .want_vpath = 1, .is_static = 1 }, + { .name = "diff", .fn = diff_fn, .want_repo = 1, .want_vpath = 1, .is_static = 1 }, { .name = "info", .fn = cgit_clone_info, .want_repo = 1, .is_clone = 1 }, { .name = "log", .fn = log_fn, .want_repo = 1, .want_vpath = 1 }, { .name = "ls_cache", .fn = ls_cache_fn }, { .name = "objects", .fn = cgit_clone_objects, .want_repo = 1, .is_clone = 1 }, - { .name = "patch", .fn = patch_fn, .want_repo = 1, .want_vpath = 1 }, - { .name = "plain", .fn = cgit_print_plain, .want_repo = 1 }, - { .name = "rawdiff", .fn = rawdiff_fn, .want_repo = 1, .want_vpath = 1 }, + { .name = "patch", .fn = patch_fn, .want_repo = 1, .want_vpath = 1, .is_static = 1 }, + { .name = "plain", .fn = cgit_print_plain, .want_repo = 1, .is_static = 1 }, + { .name = "rawdiff", .fn = rawdiff_fn, .want_repo = 1, .want_vpath = 1, .is_static = 1 }, { .name = "refs", .fn = refs_fn, .want_repo = 1 }, { .name = "repolist", .fn = cgit_print_repolist }, - { .name = "snapshot", .fn = snapshot_fn, .want_repo = 1 }, + { .name = "snapshot", .fn = snapshot_fn, .want_repo = 1, .is_static = 1 }, { .name = "stats", .fn = stats_fn, .want_repo = 1, .want_vpath = 1 }, { .name = "summary", .fn = cgit_print_summary, .want_repo = 1 }, - { .name = "tag", .fn = tag_fn, .want_repo = 1 }, - { .name = "tree", .fn = tree_fn, .want_repo = 1, .want_vpath = 1 }, + { .name = "tag", .fn = tag_fn, .want_repo = 1, .is_static = 1 }, + { .name = "tree", .fn = tree_fn, .want_repo = 1, .want_vpath = 1, .is_static = 1 }, }; const struct cgit_cmd *cgit_find_cmd(const char *name) diff --git a/source/cmd.h b/source/cmd.h index f47878b..a855574 100644 --- a/source/cmd.h +++ b/source/cmd.h @@ -14,6 +14,10 @@ struct cgit_cmd { const char *name; cgit_cmd_fn fn; unsigned int want_repo:1, want_vpath:1, is_clone:1; + // Set on the pages that render the same bytes for the same id for + // ever. A log or refs page named with an id still lists branches and + // tags, which move. + unsigned int is_static:1; }; /* |
