git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 0/5] Support server option from configuration

From
BGblanet via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 8, 2024, 03:38 UTC
Message-ID
<pull.1776.v3.git.git.1728358699.gitgitgadget@gmail.com>
In-Reply-To
<pull.1776.v2.git.git.1727093878.gitgitgadget@gmail.com>

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.<name>.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.<name>.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.<name>.serverOption configuration
     @@ Documentation/config/remote.txt: remote.<name>.partialclonefilter::
       	database, use the `--refetch` option of linkgit:git-fetch[1].
      +
      +remote.<name>.serverOption::
     -+	When no `--server-option=<option>` argument is given from the command
     -+	line, git will use the values from this configuration as a default list of
     -+	server options for this remote.
     ++	The default set of server options used when fetching from this remote.
     ++	These server options can be overridden by the `--server-option=` command
     ++	line arguments.
      ++
      +This is a multi-valued variable, and an empty value can be used in a higher
      +priority configuration file (e.g. `.git/config` in a repository) to clear
     @@ remote.c
       
       enum map_direction { FROM_SRC, FROM_DST };
       
     -@@ remote.c: static struct remote *make_remote(struct remote_state *remote_state,
     - 	struct remote *ret;
     - 	struct remotes_hash_key lookup;
     - 	struct hashmap_entry lookup_entry, *e;
     -+	struct string_list server_options = STRING_LIST_INIT_DUP;
     - 
     - 	if (!len)
     - 		len = strlen(name);
      @@ remote.c: static struct remote *make_remote(struct remote_state *remote_state,
       	ret->name = xstrndup(name, len);
       	refspec_init(&ret->push, REFSPEC_PUSH);
       	refspec_init(&ret->fetch, REFSPEC_FETCH);
     -+	ret->server_options = server_options;
     ++	string_list_init_dup(&ret->server_options);
       
       	ALLOC_GROW(remote_state->remotes, remote_state->remotes_nr + 1,
       		   remote_state->remotes_alloc);
     @@ remote.c: static void remote_clear(struct remote *remote)
       
       static void add_merge(struct branch *branch, const char *name)
      @@ remote.c: static int handle_config(const char *key, const char *value,
     - 					 key, value);
       	} else if (!strcmp(subkey, "vcs")) {
     + 		FREE_AND_NULL(remote->foreign_vcs);
       		return git_config_string(&remote->foreign_vcs, key, value);
      +	} else if (!strcmp(subkey, "serveroption")) {
      +		return parse_transport_option(key, value,
 3:  a7f3e458501 = 3:  f0835259b06 transport.c::handshake: make use of server options from remote
 4:  39ee8dbef78 = 4:  420b15d9f37 fetch: respect --server-option when fetching multiple remotes
 5:  39c07a6c8ee ! 5:  2528d929c7e ls-remote: leakfix for not clearing server_options
     @@ Commit message
          Signed-off-by: Xing Xin <xingxin.xx@bytedance.com>
      
       ## builtin/ls-remote.c ##
     -@@ builtin/ls-remote.c: int cmd_ls_remote(int argc, const char **argv, const char *prefix)
     +@@ builtin/ls-remote.c: int cmd_ls_remote(int argc,
       	transport_ls_refs_options_release(&transport_options);
       
       	strvec_clear(&pattern);
-- 
gitgitgadget
Previous: Xing XinNext: Xing Xin via GitGitGadget
Message 31 of 39 in “Support server option from configuration”
  1. 0/4 Support server option from configurationblanet via GitGitGadget, Sep 2, 2024
  2. 1/4 transport: add parse_transport_option() methodXing Xin via GitGitGadget, Sep 2, 2024
  3. 2/4 builtin/fetch.c: add fetch.serverOption configurationXing Xin via GitGitGadget, Sep 2, 2024
  4. Patrick SteinhardtSep 3, 2024
  5. 3/4 builtin/clone.c: recognize fetch.serverOption configurationXing Xin via GitGitGadget, Sep 2, 2024
  6. Patrick SteinhardtSep 3, 2024
  7. Xing XinSep 4, 2024
  8. Patrick SteinhardtSep 5, 2024
  9. Xing XinSep 5, 2024
  10. Patrick SteinhardtSep 5, 2024
  11. Junio C HamanoSep 5, 2024
  12. Xing XinSep 9, 2024
  13. Patrick SteinhardtSep 9, 2024
  14. Xing XinSep 23, 2024
  15. Junio C HamanoSep 9, 2024
  16. 4/4 builtin/ls-remote.c: recognize fetch.serverOption configurationXing Xin via GitGitGadget, Sep 2, 2024
  17. Patrick SteinhardtSep 3, 2024
  18. Patrick SteinhardtSep 3, 2024
  19. 0/5 Support server option from configurationblanet via GitGitGadget, Sep 23, 2024
  20. 1/5 transport: introduce parse_transport_option() methodXing Xin via GitGitGadget, Sep 23, 2024
  21. 2/5 remote: introduce remote.<name>.serverOption configurationXing Xin via GitGitGadget, Sep 23, 2024
  22. Patrick SteinhardtOct 7, 2024
  23. Xing XinOct 8, 2024
  24. 3/5 transport.c::handshake: make use of server options from remoteXing Xin via GitGitGadget, Sep 23, 2024
  25. 4/5 fetch: respect --server-option when fetching multiple remotesXing Xin via GitGitGadget, Sep 23, 2024
  26. Patrick SteinhardtOct 7, 2024
  27. 5/5 ls-remote: leakfix for not clearing server_optionsXing Xin via GitGitGadget, Sep 23, 2024
  28. Patrick SteinhardtOct 7, 2024
  29. Patrick SteinhardtOct 7, 2024
  30. Xing XinOct 8, 2024
  31. 0/5 Support server option from configurationblanet via GitGitGadget, Oct 8, 2024
  32. 1/5 transport: introduce parse_transport_option() methodXing Xin via GitGitGadget, Oct 8, 2024
  33. 2/5 remote: introduce remote.<name>.serverOption configurationXing Xin via GitGitGadget, Oct 8, 2024
  34. 3/5 transport.c::handshake: make use of server options from remoteXing Xin via GitGitGadget, Oct 8, 2024
  35. 4/5 fetch: respect --server-option when fetching multiple remotesXing Xin via GitGitGadget, Oct 8, 2024
  36. Junio C HamanoOct 8, 2024
  37. 5/5 ls-remote: leakfix for not clearing server_optionsXing Xin via GitGitGadget, Oct 8, 2024
  38. Patrick SteinhardtOct 8, 2024
  39. Junio C HamanoOct 8, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.