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

Re: [PATCH v2 4/7] for-each-repo: run subcommands on configured repos

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 25, 2020, 22:19 UTC
Message-ID
<xmqq8se2z7uh.fsf@gitster.c.googlers.com>
In-Reply-To
<0314258c5cbb8fd771c35e433bf6be95297c4597.1598380805.git.gitgitgadget@gmail.com>
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 8 quoted lines
> +SYNOPSIS
> +--------
> +[verse]
> +'git for-each-repo' --config=<config> [--] <arguments>
> + ...
> +--config=<config>::
> +	Use the given config variable as a multi-valued list storing
> +	absolute path names.

Would it make sense to allow this config to be read from the current repository, I wonder. It is probably designed to be written to either ~/.gitconfig or /etc/gitconfig because it is probably a need that is not per-repository to list repositories for various purposes specified by the config key, but I suspect there _might_ be a good use case for storing some custom list of repositories in the configuration file local to a repository, but it is not quite obvious what it is.

If we have a good example, we may want to spell it out---that would help future readers who wonder about this (just like I am doing now).

Also, if we do read from local config, should there be a way to say "ah, you may have read values from /etc/gitconfig and ~/.gitconfig, but please forget them---I have a full list I care when you are running in this repository", i.e. clear the list. It is purely a convention and there is no built-in mechanism for this in the config API, but often it is signalled by giving an empty string as a value.

By the way, I do not have a good concrete suggestion, but can we use something better than <config> as the placeholder? I first thought this was naming the name of a file that lists repositories, not the config variable name in our usual config namespace.

> +static int run_command_on_repo(const char *path,
> +			       void *cbdata)

Is that on repo or in repo? When I saw "-C" on the command line, I immediately thought of "in repo".

Show 10 quoted lines
> +{
> +	int i;
> +	struct child_process child = CHILD_PROCESS_INIT;
> +	struct strvec *args = (struct strvec *)cbdata;
> +
> +	child.git_cmd = 1;
> +	strvec_pushl(&child.args, "-C", path, NULL);
> +
> +	for (i = 0; i < args->nr; i++)
> +		strvec_push(&child.args, args->v[i]);
Would strvec_pushv() work, or is args->v[] not NULL terminated?
> +	return run_command(&child);
> +}
> +	values = repo_config_get_value_multi(the_repository,
> +					     config_key);

Not your fault, but it is a bit unsatisfactory that we do not have special "type" meant for paths in the config API, unlike the parse-options API where there is a "filename" type that is a bit richer than a vanilla "string" type by allowing "prefix" handling. For the purposes of this, as the values are limited to absolute/full pathnames, it does not hurt as much, though.

Thanks.
Previous: Derrick Stolee via GitGitGadgetNext: Derrick Stolee
Message 28 of 41 in “[RFC] Maintenance III: background maintenance”
  1. 0/7 [RFC] Maintenance III: background maintenanceDerrick Stolee via GitGitGadget, Aug 19, 2020
  2. 1/7 maintenance: optionally skip --auto processDerrick Stolee via GitGitGadget, Aug 19, 2020
  3. Đoàn Trần Công DanhAug 20, 2020
  4. Derrick StoleeAug 20, 2020
  5. 4/7 for-each-repo: run subcommands on configured reposDerrick Stolee via GitGitGadget, Aug 19, 2020
  6. Đoàn Trần Công DanhAug 20, 2020
  7. 3/7 maintenance: add --scheduled option and configDerrick Stolee via GitGitGadget, Aug 19, 2020
  8. Đoàn Trần Công DanhAug 20, 2020
  9. Derrick StoleeAug 24, 2020
  10. 5/7 maintenance: add [un]register subcommandsDerrick Stolee via GitGitGadget, Aug 19, 2020
  11. 6/7 maintenance: add start/stop subcommandsDerrick Stolee via GitGitGadget, Aug 19, 2020
  12. 7/7 maintenance: recommended schedule in register/startDerrick Stolee via GitGitGadget, Aug 19, 2020
  13. 0/7 [RFC] Maintenance III: background maintenanceDerrick Stolee via GitGitGadget, Aug 25, 2020
  14. 1/7 maintenance: optionally skip --auto processDerrick Stolee via GitGitGadget, Aug 25, 2020
  15. Junio C HamanoAug 25, 2020
  16. Derrick StoleeAug 26, 2020
  17. Junio C HamanoAug 26, 2020
  18. 2/7 maintenance: store the "last run" time in configDerrick Stolee via GitGitGadget, Aug 25, 2020
  19. Junio C HamanoAug 25, 2020
  20. Derrick StoleeAug 26, 2020
  21. Junio C HamanoAug 26, 2020
  22. Derrick StoleeAug 27, 2020
  23. 3/7 maintenance: add --scheduled option and configDerrick Stolee via GitGitGadget, Aug 25, 2020
  24. Junio C HamanoAug 25, 2020
  25. Derrick StoleeAug 26, 2020
  26. Derrick StoleeAug 27, 2020
  27. 4/7 for-each-repo: run subcommands on configured reposDerrick Stolee via GitGitGadget, Aug 25, 2020
  28. Junio C HamanoAug 25, 2020
  29. Derrick StoleeAug 26, 2020
  30. 6/7 maintenance: add start/stop subcommandsDerrick Stolee via GitGitGadget, Aug 25, 2020
  31. 7/7 maintenance: recommended schedule in register/startDerrick Stolee via GitGitGadget, Aug 25, 2020
  32. 5/7 maintenance: add [un]register subcommandsDerrick Stolee via GitGitGadget, Aug 25, 2020
  33. 0/6 [RFC] Maintenance III: background maintenanceDerrick Stolee via GitGitGadget, Aug 28, 2020
  34. 2/6 maintenance: add --schedule option and configDerrick Stolee via GitGitGadget, Aug 28, 2020
  35. 4/6 maintenance: add [un]register subcommandsDerrick Stolee via GitGitGadget, Aug 28, 2020
  36. 1/6 maintenance: optionally skip --auto processDerrick Stolee via GitGitGadget, Aug 28, 2020
  37. 5/6 maintenance: add start/stop subcommandsDerrick Stolee via GitGitGadget, Aug 28, 2020
  38. 6/6 maintenance: recommended schedule in register/startDerrick Stolee via GitGitGadget, Aug 28, 2020
  39. 3/6 for-each-repo: run subcommands on configured reposDerrick Stolee via GitGitGadget, Aug 28, 2020
  40. Michal SuchánekAug 26, 2020
  41. Đoàn Trần Công DanhAug 20, 2020

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.