Re: [PATCH v2 2/9] setup: introduce startup_info->original_cwd
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 29, 2021, 17:42 UTC
- Message-ID
- <xmqqwnkq3llj.fsf@gitster.g>
- In-Reply-To
- <48fced3c-1fcb-d5cd-cec0-b9e58be40259@gmail.com>
Derrick Stolee <stolee@gmail.com> writes:
Show 11 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?
Since setup_git_directory() is used to figure out the prefix, which is relative path to the directory, in which the command was started, viewed from the top-level of the working tree, it would be a bug if the caller did any chdir(2) before it called the function.
I didn't look at or thought about how chdir(2) done inside this function affects what setup_original_cwd() wants to do, though.
Thanks.