Re: [PATCH v2 2/9] setup: introduce startup_info->original_cwd
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Nov 29, 2021, 14:05 UTC
- Message-ID
- <48fced3c-1fcb-d5cd-cec0-b9e58be40259@gmail.com>
- In-Reply-To
- <f6129a8ac9c3d052fb7fb508a62d4eedb8d9ed57.1637829556.git.gitgitgadget@gmail.com>
On 11/25/2021 3:39 AM, Elijah Newren via GitGitGadget wrote:
> From: Elijah Newren <newren@gmail.com>
Show 6 quoted lines
> @@ -866,6 +866,8 @@ int cmd_main(int argc, const char **argv) > > trace_command_performance(argv); > > + startup_info->original_cwd = xgetcwd(); > +
I see this initial assignment in cmd_main()...
Show 12 quoted lines
> +static void setup_original_cwd(void)
> +{
> + struct strbuf tmp = STRBUF_INIT;
> + const char *worktree = NULL;
> + int offset = -1;
> +
> + /*
> + * startup_info->original_cwd wass set early on in cmd_main(), unless
> + * we're an auxiliary tool like git-remote-http or test-tool.
> + */
> + if (!startup_info->original_cwd)
> + return;...which is assumed to be run before this method was called...
Show 5 quoted lines
> @@ -1330,6 +1378,7 @@ const char *setup_git_directory_gently(int *nongit_ok) > setenv(GIT_PREFIX_ENVIRONMENT, "", 1); > } > > + setup_original_cwd();
...here in setup_git_directory_gently().
Why do we need that assignment in cmd_main()? Could we instead let setup_original_cwd() do the initial assignment? Or is it possible that a chdir has happened already before this point?
Thanks, -Stolee