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

[PATCH v2 1/2] for-each-repo: interpolate repo path arguments

From
Ronan Pigott <ronan@rjp.ie>
Date
Nov 8, 2022, 19:49 UTC
Message-ID
<20221108194930.25805-2-ronan@rjp.ie>
In-Reply-To
<20221108194930.25805-1-ronan@rjp.ie>

This is a quality of life change for git-maintenance, so repos can be recorded with the tilde syntax. The register subcommand will not record repos in this format by default.

Signed-off-by: Ronan Pigott <ronan@rjp.ie>
---
 builtin/for-each-repo.c  | 5 ++++-
 t/t0068-for-each-repo.sh | 6 ++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/builtin/for-each-repo.c b/builtin/for-each-repo.c
index d45d873f57..6aeac37148 100644
--- a/builtin/for-each-repo.c
+++ b/builtin/for-each-repo.c
@@ -14,13 +14,16 @@ static int run_command_on_repo(const char *path, int argc, const char ** argv)
 {
 	int i;
 	struct child_process child = CHILD_PROCESS_INIT;
+	char *abspath = interpolate_path(path, 0);
 
 	child.git_cmd = 1;
-	strvec_pushl(&child.args, "-C", path, NULL);
+	strvec_pushl(&child.args, "-C", abspath, NULL);
 
 	for (i = 0; i < argc; i++)
 		strvec_push(&child.args, argv[i]);
 
+	free(abspath);
+
 	return run_command(&child);
 }
 
diff --git a/t/t0068-for-each-repo.sh b/t/t0068-for-each-repo.sh
index 4675e85251..c6e0d65563 100755
--- a/t/t0068-for-each-repo.sh
+++ b/t/t0068-for-each-repo.sh
@@ -8,9 +8,11 @@ test_expect_success 'run based on configured value' '
 	git init one &&
 	git init two &&
 	git init three &&
+	git init ~/four &&
 	git -C two commit --allow-empty -m "DID NOT RUN" &&
 	git config run.key "$TRASH_DIRECTORY/one" &&
 	git config --add run.key "$TRASH_DIRECTORY/three" &&
+	git config --add run.key "~/four" &&
 	git for-each-repo --config=run.key commit --allow-empty -m "ran" &&
 	git -C one log -1 --pretty=format:%s >message &&
 	grep ran message &&
@@ -18,12 +20,16 @@ test_expect_success 'run based on configured value' '
 	! grep ran message &&
 	git -C three log -1 --pretty=format:%s >message &&
 	grep ran message &&
+	git -C ~/four log -1 --pretty=format:%s >message &&
+	grep ran message &&
 	git for-each-repo --config=run.key -- commit --allow-empty -m "ran again" &&
 	git -C one log -1 --pretty=format:%s >message &&
 	grep again message &&
 	git -C two log -1 --pretty=format:%s >message &&
 	! grep again message &&
 	git -C three log -1 --pretty=format:%s >message &&
+	grep again message &&
+	git -C ~/four log -1 --pretty=format:%s >message &&
 	grep again message
 '
 
-- 
2.38.1
Previous: Ronan PigottNext: Ronan Pigott
Message 2 of 10 in “git-maintenance quality-of-life improvements”
  1. 0/2 git-maintenance quality-of-life improvementsRonan Pigott, Nov 8, 2022
  2. 1/2 for-each-repo: interpolate repo path argumentsRonan Pigott, Nov 8, 2022
  3. 2/2 maintenance: add option to register in a specific configRonan Pigott, Nov 8, 2022
  4. Phillip WoodNov 8, 2022
  5. Taylor BlauNov 8, 2022
  6. Phillip WoodNov 8, 2022
  7. ronan@rjp.ieNov 8, 2022
  8. Derrick StoleeNov 9, 2022
  9. Taylor BlauNov 10, 2022
  10. Taylor BlauNov 8, 2022

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.