]> git.ipfire.org Git - thirdparty/git.git/commitdiff
for-each-repo: interpolate repo path arguments
authorRonan Pigott <ronan@rjp.ie>
Wed, 9 Nov 2022 19:07:07 +0000 (12:07 -0700)
committerTaylor Blau <me@ttaylorr.com>
Tue, 15 Nov 2022 03:39:25 +0000 (22:39 -0500)
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>
builtin/for-each-repo.c
t/t0068-for-each-repo.sh

index d45d873f5797c9d1aa836f5d53e7c5b7b80e9ef4..6aeac37148830d316f533e5399c79ed551fda2fe 100644 (file)
@@ -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);
 }
 
index 4675e852517688179c2783803ebfa56e730cd24c..c6e0d655630638853b6831350618bc10b15de6e2 100755 (executable)
@@ -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
 '