Thread (3 messages) flat view 3 messages, 2 authors, 2016-06-15

Re: [PATCH] git wrapper: DWIM mistyped commands

From: Mikael Magnusson <hidden>
Date: 2016-06-15 22:45:16

2008/8/31 Alex Riesen [off-list ref]:
From: Johannes Schindelin <redacted>

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help