From 4627497bb5a9fff46a5daad4898c2809944d5bd5 Mon Sep 17 00:00:00 2001 From: Wynn Wolf Arbor Date: Fri, 3 Jul 2020 15:32:00 +0200 Subject: 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 --- www-apps/cgit/Manifest | 5 +- www-apps/cgit/cgit-1.2.3-r4.ebuild | 1 + .../files/cgit-1.2.3-disable-cached-clones.patch | 58 ++++++++++++++++++++++ .../cgit/files/cgit-1.2.3-git-http-backend.patch | 49 ++---------------- 4 files changed, 66 insertions(+), 47 deletions(-) create mode 100644 www-apps/cgit/files/cgit-1.2.3-disable-cached-clones.patch (limited to 'www-apps') diff --git a/www-apps/cgit/Manifest b/www-apps/cgit/Manifest index 50f975f..a3383b0 100644 --- a/www-apps/cgit/Manifest +++ b/www-apps/cgit/Manifest @@ -1,5 +1,6 @@ -AUX cgit-1.2.3-git-http-backend.patch 7727 BLAKE2B a79f9f187f4b4a3b924f9aef3d1f478e3c1ee79677378458e769dc29ad5e0f6353addf8a2ae1a1db41a2ea99f484f82b31fa38cad8b54a2c7bddbb25a3023aec SHA512 7f96b37ecc0ce7842fcb4bfa05ffc6134769bd01e5660a5fd53ef664dc9a44ca49df9d01b9d94c3859057bb3364602de4eedc0db55459dc418451c5c1f45d384 +AUX cgit-1.2.3-disable-cached-clones.patch 1574 BLAKE2B 05c2627998175566a2f186a4f1946ce943bea67ae28f9dd339530b723545434932bccfe396b908f3a386e864dcf0347787f2521e915bb1df74547838827201ec SHA512 4a1c87d49a22140add69a96ce62a859402162d6740b070b7196a388e7208e4357e2659c0987c0c73828ace0183cf8a20adaf3e59967eb354db419851d9eb4df8 +AUX cgit-1.2.3-git-http-backend.patch 6647 BLAKE2B 920fdc85ec122020bf360587e19fd98067ef61ad11be3f044c4808f9f68eff9bc74bd8d3db5743bae565eb2985e536e3607eb055c99fec37870179c78808f228 SHA512 cfb245c0aa2e783961fca27f56706c6afe021e3c3620c0c6dcb8e29751dc7f68673a6c9c10ae6220efb304703fee4a6d18255015e2f84c4db65839880576f51c DIST cgit-1.2.3.tar.xz 90632 BLAKE2B 594a9b2ae0b449e0ef090f428f955cc02833f5f5b1e4d6dc8c737daa565d01ba6840933c0bdc53d4eb683b2f44e2fae885ddd020cfb2de38141a870a6eae2380 SHA512 58f9bb644b07be49dc51f3ef30a3d0e53699cede3c06b1d6920f3874fe846c83dd2589632aa84357b70ea2d60272448409aa1b892f405d14dd6745f5559b4504 DIST git-2.25.1.tar.xz 5875548 BLAKE2B 582da3d4ac996d7b9ce6cf505661496ab1a2cd061f058745350498121956b33d79739b567fb5fea0b4e298303261256034aa0b8da0b842feab04ae67a7d5b142 SHA512 15241143acfd8542d85d2709ac3c80dbd6e8d5234438f70c4f33cc71a2bdec3e32938df7f6351e2746d570b021d3bd0b70474ea4beec0c51d1fc45f9c287b344 -EBUILD cgit-1.2.3-r4.ebuild 2393 BLAKE2B 5b3f54b347ea51c6ee9682a7099058d12a6757762b24f4e463b5b3ddd7f1a359fed51a018044d84020235e2c5601a68215657677f5066136ee3a2c0fbd4100c0 SHA512 4d67e9db74b9d792ae9821eb2de81f2d5b5c9d6a93017899ffe0adda5da7ead4c383d2319ed657eb96f7368ced06eea75dba11196be1111cf4223147985f95d1 +EBUILD cgit-1.2.3-r4.ebuild 2443 BLAKE2B b681ff0af7e23f261ebd08a9874dc4cf10b5dbe0de9f71eecd1e495ed4efd97e73e578c6d4dbbd093f3c095a088a8aa4f12a20e158caed978d1418904363e42b SHA512 bf964f5782b1ae8bf46cab86e3318610cc3cfaf795b318385d1a4d1b41aa100f6a608111ff9c5fbeb03e938e56d9ee756cf3fda948f09ad462a568928109b353 MISC metadata.xml 1029 BLAKE2B e46976de1886fef155a1488142b4b3733c1e682a8851b4b36449e95759a050722d3147221f3cc587a984e28c2b167dacf3e29a4cc208f30bd52e0216806d2327 SHA512 bcd83dfd7789597db8ef429aebe5c34138aba888706bce5972208e6cb8e991a820691cef5268fcebf9e30ec5bf9d4ccc65d36790372282f96c09243137856fdd diff --git a/www-apps/cgit/cgit-1.2.3-r4.ebuild b/www-apps/cgit/cgit-1.2.3-r4.ebuild index 58030e6..7dae402 100644 --- a/www-apps/cgit/cgit-1.2.3-r4.ebuild +++ b/www-apps/cgit/cgit-1.2.3-r4.ebuild @@ -54,6 +54,7 @@ src_prepare() { if ! use vanilla; then PATCHES+=( "${FILESDIR}/${P}-git-http-backend.patch" + "${FILESDIR}/${P}-disable-cached-clones.patch" ) fi 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 +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 +@@ -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 -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 -@@ -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 -- cgit v1.2.3-2-gb3c3