From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: git@vger.kernel.org
Cc: Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: [RFC/PATCH] Reduce cost of deletion in levenstein distance (4 -> 3)
Date: Fri, 27 Apr 2012 10:58:02 +0200 [thread overview]
Message-ID: <1335517082-29325-1-git-send-email-Matthieu.Moy@imag.fr> (raw)
Before this patch, a character deletion has the same cost as 2 swaps, or
4 additions, so Git prefers suggesting a completely scrambled command
name to removing a character. For example, "git tags" suggests "stage",
but not "tag".
By setting the deletion cost to 3, we keep it higher than swaps or
additions, but prefer 1 deletion to 2 swaps. "git tags" now suggests
"tag" in addition to staged.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
The funny thing is: A while ago, I reported that the typo "git tags"
was not suggesting "git tag" as alternative "did you mean this?". A
patch was posted and merged:
http://thread.gmane.org/gmane.comp.version-control.git/101278
According to the discussion, I it worked for me. But I can't reproduce
this "works for me" even going back to the version right after the fix
above.
help.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/help.c b/help.c
index 14eefc9..fdaa90d 100644
--- a/help.c
+++ b/help.c
@@ -334,7 +334,7 @@ const char *help_unknown_cmd(const char *cmd)
}
main_cmds.names[i]->len =
- levenshtein(cmd, candidate, 0, 2, 1, 4) + 1;
+ levenshtein(cmd, candidate, 0, 2, 1, 3) + 1;
}
qsort(main_cmds.names, main_cmds.cnt,
--
1.7.10.363.g9094b
next reply other threads:[~2012-04-27 8:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-27 8:58 Matthieu Moy [this message]
2012-04-27 9:43 ` [RFC/PATCH] Reduce cost of deletion in levenstein distance (4 -> 3) Zbigniew Jędrzejewski-Szmek
2012-05-24 20:33 ` Matthieu Moy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1335517082-29325-1-git-send-email-Matthieu.Moy@imag.fr \
--to=matthieu.moy@imag.fr \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).