From 8af84dadb142f7321ff0ce8690385e99da8ede2f Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 31 Aug 2008 15:50:23 +0200 Subject: git wrapper: DWIM mistyped commands 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: Johannes Schindelin Signed-off-by: Alex Riesen Signed-off-by: Junio C Hamano --- builtin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin.h') diff --git a/builtin.h b/builtin.h index f3502d305..e67cb2090 100644 --- a/builtin.h +++ b/builtin.h @@ -11,7 +11,7 @@ extern const char git_usage_string[]; extern const char git_more_info_string[]; extern void list_common_cmds_help(void); -extern void help_unknown_cmd(const char *cmd); +extern const char *help_unknown_cmd(const char *cmd); extern void prune_packed_objects(int); extern int read_line_with_nul(char *buf, int size, FILE *file); extern int fmt_merge_msg(int merge_summary, struct strbuf *in, -- cgit v1.2.1