for-each-repo: interpolate repo path arguments

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> Signed-off-by: Taylor Blau <me@ttaylorr.com>

Ronan Pigott committed Nov 9, 2022 at 12:07 UTC 13d5bbdf72aab109c9b69994c90aaff2a0b7e42f
2 files changed +10 -1
builtin/for-each-repo.c
+4 -1
@@ -14,13 +14,16 @@ static int run_command_on_repo(const char *path, int argc, const char ** argv)
14 {
15 int i;
16 struct child_process child = CHILD_PROCESS_INIT;
17 + char *abspath = interpolate_path(path, 0);
18
19 child.git_cmd = 1;
19 - strvec_pushl(&child.args, "-C", path, NULL);
20 + strvec_pushl(&child.args, "-C", abspath, NULL);
21
22 for (i = 0; i < argc; i++)
23 strvec_push(&child.args, argv[i]);
24
25 + free(abspath);
26 +
27 return run_command(&child);
28 }
29
t/t0068-for-each-repo.sh
+6
@@ -8,9 +8,11 @@ test_expect_success 'run based on configured value' '
8 git init one &&
9 git init two &&
10 git init three &&
11 + git init ~/four &&
12 git -C two commit --allow-empty -m "DID NOT RUN" &&
13 git config run.key "$TRASH_DIRECTORY/one" &&
14 git config --add run.key "$TRASH_DIRECTORY/three" &&
15 + git config --add run.key "~/four" &&
16 git for-each-repo --config=run.key commit --allow-empty -m "ran" &&
17 git -C one log -1 --pretty=format:%s >message &&
18 grep ran message &&
@@ -18,12 +20,16 @@ test_expect_success 'run based on configured value' '
20 ! grep ran message &&
21 git -C three log -1 --pretty=format:%s >message &&
22 grep ran message &&
23 + git -C ~/four log -1 --pretty=format:%s >message &&
24 + grep ran message &&
25 git for-each-repo --config=run.key -- commit --allow-empty -m "ran again" &&
26 git -C one log -1 --pretty=format:%s >message &&
27 grep again message &&
28 git -C two log -1 --pretty=format:%s >message &&
29 ! grep again message &&
30 git -C three log -1 --pretty=format:%s >message &&
31 + grep again message &&
32 + git -C ~/four log -1 --pretty=format:%s >message &&
33 grep again message
34 '
35