From: Mikael Magnusson Date: Mon, 01 Sep 2008 14:42:44 GMT Subject: Re: [PATCH] git wrapper: DWIM mistyped commands Message-ID: <237967ef0809010742w43de9e3dj28880de484e8c48d@mail.gmail.com> In-Reply-To: <20080831135023.GA6616@blimp.local> 2008/8/31 Alex Riesen : > From: Johannes Schindelin > > This patch introduces a modified Damerau-Levenshtein algorithm into > Git's code base, and uses it with the following penalties to show some > similar commands when an unknown command was encountered: > > swap = 0, insertion = 1, substitution = 2, deletion = 4 > > A typical output would now look like this: > > $ git sm > git: 'sm' is not a git-command. See 'git --help'. > > Did you mean one of these? > am > rm > > The cut-off is at similarity rating 6, which was empirically determined > to give sensible results. > > As a convenience, if there is only one candidate, Git continues under > the assumption that the user mistyped it. Example: > > $ git reabse > WARNING: You called a Git program named 'reabse', which does > not exist. > Continuing under the assumption that you meant 'rebase' > [...] > Mikael, this also might fix the crash you're seeing: the heap was > corrupted by clean_cmdnames(&other_cmds) names members of which were > moved to main_cmds. It doesn't crash now, but the cut-off appears ineffective: % git aaaaaaaaaaaaaaa WARNING: You called a Git program named 'aaaaaaaaaaaaaaa', which does not exist. Continuing under the assumption that you meant 'add--interactive' in 2.0 seconds automatically... By my estimate, that should have a score above 6 :). -- Mikael Magnusson