git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Mark Mentovai <mark@chromium.org>,
	 Git Development <git@vger.kernel.org>,
	 Derrick Stolee <stolee@gmail.com>
Subject: Re: [PATCH] t7900: use pwd -P in macOS maintenance test
Date: Fri, 23 May 2025 13:42:54 -0700	[thread overview]
Message-ID: <xmqqsekvvz1t.fsf@gitster.g> (raw)
In-Reply-To: <CAPig+cRpS=t-wNLxdV_WoKF0Wzy-S1oLUEyS18S9r-4OBQ87VQ@mail.gmail.com> (Eric Sunshine's message of "Fri, 23 May 2025 16:08:02 -0400")

Eric Sunshine <sunshine@sunshineco.com> writes:

>> -       pfx=$(cd "$HOME" && pwd) &&
>> +       pfx=$(cd "$HOME" && pwd -P) &&
>
> Okay, this seems like the minimum fix[*], and -P is POSIX.
>
> However, have you tested this on Windows? I ask because, despite the
> test's name, this and most of the tests in this script, are actually
> run on all platforms, and because `pwd` is overridden by a shell
> function for MinGW on Windows:
>
>     # t/test-lib.sh
>     ...
>     # git sees Windows-style pwd
>     pwd () {
>         builtin pwd -W
>     }
>
> My quick testing suggests that this patch's change might be problematic:
>
>     # on Windows
>     $ pwd
>     /home/me
>     $ pwd -W
>     C:/msys64/home/me
>     $ pwd -P
>     /home/me
>     $ pwd -W -P
>     /home/me

Because pwd emulation we use on Windows ignores -P the updated
caller, pfx with this change would not change the existing
behaviour.

How would one test this situation on Windows, I wonder?  Create a
directory that is pointed at by a symbolic link, and use it as the
test directory (either have the checkout there, or use --root to
have the trash directory there)?

> FOOTNOTES
>
> [*]: In the long run, a better fix would probably be for the tests to
> sanitize the output of the Git command, replacing (via `sed`) the
> actual emitted path with some placeholder, such as "%HOME%" or
> something, and then have the tests look for (`grep` or whatnot)
> needles using that literal placeholder rather than trying to perfectly
> match the path emitted by Git. This approach makes sense since these
> tests are about overall functionality of git-maintenance, not about
> the specific path in which the person happens to be running the tests.

Another approach may be to do a form of chdir that forces the shell
to figure out where it really is upfront at the beginning of a test
script, perhaps inside test-lib.sh which happend before anything
meaningful happens in the test (i.e. "cd -P ." or something).

  reply	other threads:[~2025-05-23 20:42 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-23 19:37 [PATCH] t7900: use pwd -P in macOS maintenance test Mark Mentovai
2025-05-23 20:08 ` Eric Sunshine
2025-05-23 20:42   ` Junio C Hamano [this message]
2025-05-23 21:24     ` Eric Sunshine
2025-05-23 21:51       ` Junio C Hamano
2025-05-24  4:39         ` Mark Mentovai
2025-05-27 17:19           ` Junio C Hamano
2025-05-23 20:43   ` Mark Mentovai
2025-05-23 21:36     ` Eric Sunshine
2025-05-28 20:17 ` [PATCH v2] t: run tests from a normalized working directory Mark Mentovai
2025-05-28 23:08   ` Torsten Bögershausen
2025-05-30  5:04     ` Junio C Hamano
2025-05-31  5:46       ` Torsten Bögershausen
2025-06-01 16:38         ` Junio C Hamano
2025-06-02 16:08           ` Mark Mentovai
2025-06-02 21:32             ` Junio C Hamano
2025-06-03  5:02               ` Torsten Bögershausen
2025-06-03 13:15                 ` Mark Mentovai
2025-06-03 18:22                   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqsekvvz1t.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=mark@chromium.org \
    --cc=stolee@gmail.com \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).