summaryrefslogtreecommitdiff
path: root/levenshtein.h
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2008-08-31 15:50:23 +0200
committerJunio C Hamano <gitster@pobox.com>2008-08-31 10:14:58 -0700
commit8af84dadb142f7321ff0ce8690385e99da8ede2f (patch)
treee47023679099de35b18da39c3b1c89efc0dd2c3a /levenshtein.h
parenta1184d85e8752658f02746982822f43f32316803 (diff)
downloadgit-8af84dadb142f7321ff0ce8690385e99da8ede2f.tar.gz
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 <johannes.schindelin@gmx.de> Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'levenshtein.h')
-rw-r--r--levenshtein.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/levenshtein.h b/levenshtein.h
new file mode 100644
index 0000000000..0173abeef5
--- /dev/null
+++ b/levenshtein.h
@@ -0,0 +1,8 @@
+#ifndef LEVENSHTEIN_H
+#define LEVENSHTEIN_H
+
+int levenshtein(const char *string1, const char *string2,
+ int swap_penalty, int substition_penalty,
+ int insertion_penalty, int deletion_penalty);
+
+#endif