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

Re: [PATCH 3/5] tests: explicitly skip `chmod` calls on Windows

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 23, 2022, 07:34 UTC
Message-ID
<2553p8p9-q04r-75r6-5spn-8n9npno6q8p3@tzk.qr>
In-Reply-To
<p79ppo86-022r-7sss-41q1-39n499n3266s@tzk.qr>
Hi Ævar,
On Mon, 22 Aug 2022, Johannes Schindelin wrote:
Show 6 quoted lines
> Instead of wasting the run time (even on non-Windows platforms!) to
> determine whether the `MINGW` prereq is set in order to skip the `chmod`
> call or not, we can make `chmod` a no-op explicitly in that `case
> $uname_s` block.
>
> I will make it so.
tl;dr this patch needs to be dropped, without the suggested replacement.
Gaaah!

After struggling with this for much longer than I care to admit, and even debugging inside the MSYS2 runtime (which is a level boss if there ever was one), I found out that all about this patch was wrong.

The suggested patch (making `chmod` a no-op) was wrong: the test suite started failing left and right. Why? Because `chmod` is not a _complete_ no-op. The test suite does not use the `-o` flag you suggested (which would not make sense in Git's test suite, whether or not you remove file permissions for "others" than the current user or group, Git behaves identically), but it _does_ use the `-w`/`+w` flags, and those _are_ respected, even on Windows.

The way the write permission bits are translated to ACLs is admittedly somewhat magical or all kinds of wrong, too, depending on your point of view.

But my original patch was also wrong. Why? Because it claimed that `chmod +x` does not work outside of MSYS2's pseudo Unix root directory tree. And that's simply not true.

Whether you call `chmod +x C:/Users/avar/my-file.txt` or `chmod +x /tmp/avar.sh`, it "succeeds" (by silently ignoring the flag that is inapplicable on Windows, whether or not a file is executable is determined by its file extension, and yes, that means that shell scripts are never executable and we have to live with a nasty hack in Git to pretend that they are, based on their contents starting with a hash-bang line).

So why did I claim that the `chmod +x` invocation does not work outside of that pseudo Unix root directory tree? Because it actually did not work, at least for me! But it worked on the build agents. Why? Because I have a command in my `~/.profile` that mounts several of my Git for Windows SDKs as "short-cuts" like `/sdk64`, `/sdk32` and the likes (think of these as bind-mounts). And those `mount` commands did not specify the `noacl` flag.

So what's that `noacl` flag? It is magic, I can tell you. It basically makes all this pretense work where MSYS2 pretends that we are in a Unix environment with Unix permissions when we're not actually. The details are too gnarly and involved to explain, I won't write them up here in order to avoid putting even more readers to sleep than I must have done already.

So my analysis was based on observation instead of inspection, cutting corners, and I dearly regret that now. By default, MSYS2 "mounts" the system drives as `/c`, `/d`, etc with that `noacl` flag, the same as it mounts the pseudo Unix root as `/`. And that is why the Git test suite does not throw up every time `chmod +x` is called. And it was a simple pilot error on my part that caused it to fail on my system, and I did not realize that the problem was confined to my system, and the bug was in my `~/.profile` and not in Git's code base.

Working on Git for Windows is never boring.

Ciao, Johannes

Previous: Johannes SchindelinNext: Johannes Schindelin via GitGitGadget
Message 12 of 58 in “Some fixes and an improvement for using CTest on Windows”
  1. 0/5 Some fixes and an improvement for using CTest on WindowsJohannes Schindelin via GitGitGadget, Aug 10, 2022
  2. 1/5 cmake: align CTest definition with Git's CI runsJohannes Schindelin via GitGitGadget, Aug 10, 2022
  3. Junio C HamanoAug 10, 2022
  4. Johannes SchindelinAug 16, 2022
  5. Junio C HamanoAug 16, 2022
  6. Johannes SchindelinAug 19, 2022
  7. Ævar Arnfjörð BjarmasonAug 11, 2022
  8. 2/5 cmake: copy the merge tools for testingJohannes Schindelin via GitGitGadget, Aug 10, 2022
  9. 3/5 tests: explicitly skip `chmod` calls on WindowsJohannes Schindelin via GitGitGadget, Aug 10, 2022
  10. Ævar Arnfjörð BjarmasonAug 11, 2022
  11. Johannes SchindelinAug 22, 2022
  12. Johannes SchindelinAug 23, 2022
  13. 4/5 add -p: avoid ambiguous signed/unsigned comparisonJohannes Schindelin via GitGitGadget, Aug 10, 2022
  14. Junio C HamanoAug 10, 2022
  15. Johannes SchindelinAug 16, 2022
  16. Junio C HamanoAug 16, 2022
  17. Johannes SchindelinAug 19, 2022
  18. Phillip WoodAug 11, 2022
  19. Johannes SchindelinAug 16, 2022
  20. Phillip WoodAug 16, 2022
  21. Johannes SchindelinAug 19, 2022
  22. 5/5 cmake: avoid editing t/test-lib.shJohannes Schindelin via GitGitGadget, Aug 10, 2022
  23. Ævar Arnfjörð BjarmasonAug 11, 2022
  24. Johannes SchindelinOct 18, 2022
  25. Phillip WoodAug 11, 2022
  26. Johannes SchindelinAug 16, 2022
  27. Phillip WoodAug 16, 2022
  28. 0/5 Some fixes and an improvement for using CTest on WindowsJohannes Schindelin via GitGitGadget, Aug 23, 2022
  29. 4/5 cmake: avoid editing t/test-lib.shJohannes Schindelin via GitGitGadget, Aug 23, 2022
  30. Ævar Arnfjörð BjarmasonSep 8, 2022
  31. Johannes SchindelinOct 18, 2022
  32. Ævar Arnfjörð BjarmasonOct 18, 2022
  33. Victoria DyeSep 8, 2022
  34. Victoria DyeSep 8, 2022
  35. Junio C HamanoSep 8, 2022
  36. Johannes SchindelinOct 18, 2022
  37. 5/5 cmake: increase time-out for a long-running testJohannes Schindelin via GitGitGadget, Aug 23, 2022
  38. Ævar Arnfjörð BjarmasonSep 8, 2022
  39. Victoria DyeSep 8, 2022
  40. 2/5 cmake: copy the merge tools for testingJohannes Schindelin via GitGitGadget, Aug 23, 2022
  41. 1/5 cmake: make it easier to diagnose regressions in CTest runsJohannes Schindelin via GitGitGadget, Aug 23, 2022
  42. Victoria DyeSep 7, 2022
  43. Johannes SchindelinOct 18, 2022
  44. Ævar Arnfjörð BjarmasonSep 8, 2022
  45. Eric SunshineSep 28, 2022
  46. 3/5 add -p: avoid ambiguous signed/unsigned comparisonJohannes Schindelin via GitGitGadget, Aug 23, 2022
  47. Victoria DyeSep 8, 2022
  48. 0/5 Some fixes and an improvement for using CTest on WindowsJohannes Schindelin via GitGitGadget, Oct 18, 2022
  49. 1/5 cmake: make it easier to diagnose regressions in CTest runsJohannes Schindelin via GitGitGadget, Oct 18, 2022
  50. Ævar Arnfjörð BjarmasonOct 18, 2022
  51. 2/5 cmake: copy the merge tools for testingJohannes Schindelin via GitGitGadget, Oct 18, 2022
  52. Ævar Arnfjörð BjarmasonOct 18, 2022
  53. 3/5 add -p: avoid ambiguous signed/unsigned comparisonJohannes Schindelin via GitGitGadget, Oct 18, 2022
  54. Ævar Arnfjörð BjarmasonOct 18, 2022
  55. 4/5 cmake: avoid editing t/test-lib.shJohannes Schindelin via GitGitGadget, Oct 18, 2022
  56. Ævar Arnfjörð BjarmasonOct 18, 2022
  57. Johannes SchindelinOct 18, 2022
  58. 5/5 cmake: increase time-out for a long-running testJohannes Schindelin via GitGitGadget, Oct 18, 2022

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.