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>
maint
Ronan Pigott 2022-11-09 12:07:07 -07:00 committed by Taylor Blau
parent 3b08839926
commit 13d5bbdf72
2 changed files with 10 additions and 1 deletions

View File

@ -14,13 +14,16 @@ static int run_command_on_repo(const char *path, int argc, const char ** argv)
{ {
int i; int i;
struct child_process child = CHILD_PROCESS_INIT; struct child_process child = CHILD_PROCESS_INIT;
char *abspath = interpolate_path(path, 0);


child.git_cmd = 1; child.git_cmd = 1;
strvec_pushl(&child.args, "-C", path, NULL); strvec_pushl(&child.args, "-C", abspath, NULL);


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


free(abspath);

return run_command(&child); return run_command(&child);
} }



View File

@ -8,9 +8,11 @@ test_expect_success 'run based on configured value' '
git init one && git init one &&
git init two && git init two &&
git init three && git init three &&
git init ~/four &&
git -C two commit --allow-empty -m "DID NOT RUN" && git -C two commit --allow-empty -m "DID NOT RUN" &&
git config run.key "$TRASH_DIRECTORY/one" && git config run.key "$TRASH_DIRECTORY/one" &&
git config --add run.key "$TRASH_DIRECTORY/three" && 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 for-each-repo --config=run.key commit --allow-empty -m "ran" &&
git -C one log -1 --pretty=format:%s >message && git -C one log -1 --pretty=format:%s >message &&
grep ran message && grep ran message &&
@ -18,12 +20,16 @@ test_expect_success 'run based on configured value' '
! grep ran message && ! grep ran message &&
git -C three log -1 --pretty=format:%s >message && git -C three log -1 --pretty=format:%s >message &&
grep ran 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 for-each-repo --config=run.key -- commit --allow-empty -m "ran again" &&
git -C one log -1 --pretty=format:%s >message && git -C one log -1 --pretty=format:%s >message &&
grep again message && grep again message &&
git -C two log -1 --pretty=format:%s >message && git -C two log -1 --pretty=format:%s >message &&
! grep again message && ! grep again message &&
git -C three log -1 --pretty=format:%s >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 grep again message
' '