[TOY PATCH] diffcore-rename: replace basename_same() heuristics by levenshtein

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When the environment variable GIT_USE_LEVENSHTEIN is set, the rename
score is reduced by the Damerau-Levenshtein distance.  This should
lead to a little more intuitive rename scores.

Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
---

	I have this in my personal tree, but I did not really use it.
	Maybe others want to play with it.

 diffcore-rename.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/diffcore-rename.c b/diffcore-rename.c
index 168a95b..1f4b371 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -5,6 +5,7 @@
 #include "diff.h"
 #include "diffcore.h"
 #include "hash.h"
+#include "levenshtein.h"
 
 /* Table of rename/copy destinations */
 
@@ -187,7 +188,9 @@ static int estimate_similarity(struct diff_filespec *src,
 	if (!dst->size)
 		score = 0; /* should not happen */
 	else
-		score = (int)(src_copied * MAX_SCORE / max_size);
+		score = (int)(src_copied * MAX_SCORE / max_size)
+			- (getenv("GIT_USE_LEVENSHTEIN") ?
+			   levenshtein(src->path, dst->path, 1, 1, 1, 1) : 0);
 	return score;
 }
 
-- 
1.6.1.rc3.224.g95ac9

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux