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

Re: [PATCH 3/3] builtins: check for startup_info->help, print and exit early

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 19, 2010, 16:33 UTC
Message-ID
<7vvd4y16t8.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1287495320-27278-3-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
Show 8 quoted lines
> These commands need more than just git_config() before parsing
> commmand line arguments. Some of these activities will unconditionally
> look into a repository. When startup_info->help is TRUE, no repository
> is set up and the caller expects callees to print help usage and exit,
> no more.
>
> Do as expected.
> ---
No sign-off given to any of the three patches...
Show 12 quoted lines
> diff --git a/builtin/branch.c b/builtin/branch.c
> index 87976f0..9f152ed 100644
> --- a/builtin/branch.c
> +++ b/builtin/branch.c
> @@ -667,6 +667,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
>  		OPT_END(),
>  	};
>  
> +	if (startup_info->help)
> +		usage_with_options(builtin_branch_usage, options);
> +
>  	git_config(git_branch_config, NULL);
I can just say:
    $ cd / && git branch -h
    usage: git branch [options] ...

without your patch just fine (and no I am not insane to make / controlled by git).

The same for checkout-index, commit, ls-files, etc.
Show 13 quoted lines
> diff --git a/builtin/gc.c b/builtin/gc.c
> index c304638..f040171 100644
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -191,6 +191,9 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
>  
>  	git_config(gc_config, NULL);
>  
> +	if (startup_info->help)
> +		usage_with_options(builtin_gc_usage, builtin_gc_options);
> +
>  	if (pack_refs < 0)
>  		pack_refs = !is_bare_repository();

This one is curious. Why do you need a call to git_config() in "gc" only? You don't do that for e.g. "branch".

While I do not see anything glaringly wrong with this change, I am not sure I am getting the point of these patches.

Previous: Nguyễn Thái Ngọc DuyNext: Nguyen Thai Ngoc Duy
Message 9 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.