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

Re: [PATCH 2/3] builtins: utilize startup_info->help where possible

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Oct 20, 2010, 01:13 UTC
Message-ID
<AANLkTinvSKAyXkzjUgxvrDWvuHWpa+46XVxTu=tWck53@mail.gmail.com>
In-Reply-To
<20101019172953.GC25139@burratino>
2010/10/20 Jonathan Nieder <jrnieder@gmail.com>:
Show 9 quoted lines
> Nguyễn Thái Ngọc Duy wrote:
>
>> It helps reduce false alarms while I'm looking for "git foo -h" code
>> path that accesses repository.
>
> Not sure I understand.  Is the idea that use of startup_info->help
> is a marker for "I've checked this code path"?
>
> If that were the only reason, I don't think I'd like the idea.

That. And simpler check. I mean "if (startup_info->help)" takes a tiny bit less energy for me to understand than "if (argc == 2 && argv[1] == "-h")". It's also good for grepping.

> As it is, I'm a bit conflicted: what if we decide to short-circuit
> "git foo --help-all" in the future just like we short-circuit
> "git foo -h" now?  Would that require a separate flag?

As long as it's help related, startup_info->help can be turned to a bit set. Although I'm not sure if --help-all or any other option will be implemented anytime soon. Remember it has to be implemented for _all_ builtin commands, or we need to introduce NO_DASH_H in run_builtin() to skip the shortcut for commands that do not support it.

Show 13 quoted lines
> In other words, I'm not sure startup_info->help is a good abstraction.
> Maybe (modulo names) it would be better to do
>
> struct startup_info {
>        ...
>        const char *short_circuit;      /* "-h", "--help-all", "--no-index", or NULL */
> };
>
> and use
>
>        if (!strcmp(startup_info->short_circuit, "-h"))
>
> to allow relaxing the argc == 2 check later?
Can it be relaxed later when someone comes up with "--help-all" or something?
-- 
Duy
Previous: Junio C HamanoNext: Jonathan Nieder
Message 6 of 12 in “run_builtin(): save "-h" detection result for later use”
  1. 1/3 run_builtin(): save "-h" detection result for later useNguyễn Thái Ngọc Duy, Oct 19, 2010
  2. 2/3 builtins: utilize startup_info->help where possibleNguyễn Thái Ngọc Duy, Oct 19, 2010
  3. Jonathan NiederOct 19, 2010
  4. Jonathan NiederOct 19, 2010
  5. Junio C HamanoOct 19, 2010
  6. Nguyen Thai Ngoc DuyOct 20, 2010
  7. Jonathan NiederOct 20, 2010
  8. 3/3 builtins: check for startup_info->help, print and exit earlyNguyễn Thái Ngọc Duy, Oct 19, 2010
  9. Junio C HamanoOct 19, 2010
  10. Nguyen Thai Ngoc DuyOct 20, 2010
  11. Jonathan NiederOct 19, 2010
  12. Jonathan NiederOct 19, 2010

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.