Git development
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: git@vger.kernel.org
Subject: [TOY PATCH] diffcore-rename: replace basename_same() heuristics by levenshtein
Date: Fri, 2 Jan 2009 19:07:56 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.1.00.0901021301560.27818@racer> (raw)


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@gmx.de>
---

	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

                 reply	other threads:[~2009-01-02 18:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=alpine.DEB.1.00.0901021301560.27818@racer \
    --to=johannes.schindelin@gmx.de \
    --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