diff options
author | Wynn Wolf Arbor | 2020-07-03 15:32:00 +0200 |
---|---|---|
committer | Wynn Wolf Arbor | 2020-07-03 15:34:25 +0200 |
commit | 4627497bb5a9fff46a5daad4898c2809944d5bd5 (patch) | |
tree | a5ee8a6225c02836bd371f4245712c116bc78226 /www-apps/cgit/files | |
parent | ea0a413d193d9bd2e1eec845f6fda8641cb2f659 (diff) | |
download | pramantha-4627497bb5a9fff46a5daad4898c2809944d5bd5.tar.gz |
www-apps/cgit: Split git-http-backend patch in two
Disabling cached clones can be a feature of its own, so split it out of
the git-http-backend patch. This is cleaner in the long run.
Package-Manager: Portage-2.3.99, Repoman-2.3.23
Diffstat (limited to 'www-apps/cgit/files')
-rw-r--r-- | www-apps/cgit/files/cgit-1.2.3-disable-cached-clones.patch | 58 | ||||
-rw-r--r-- | www-apps/cgit/files/cgit-1.2.3-git-http-backend.patch | 49 |
2 files changed, 62 insertions, 45 deletions
diff --git a/www-apps/cgit/files/cgit-1.2.3-disable-cached-clones.patch b/www-apps/cgit/files/cgit-1.2.3-disable-cached-clones.patch new file mode 100644 index 0000000..c9c547e --- /dev/null +++ b/www-apps/cgit/files/cgit-1.2.3-disable-cached-clones.patch @@ -0,0 +1,58 @@ +From 8f9eeb3280c43ef184eb6ce08b322bc7d9ad6c3f Mon Sep 17 00:00:00 2001 +From: Wynn Wolf Arbor <wolf@oriole.systems> +Date: Fri, 3 Jul 2020 15:17:02 +0200 +Subject: [PATCH 1/2] cache: Disable caching for clones + +Whilst the cache feature is useful for content that the web browser will +see, it is less useful when cgit is asked to clone a repository. Users +might end up with a tree that is ever so slightly out of date. + +An upcoming commit will introduce functionality to offload clones to +git-http-backend(1). The cache feature will prevent this from working +correctly. + +Therefore, disable cache processing for commands that have the is_clone +flag set. +--- + cache.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/cache.c b/cache.c +index 2c70be7..bb4fc47 100644 +--- a/cache.c ++++ b/cache.c +@@ -15,6 +15,7 @@ + + #include "cgit.h" + #include "cache.h" ++#include "cmd.h" + #include "html.h" + #ifdef HAVE_LINUX_SENDFILE + #include <sys/sendfile.h> +@@ -356,6 +357,7 @@ int cache_process(int size, const char *path, const char *key, int ttl, + struct strbuf filename = STRBUF_INIT; + struct strbuf lockname = STRBUF_INIT; + struct cache_slot slot; ++ struct cgit_cmd *cmd; + int result; + + /* If the cache is disabled, just generate the content */ +@@ -370,6 +372,15 @@ int cache_process(int size, const char *path, const char *key, int ttl, + fn(); + return 0; + } ++ ++ cmd = cgit_get_cmd(); ++ ++ /* Do not cache files that are being cloned */ ++ if (cmd && cmd->is_clone) { ++ fn(); ++ return 0; ++ } ++ + if (!key) + key = ""; + hash = hash_str(key) % size; +-- +2.27.0 + diff --git a/www-apps/cgit/files/cgit-1.2.3-git-http-backend.patch b/www-apps/cgit/files/cgit-1.2.3-git-http-backend.patch index 93bd4eb..e43eb09 100644 --- a/www-apps/cgit/files/cgit-1.2.3-git-http-backend.patch +++ b/www-apps/cgit/files/cgit-1.2.3-git-http-backend.patch @@ -1,7 +1,7 @@ -From 6c9eb981818260af3b7f4235185ab8b0f94c4f5e Mon Sep 17 00:00:00 2001 +From dcf96f0b2210d15b390ba1a5d26cd271f89aa924 Mon Sep 17 00:00:00 2001 From: Wynn Wolf Arbor <wolf@oriole.systems> -Date: Sat, 30 May 2020 21:51:39 +0200 -Subject: [PATCH] Support Git over HTTP by proxying git-http-backend(1) +Date: Fri, 3 Jul 2020 15:23:45 +0200 +Subject: [PATCH 2/2] Support Git over HTTP by proxying git-http-backend(1) cgit lacks an easy way to support the "smart" HTTP protocol out of the box. A patch [1] has been proposed in the past, but was never merged. @@ -34,59 +34,18 @@ Notable changes to the original patch: def_cmd() macro directly, as the endpoints "git-upload-pack" and "git-receive-pack" contain dashes. - * The original patch did not account for caching support, which will - break the whole clone process if enabled. Work around this by - disabling the cache for commands that have is_clone set to true. - [1] https://lists.zx2c4.com/pipermail/cgit/2014-December/002312.html [2] https://lists.zx2c4.com/pipermail/cgit/2016-February/002907.html [3] https://lists.zx2c4.com/pipermail/cgit/2016-February/002926.html --- - cache.c | 11 +++++++++++ cgit.c | 3 +++ cgit.h | 1 + cgitrc.5.txt | 8 ++++++++ cmd.c | 13 +++++++++++++ ui-clone.c | 42 ++++++++++++++++++++++++++++++++++++++++++ ui-clone.h | 2 ++ - 7 files changed, 80 insertions(+) + 6 files changed, 69 insertions(+) -diff --git a/cache.c b/cache.c -index 2c70be7..bb4fc47 100644 ---- a/cache.c -+++ b/cache.c -@@ -15,6 +15,7 @@ - - #include "cgit.h" - #include "cache.h" -+#include "cmd.h" - #include "html.h" - #ifdef HAVE_LINUX_SENDFILE - #include <sys/sendfile.h> -@@ -356,6 +357,7 @@ int cache_process(int size, const char *path, const char *key, int ttl, - struct strbuf filename = STRBUF_INIT; - struct strbuf lockname = STRBUF_INIT; - struct cache_slot slot; -+ struct cgit_cmd *cmd; - int result; - - /* If the cache is disabled, just generate the content */ -@@ -370,6 +372,15 @@ int cache_process(int size, const char *path, const char *key, int ttl, - fn(); - return 0; - } -+ -+ cmd = cgit_get_cmd(); -+ -+ /* Do not cache files that are being cloned */ -+ if (cmd && cmd->is_clone) { -+ fn(); -+ return 0; -+ } -+ - if (!key) - key = ""; - hash = hash_str(key) % size; diff --git a/cgit.c b/cgit.c index c4320f0..fc85c18 100644 --- a/cgit.c |