From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 178571F953 for ; Mon, 29 Nov 2021 17:44:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349048AbhK2RrV (ORCPT ); Mon, 29 Nov 2021 12:47:21 -0500 Received: from pb-smtp1.pobox.com ([64.147.108.70]:52095 "EHLO pb-smtp1.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236455AbhK2RpV (ORCPT ); Mon, 29 Nov 2021 12:45:21 -0500 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id A6FDBE4FE7; Mon, 29 Nov 2021 12:42:02 -0500 (EST) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=NOfj4cFAgGSOzYfvOEUJu71pQgnst1IJAUrKle rTmmQ=; b=PR6+0PuQSZVDwc/OoKpWb0H/gG1Nvj+jN7FWEs+ASIVsRZt4bq0cpj bZGwNLvpF5jFGX1vcn668nVoYEK4JochvOxtkMDSiVMSigZYxRY2CO4s7hDU9XGH 8ERIQObzmGV5yN7mYJjpGrqn+k6/XQh5HN3ThRycanXujiU3jtoaE= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 90CC5E4FE6; Mon, 29 Nov 2021 12:42:02 -0500 (EST) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [104.133.2.91]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 9F75CE4FE5; Mon, 29 Nov 2021 12:42:01 -0500 (EST) (envelope-from junio@pobox.com) From: Junio C Hamano To: Derrick Stolee Cc: Elijah Newren via GitGitGadget , git@vger.kernel.org, Jeff King , =?utf-8?Q?Ren=C3=A9?= Scharfe , =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Glen Choo , Philip Oakley Subject: Re: [PATCH v2 2/9] setup: introduce startup_info->original_cwd References: <48fced3c-1fcb-d5cd-cec0-b9e58be40259@gmail.com> Date: Mon, 29 Nov 2021 09:42:00 -0800 In-Reply-To: <48fced3c-1fcb-d5cd-cec0-b9e58be40259@gmail.com> (Derrick Stolee's message of "Mon, 29 Nov 2021 09:05:55 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: A8B22D70-513B-11EC-A473-62A2C8D8090B-77302942!pb-smtp1.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Derrick Stolee writes: >> @@ -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.