Subject: Re: [PATCH v3 3/4] for-each-repo: work correctly in a worktree

From: Jeff King <[email-masked]>
Date: Mon, 2 Mar 2026 13:06:01 -0500

On Mon, Mar 02, 2026 at 03:36:44PM +0000, Derrick Stolee via GitGitGadget wrote:

> @@ -15,10 +16,11 @@ static const char * const for_each_repo_usage[] = {
>  
>  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);
>  
> +	clear_local_repo_env(&child.env);
> +
>  	child.git_cmd = 1;
>  	strvec_pushl(&child.args, "-C", abspath, NULL);

The second part of the hunk here is as expected, but the first one looks
wrong. We didn't remove any references to "i", so either it was
redundant to start with (and the compiler should have complained), or
now we've broken compilation.

Looks like the latter, but we recover when we switch to using pushv in
patch 4. So I think the declaration of "i" should move to that patch.

-Peff