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

Re: [PATCH] "git help" and "git help -a" shouldn't exit(1) unless they error

From
Shawn O. Pearce <spearce@spearce.org>
Date
Oct 22, 2007, 05:47 UTC
Message-ID
<20071022054741.GP14735@spearce.org>
In-Reply-To
<20071021214744.GH16291@srparish.net>
Scott R Parish <srp@srparish.net> wrote:
Show 11 quoted lines
> diff --git a/help.c b/help.c
> index 1cd33ec..b0d2dd4 100644
> --- a/help.c
> +++ b/help.c
> @@ -204,14 +204,14 @@ int cmd_help(int argc, const char **argv, const char *prefix)
>  	if (!help_cmd) {
>  		printf("usage: %s\n\n", git_usage_string);
>  		list_common_cmds_help();
> -		exit(1);
> +		exit(0);
>  	}

Although it seems simple on the surface this patch breaks the test suite:

	$ make test
	make -C t/ all
	make[1]: Entering directory `/home/spearce/mygit/t'
	*** t0000-basic.sh ***
	You do not seem to have built git yet.

The issue here is t0000-basic.sh runs "../git" and tests that the exit status is 1. If it isn't (the patch above makes it 0) we just abort the test suite entirely.

I think its correct for "git help" to exit 0, and also for "git
help checkout" or "git checkout --help" to exit 0, but "git" by
itself with no subcommand should exit with an error, it requires a
subcommand to continue.  So some sort of change is needed in git.c
to handle this special no subcommand condition.
  
-- 
Shawn.
Previous: Scott R ParishNext: Scott Parish
Message 2 of 4 in “"git help" and "git help -a" shouldn't exit(1) unless they error”
  1. "git help" and "git help -a" shouldn't exit(1) unless they errorScott R Parish, Oct 21, 2007
  2. Shawn O. PearceOct 22, 2007
  3. Scott ParishOct 22, 2007
  4. Shawn O. PearceOct 22, 2007

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.