Skip to content
  • Johannes Schindelin's avatar
    git wrapper: DWIM mistyped commands · 8af84dad
    Johannes Schindelin authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    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'
    	[...]
    
    Signed-off-by: default avatarJohannes Schindelin <johannes.schindelin@gmx.de>
    Signed-off-by: default avatarAlex Riesen <raa.lkml@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    8af84dad