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

Re: [PATCH v2] config: introduce an Operating System-specific `includeIf` condition

From
SFSamuel Ferencik <sferencik@gmail.com>
Date
Apr 17, 2023, 07:04 UTC
Message-ID
<CABwTEiRz+-+Zdx3Ed7O09Ch8GoXH-SnmJyc-vFOdF-hk_uO-yA@mail.gmail.com>
In-Reply-To
<xmqqk03jcwxz.fsf@gitster.g>
>>> Let's introduce a new condition: `os:<uname-s>` where `<uname-s>` is the
>>> system name, i.e. the output of `uname -s`.

The discussion about https://github.com/gitgitgadget/git/pull/1429 seems to have stalled on several points. I'll try to summarise; let's see if we can move forward.

(I am the reporter of https://github.com/git-for-windows/git/issues/4125, which led to this PR. I am vested in making progress here.)

1. name of the setting (`os` vs `uname-s` vs `sysname`)
   * dscho@ suggested `os`; Phillip and Philip suggested `uname-s` and
     `sysname`, respectively
   * I vote for `os`; I'm afraid perfect is the enemy of good here as
     * `man uname` says `-s` gives "the name of the operating system
       implementation"; no other `uname` switch comes closer to whatever
       concept "OS" represents
     * this is also correct on Windows (the "Windows" string) - see below
     * I find it extremely unlikely a future unforeseen git feature would have
       a better use for `includeIf os` (in parallel with `includeIf sysname`),
       i.e. I don't worry that we're squatting on a good name for a poor
       use-case
2. casing (use of `/i`)
   * dscho@ implemented case-insensitive comparison but without test coverage,
     documentation, and it's inconsistent with the other `includeIf` options
     that support the `/i` switch.
   * I propose that we compare case-sensitively because
     * no user can reasonably complain about this if the documentation is
       clear; the OS names are definitive and stable and it's not a big deal
       getting the case right for "Linux"
     * without the case insensitivity being documented, the users who [discover
       the insensitivity and] rely on it are risking breakage; plus the git
       maintainers are exposing themselves to the effects of Hyrum's law
       (https://xkcd.com/1172) - it's a disservice for both sides
     * this still allows us to add support for `/i` later (should a use-case
       emerge)
     * it is consistent with the other settings
     * it requires less code (incl. tests) and shorter documentation
3. handling Windows (MinGW, WSL)
   * As implemented currently, `includeIf "os:Windows"` would work in
     git-for-Windows. I think that's desirable, and no-one suggested otherwise.
   * In contrast, Philip points out `includeIf "os:Linux"` would be the way to
     match on WSL. Is that an issue? Do we want WSL to match "os:Windows" or
     "os:WSL"? As a Windows user, when I switch to WSL I do expect a "proper"
     Linux experience (unlike when I run "Git bash" on Windows, which is more
     like a port of utilities, but still Windows). I think this treating WLS as
     Linux is OK-ish, and we may get away with not discerning WSL. Thoughts?
4. documentation (w.r.t. the details in 1. - 3.)
   * We should document all of 1. - 3. I'm happy to give it a go if we can
     reach consensus.
   * Specifically, the documentation should mention that the OS string equals
     "Windows" in Git-for-Windows, and `$(uname -s)` otherwise; it should list
     examples, incl. "Linux" and "Darwin"; it should mention the case
     sensitivity.
5. tests (potential segfaults)
   * Johannes points out the tests hide segfaults. I haven't looked at this
     closely but hopefully Johannes's suggestion ("use test_cmp or
     test_cmp_config") is a clear enough pointer. I can try to fix this.
6. what's the use-case?
   * As the reporter of https://github.com/git-for-windows/git/issues/4125,
     here are my use-cases, i.e. settings that I currently set conditionally
     per OS (using `includeIf gitdir`):
     * different `difftool.path`, `mergetool.path` per OS (e.g. paths
       containing `C:\Program Files\...\...exe` vs Unix file paths)
     * different `merge.tool` per OS (I have a BeyondCompare license for Linux
       only)
     * different `core.autocrlf`: `true` on Windows, `input` otherwise
     * `core.whitespace` set to `cr-at-eol` on Windows
     * `core.editor` set to `gvim` on Windows
   * Note all of the use-cases above would cope with WSL reporting "Linux",
     except of `merge.tool`.

I hope this revives the discussion; I know it's been a while but I would appreciate your input. If possible, please refer to the numbered points (1 - 6) for clarity.

I'm happy to iterate on dscho@'s PR if we can reach consensus.
On Fri, 14 Apr 2023 at 01:44, Junio C Hamano <gitster@pobox.com> wrote:
Show 21 quoted lines
>
> Philip Oakley <philipoakley@iee.email> writes:
>
> >> Let's introduce a new condition: `os:<uname-s>` where `<uname-s>` is the
> >> system name, i.e. the output of `uname -s`.
> >
> > This `uname -s` doesn't work well on Git-for-Windows (GfW) / Windows
> > because GfW has its own internal compatibility code to spoof the result.
> > ...
> > Or just drop the mentions of "<uname-s>" in this commit message and
> > rename it 'sysname' to match the field of the struct utsname?
>
> FWIW I do not mind "sysname".  It is much better to say
>
>         [includeIf "sysname:Linux"] path = ...
>
> than "os:Linux", as "sysname" informs us the granularity used to
> identify the system better than "os".
>
>
>
Previous: Junio C HamanoNext: Junio C Hamano
Message 17 of 26 in “config: introduce an Operating System-specific `includeIf` condition”
  1. config: introduce an Operating System-specific `includeIf` conditionJohannes Schindelin via GitGitGadget, Nov 21, 2022
  2. Ævar Arnfjörð BjarmasonNov 21, 2022
  3. Phillip WoodNov 21, 2022
  4. Johannes SchindelinNov 21, 2022
  5. config: introduce an Operating System-specific `includeIf` conditionJohannes Schindelin via GitGitGadget, Nov 21, 2022
  6. Jeff KingNov 21, 2022
  7. Đoàn Trần Công DanhNov 23, 2022
  8. Jeff KingNov 24, 2022
  9. Ævar Arnfjörð BjarmasonNov 22, 2022
  10. Phillip WoodNov 22, 2022
  11. Junio C HamanoNov 23, 2022
  12. Phillip WoodNov 23, 2022
  13. Junio C HamanoNov 23, 2022
  14. Philippe BlainNov 22, 2022
  15. Philip OakleyNov 23, 2022
  16. Junio C HamanoNov 25, 2022
  17. Samuel FerencikApr 17, 2023
  18. Junio C HamanoApr 17, 2023
  19. Felipe ContrerasApr 18, 2023
  20. Johannes SchindelinApr 19, 2023
  21. Chris TorekApr 19, 2023
  22. Samuel FerencikApr 19, 2023
  23. rsbecker@nexbridge.comApr 19, 2023
  24. Junio C HamanoApr 19, 2023
  25. Junio C HamanoApr 19, 2023
  26. Junio C HamanoNov 22, 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.