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

Re: [PATCH resend] help: convert git_cmd to page in one place

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 6, 2021, 20:11 UTC
Message-ID
<xmqqfswri4o6.fsf@gitster.g>
In-Reply-To
<87tul9706u.fsf@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 8 quoted lines
>> @@ -606,16 +604,17 @@ int cmd_help(int argc, const char **argv, const char *prefix)
>>  
>>  	argv[0] = check_git_cmd(argv[0]);
>>  
>> +	page = cmd_to_page(argv[0]);
>
> Nit not requring a re-roll: I'd snuggle this with the argv[0], not the
> switch statement, i.e. like the existing code.
Makes sense.
Show 25 quoted lines
>>  	switch (help_format) {
>>  	case HELP_FORMAT_NONE:
>>  	case HELP_FORMAT_MAN:
>> -		show_man_page(argv[0]);
>> +		show_man_page(page);
>>  		break;
>>  	case HELP_FORMAT_INFO:
>> -		show_info_page(argv[0]);
>> +		show_info_page(page);
>>  		break;
>>  	case HELP_FORMAT_WEB:
>> -		show_html_page(argv[0]);
>> +		show_html_page(page);
>>  		break;
>>  	}
>
> More generally (not the fault of this patch) the control flow in that
> file is quite a mess. I wondered why we can't just add this to
> check_git_cmd() then, it's also only called in that one place.
>
> We can, but it and cmd_to_page() return in multiple places, and
> help_unknown_cmd() might return, might exit(1) itself etc, so fixing
> similar to my 338abb0f045 (builtins + test helpers: use return instead
> of exit() in cmd_*, 2021-06-08) should probably be part of some general
> refactoring... :)
True, too.
Previous: Ævar Arnfjörð BjarmasonNext: Andrei Rybak
Message 5 of 7 in “help: convert git_cmd to page in one place”
  1. help: convert git_cmd to page in one placeAndrei Rybak, Jun 26, 2021
  2. Felipe ContrerasJun 26, 2021
  3. help: convert git_cmd to page in one placeAndrei Rybak, Jul 4, 2021
  4. Ævar Arnfjörð BjarmasonJul 5, 2021
  5. Junio C HamanoJul 6, 2021
  6. Andrei RybakJul 8, 2021
  7. Junio C HamanoJul 8, 2021

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.