Skip to content

Commit 13d5bbd

Browse files
rpigottttaylorr
authored andcommitted
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 <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 3b08839 commit 13d5bbd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

builtin/for-each-repo.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ static int run_command_on_repo(const char *path, int argc, const char ** argv)
1414
{
1515
int i;
1616
struct child_process child = CHILD_PROCESS_INIT;
17+
char *abspath = interpolate_path(path, 0);
1718

1819
child.git_cmd = 1;
19-
strvec_pushl(&child.args, "-C", path, NULL);
20+
strvec_pushl(&child.args, "-C", abspath, NULL);
2021

2122
for (i = 0; i < argc; i++)
2223
strvec_push(&child.args, argv[i]);
2324

25+
free(abspath);
26+
2427
return run_command(&child);
2528
}
2629

t/t0068-for-each-repo.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,28 @@ test_expect_success 'run based on configured value' '
88
git init one &&
99
git init two &&
1010
git init three &&
11+
git init ~/four &&
1112
git -C two commit --allow-empty -m "DID NOT RUN" &&
1213
git config run.key "$TRASH_DIRECTORY/one" &&
1314
git config --add run.key "$TRASH_DIRECTORY/three" &&
15+
git config --add run.key "~/four" &&
1416
git for-each-repo --config=run.key commit --allow-empty -m "ran" &&
1517
git -C one log -1 --pretty=format:%s >message &&
1618
grep ran message &&
1719
git -C two log -1 --pretty=format:%s >message &&
1820
! grep ran message &&
1921
git -C three log -1 --pretty=format:%s >message &&
2022
grep ran message &&
23+
git -C ~/four log -1 --pretty=format:%s >message &&
24+
grep ran message &&
2125
git for-each-repo --config=run.key -- commit --allow-empty -m "ran again" &&
2226
git -C one log -1 --pretty=format:%s >message &&
2327
grep again message &&
2428
git -C two log -1 --pretty=format:%s >message &&
2529
! grep again message &&
2630
git -C three log -1 --pretty=format:%s >message &&
31+
grep again message &&
32+
git -C ~/four log -1 --pretty=format:%s >message &&
2733
grep again message
2834
'
2935

0 commit comments

Comments
 (0)