Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information...
commit c41494f8c89c330cc9bd4629cdc3c428803e76bc 1 parent befc5ed
Matthieu Moy authored May 27, 2012 gitster committed May 29, 2012

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  help.c
2  help.c
@@ -317,7 +317,7 @@ const char *help_unknown_cmd(const char *cmd)
317 317
 		}
318 318
 
319 319
 		main_cmds.names[i]->len =
320  
-			levenshtein(cmd, candidate, 0, 2, 1, 4) + 1;
  320
+			levenshtein(cmd, candidate, 0, 2, 1, 3) + 1;
321 321
 	}
322 322
 
323 323
 	qsort(main_cmds.names, main_cmds.cnt,

0 notes on commit c41494f

Please sign in to comment.
Something went wrong with that request. Please try again.