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

Re: [PATCH] bash-completion: fix getting strategy list

From
Miklos Vajna <vmiklos@frugalware.org>
Date
Aug 21, 2008, 14:06 UTC
Message-ID
<20080821140610.GS23800@genesis.frugalware.org>
In-Reply-To
<7v7iabklas.fsf@gitster.siamese.dyndns.org>
On Wed, Aug 20, 2008 at 10:07:55PM -0700, Junio C Hamano <gitster@pobox.com> wrote:
> > Yes, there are some weird patch in 'next'.  Miklos, could you fix the
> > output format of that thing?
You were faster. ;-)
Show 35 quoted lines
> I do not think the code in 'next' that reuses the "help" thing to show
> only the list to stdout while still giving the error message to stderr
> makes any sense.
> 
> Let's do this.
> 
> ---
> 
>  builtin-merge.c |   14 +++++++++++---
>  1 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git c/builtin-merge.c w/builtin-merge.c
> index 1f9389b..3e8db0d 100644
> --- c/builtin-merge.c
> +++ w/builtin-merge.c
> @@ -110,9 +110,17 @@ static struct strategy *get_strategy(const char *name)
>  		}
>  	}
>  	if (!is_in_cmdlist(&main_cmds, name) && !is_in_cmdlist(&other_cmds, name)) {
> -
> -		fprintf(stderr, "Could not find merge strategy '%s'.\n\n", name);
> -		list_commands("strategies", longest, &main_cmds, &other_cmds);
> +		fprintf(stderr, "Could not find merge strategy '%s'.\n", name);
> +		fprintf(stderr, "Available strategies are:");
> +		for (i = 0; i < main_cmds.cnt; i++)
> +			fprintf(stderr, " %s", main_cmds.names[i]->name);
> +		fprintf(stderr, ".\n");
> +		if (other_cmds.cnt) {
> +			fprintf(stderr, "Available custom strategies are:");
> +			for (i = 0; i < other_cmds.cnt; i++)
> +				fprintf(stderr, " %s", other_cmds.names[i]->name);
> +			fprintf(stderr, ".\n");
> +		}
>  		exit(1);
>  	}

Given that we don't have 100+ merge strategies like we have 100+ git commands, I think printing them in one line should not be problematic, and this definitely improves script usability, so I like it, thanks.

Previous: Junio C Hamano
Message 16 of 16 in “[BUG] git completion do sed on binary file”
  1. Nguyen Thai Ngoc DuyAug 19, 2008
  2. bash-completion: fix getting strategy listNguyen Thai Ngoc Duy, Aug 19, 2008
  3. Matthieu MoyAug 19, 2008
  4. Nguyen Thai Ngoc DuyAug 19, 2008
  5. Shawn O. PearceAug 19, 2008
  6. Johannes SixtAug 19, 2008
  7. Johannes SixtAug 19, 2008
  8. Nguyen Thai Ngoc DuyAug 20, 2008
  9. Junio C HamanoAug 20, 2008
  10. Junio C HamanoAug 20, 2008
  11. Miklos VajnaAug 20, 2008
  12. Nguyen Thai Ngoc DuyAug 21, 2008
  13. Mikael MagnussonAug 21, 2008
  14. Junio C HamanoAug 21, 2008
  15. Junio C HamanoAug 21, 2008
  16. Miklos VajnaAug 21, 2008

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.