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

Re: [PATCH] mergetool: new config guiDefault supports auto-toggling gui by DISPLAY

From
Tao Klerks <tao@klerks.biz>
Date
Oct 14, 2022, 12:32 UTC
Message-ID
<CAPMMpoiwnLyqzBBubkgSpjyJQqSeEVdoZy72FAwGDbMgg9UXxg@mail.gmail.com>
In-Reply-To
<xmqqsfjqbwil.fsf@gitster.g>
On Fri, Oct 14, 2022 at 11:11 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 18 quoted lines
>
> Tao Klerks <tao@klerks.biz> writes:
>
> > 1. Why add an OPT_CALLBACK_F arg handler, rather than keeping a simple
> > OPT_BOOL arg type?
> > Because OPT_BOOL always overwrites with either true or false, so in
> > order to have use_gui_tool retain its "_BY_CONFIG" value in the
> > absence of an arg, the explicit arg handler function is required.
>
> That is exactly why you want to initialize the variable to something
> other than 0 or 1 (say "-1") and use that as "not explicitly
> specified from the command line" aka _BY_CONFIG value, isn't it?
>
> And once you do so, you do not need callback and you do not need
> enum.  The original "int" can take tri-state, (unspecified = -1,
> false = 0, true = 1).
>
> Am I missing something?
Heh, I guess one of us must be, and it's probably me :)

My understanding, from ad-hoc testing, is that using OPT_BOOL causes the target variable ("use_gui_tool" in this case) to *always* be set to either "1" or "0", regardless of whether the user sets the main flag, the --no form of the flag, or sets nothing at all. As far as I can tell, OPT_BOOL never leaves the original value, so it cannot be used to track tri-state "true, false or not specified" logic. Maybe I made a mistake somewhere, and that's not really or always how it behaves.

I can re-test, and/or try to dig into the option parsing logic to understand how it works - the time I tried, I got hopelessly lost and was relieved to find that OPT_CALLBACK_F existed and seemed to be used for exactly these kinds of use cases.

Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 23 in “mergetool: new config guiDefault supports auto-toggling gui by DISPLAY”
  1. mergetool: new config guiDefault supports auto-toggling gui by DISPLAYTao Klerks via GitGitGadget, Oct 12, 2022
  2. Tao KlerksOct 12, 2022
  3. Junio C HamanoOct 12, 2022
  4. Tao KlerksOct 13, 2022
  5. Junio C HamanoOct 13, 2022
  6. Tao KlerksOct 14, 2022
  7. Junio C HamanoOct 14, 2022
  8. Tao KlerksOct 14, 2022
  9. Junio C HamanoOct 14, 2022
  10. Tao KlerksOct 16, 2022
  11. RFC: mergetool: new config guiDefault supports auto-toggling gui by DISPLAYTao Klerks via GitGitGadget, Oct 14, 2022
  12. Eric SunshineOct 14, 2022
  13. Tao KlerksOct 14, 2022
  14. Junio C HamanoOct 14, 2022
  15. Tao KlerksOct 16, 2022
  16. Junio C HamanoOct 17, 2022
  17. RFC: mergetool: new config guiDefault supports auto-toggling gui by DISPLAYTao Klerks via GitGitGadget, Oct 18, 2022
  18. Tao KlerksFeb 17, 2023
  19. mergetool: new config guiDefault supports auto-toggling gui by DISPLAYTao Klerks via GitGitGadget, Mar 18, 2023
  20. David AguilarApr 4, 2023
  21. Tao KlerksApr 4, 2023
  22. Junio C HamanoApr 4, 2023
  23. David AguilarApr 6, 2023

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.