git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] t7900: use pwd -P in macOS maintenance test

From
Eric Sunshine <sunshine@sunshineco.com>
Date
May 23, 2025, 21:24 UTC
Message-ID
<CAPig+cQLG+zveZg73E=TiC5uShhhRXKmK5Z_M8zN3fpGNEN1ng@mail.gmail.com>
In-Reply-To
<xmqqsekvvz1t.fsf@gitster.g>
On Fri, May 23, 2025 at 4:42 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 19 quoted lines
> Eric Sunshine <sunshine@sunshineco.com> writes:
> >> -       pfx=$(cd "$HOME" && pwd) &&
> >> +       pfx=$(cd "$HOME" && pwd -P) &&
> >
> > 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
> >     }
>
> Because pwd emulation we use on Windows ignores -P the updated
> caller, pfx with this change would not change the existing
> behaviour.
True. I overlooked that[*].

[*]: This is the second time in two days I made a stupid mistake when replying to a patch. I should probably stop trying to read/review patches while my mind is more focused on whatever task I'm actually working on despite having a few moments available while waiting for a compilation or other lengthy operation to finish.

> 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)?

Perhaps(?). The Windows experts on the list are probably better suited to answer.

Show 13 quoted lines
> > [*]: 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).

Hmm, I'm not sure how that would help this particular case which wants to know the path of $HOME:

    pfx=$(cd "$HOME" && pwd -P) &&
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 19 in “t7900: use pwd -P in macOS maintenance test”
  1. t7900: use pwd -P in macOS maintenance testMark Mentovai, May 23, 2025
  2. Eric SunshineMay 23, 2025
  3. Junio C HamanoMay 23, 2025
  4. Eric SunshineMay 23, 2025
  5. Junio C HamanoMay 23, 2025
  6. Mark MentovaiMay 24, 2025
  7. Junio C HamanoMay 27, 2025
  8. Mark MentovaiMay 23, 2025
  9. Eric SunshineMay 23, 2025
  10. t: run tests from a normalized working directoryMark Mentovai, May 28, 2025
  11. Torsten BögershausenMay 28, 2025
  12. Junio C HamanoMay 30, 2025
  13. Torsten BögershausenMay 31, 2025
  14. Junio C HamanoJun 1, 2025
  15. Mark MentovaiJun 2, 2025
  16. Junio C HamanoJun 2, 2025
  17. Torsten BögershausenJun 3, 2025
  18. Mark MentovaiJun 3, 2025
  19. Junio C HamanoJun 3, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.