From: blanet via GitGitGadget Date: Tue, 08 Oct 2024 03:38:14 GMT Subject: [PATCH v3 0/5] Support server option from configuration Message-ID: In-Reply-To: We manage some internal repositories with numerous CI tasks, each requiring code preparation through git-clone or git-fetch. These tasks, triggered by post-receive hooks, often fetch the same copy of code concurrently using --depth=1, causing extremely high load spikes on our Git servers. To reduce performance impacts caused by these tasks, we plan to deploy a specially designed pack-objects-hook [1]. This hook would allow the packs generated by git-pack-objects(during git-clone or git-fetch) to be reused. Since not all clone/fetch operations will benefit from this caching (e.g., pulls from developer environments), clients need to pass a special identifier to indicate whether caching should be enabled. Using server options [2] is suitable for this purpose. However, server options can only be specified via the command line option (via --server-option or -o), which is inconvenient and requires modifications to CI scripts. A configuration-based approach is preferable, as it can be propagated through global configuration (e.g. ~/.gitconfig) and avoids compatibility issues with older Git versions that don't support --server-option. This patch series introduces a new multi-valued configuration, remote..serverOption, similar to push.pushOption, to specify default server options for the corresponding remote. * Patches 1~3 contain the main changes for introducing the new configuration. * Patch 4 fixes a issue for git-fetch not sending server-options when fetching from multiple remotes. * Patch 5 is a minor fix for a server options-related memory leak. 1. https://git-scm.com/docs/git-config#Documentation/git-config.txt-uploadpackpackObjectsHook 2. https://git-scm.com/docs/gitprotocol-v2#_server_option Xing Xin (5): transport: introduce parse_transport_option() method remote: introduce remote..serverOption configuration transport.c::handshake: make use of server options from remote fetch: respect --server-option when fetching multiple remotes ls-remote: leakfix for not clearing server_options Documentation/config/remote.txt | 10 +++ Documentation/fetch-options.txt | 3 + Documentation/git-clone.txt | 3 + Documentation/git-ls-remote.txt | 3 + builtin/fetch.c | 2 + builtin/ls-remote.c | 1 + builtin/push.c | 9 +-- remote.c | 6 ++ remote.h | 3 + t/t5702-protocol-v2.sh | 133 ++++++++++++++++++++++++++++++++ transport.c | 15 ++++ transport.h | 4 + 12 files changed, 184 insertions(+), 8 deletions(-) base-commit: 6258f68c3c1092c901337895c864073dcdea9213 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1776%2Fblanet%2Fxx%2Fadd-server-option-from-config-v3 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1776/blanet/xx/add-server-option-from-config-v3 Pull-Request: https://github.com/git/git/pull/1776 Range-diff vs v2: 1: c95ed5e0dd5 = 1: b44face42e1 transport: introduce parse_transport_option() method 2: 2474b4c69d6 ! 2: 3c6b129d368 remote: introduce remote..serverOption configuration @@ Documentation/config/remote.txt: remote..partialclonefilter:: database, use the `--refetch` option of linkgit:git-fetch[1]. + +remote..serverOption:: -+ When no `--server-option=