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
Jonathan Nieder <jrnieder@gmail.com>
Date
Oct 19, 2010, 17:55 UTC
Message-ID
<20101019175520.GD25139@burratino>
In-Reply-To
<1287495320-27278-3-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy wrote:
Show 12 quoted lines
> --- 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);
>  
>  	if (branch_use_color == -1)
One has to work hard to trigger this one.
	git init foo
	cd foo
	>.git/refs/heads/master
	git branch -h
Produces:
	fatal: Failed to resolve HEAD as a valid ref.
Show 12 quoted lines
> --- a/builtin/checkout-index.c
> +++ b/builtin/checkout-index.c
> @@ -241,6 +241,9 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
>  		OPT_END()
>  	};
>  
> +	if (startup_info->help)
> +		usage_with_options(builtin_checkout_index_usage, builtin_checkout_index_options);
> +
>  	git_config(git_default_config, NULL);
>  	state.base_dir = "";
>  	prefix_length = prefix ? strlen(prefix) : 0;
	git init foo
	cd foo
	>.git/index
	git checkout-index -h
Produces:
	fatal: index file smaller than expected
> --- a/builtin/commit.c
> +++ b/builtin/commit.c

I'm stopping here. But maybe some test cases like this would make the series clearer.

Hope that helps, Jonathan

Previous: Nguyen Thai Ngoc DuyNext: Jonathan Nieder
Message 11 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.