Git development
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Alex Riesen <raa.lkml@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [TOY PATCH] git wrapper: show similar command names for an unknown command
Date: Sat, 7 Jun 2008 16:04:14 +0100 (BST)	[thread overview]
Message-ID: <alpine.DEB.1.00.0806071603470.1783@racer> (raw)
In-Reply-To: <20080607072721.GA3347@steel.home>

Hi,

On Sat, 7 Jun 2008, Alex Riesen wrote:


> diff --git a/help.c b/help.c
> index ac29225..765eed8 100644
> --- a/help.c
> +++ b/help.c
> @@ -640,7 +640,7 @@ static int levenshtein_compare(const void *p1, const void *p2)
>  
>  void help_unknown_cmd(const char *cmd)
>  {
> -	int i, header_shown = 0;
> +	int i, header_shown = 0, listed = 0;
>  
>  	fprintf(stderr, "git: '%s' is not a git-command. See 'git --help'.\n", cmd);
>  
> @@ -667,6 +667,8 @@ void help_unknown_cmd(const char *cmd)
>  			header_shown = 1;
>  		}
>  		fprintf(stderr, "\t%s\n", main_cmds.names[i]->name);
> +		if (++listed >= 5)
> +			break;
>  	}
>  
>  	exit(1);

How about this instead?

-- snipsnap --

 help.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/help.c b/help.c
index bd51852..173e502 100644
--- a/help.c
+++ b/help.c
@@ -655,7 +655,7 @@ void help_unknown_cmd(const char *cmd)
 	qsort(main_cmds.names, main_cmds.cnt,
 	      sizeof(*main_cmds.names), levenshtein_compare);
 
-	for (i = 0; i < main_cmds.cnt; i++) {
+	for (i = 0; i < main_cmds.cnt && i < 5; i++) {
 		int s = similarity(main_cmds.names[i]->name);
 		if (s > 6)
 			break;

  reply	other threads:[~2008-06-07 15:06 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-05  6:48 [TOY PATCH] git wrapper: show similar command names for an unknown command Johannes Schindelin
2008-06-05  8:19 ` [PATCH] Add subcommand "help" to the list of most commonly used subcommands Teemu Likonen
2008-06-05 10:32   ` Johannes Schindelin
2008-06-05 10:52     ` Teemu Likonen
2008-06-05 10:57       ` [PATCH v2 1/2] " Teemu Likonen
2008-06-05 10:57         ` [PATCH v2 2/2] More informative short description for git-help.txt Teemu Likonen
2008-06-05 12:58       ` [PATCH] Add subcommand "help" to the list of most commonly used subcommands Johannes Schindelin
2008-06-05 11:21     ` Sverre Rabbelier
2008-06-05 13:22       ` Teemu Likonen
2008-06-05 18:13   ` Junio C Hamano
2008-06-05 18:38     ` Pieter de Bie
2008-06-05 21:15       ` Teemu Likonen
2008-06-05 21:17       ` Junio C Hamano
2008-06-06  5:11         ` David Symonds
2008-06-05 18:42     ` Wincent Colaiuta
2008-06-05 19:15       ` Sverre Rabbelier
2008-06-05 20:59 ` [TOY PATCH] git wrapper: show similar command names for an unknown command Dirk Süsserott
2008-06-05 23:00   ` Johannes Schindelin
2008-06-06 12:15 ` Robin Rosenberg
2008-06-06 14:18   ` Wincent Colaiuta
2008-06-07  7:27 ` Alex Riesen
2008-06-07 15:04   ` Johannes Schindelin [this message]
2008-06-07 17:51     ` Alex Riesen
2008-06-07 18:08       ` Junio C Hamano
2008-06-08 15:07         ` Johannes Schindelin
2008-06-08 15:14           ` Dirk Süsserott
2008-06-08 17:53             ` Junio C Hamano
2008-06-08 23:26               ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.1.00.0806071603470.1783@racer \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=raa.lkml@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox