Commit c41494f8 authored by Matthieu Moy's avatar Matthieu Moy Committed by Junio C Hamano

Reduce cost of deletion in levenstein distance (4 -> 3)

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: default avatarMatthieu Moy <[email protected]>
Signed-off-by: default avatarJunio C Hamano <[email protected]>
parent befc5ed3
......@@ -317,7 +317,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,
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment