On Mon, Oct 22, 2007 at 02:32:22AM -0400, Shawn O. Pearce wrote: > * lt/rename (Sun Oct 21 16:59:03 2007 -0700) 2 commits > - Linear-time/space rename logic (exact renames only) > - Split out "exact content match" phase of rename detection > > t4001-diff-rename.sh failed while running tests on pu. I'm pretty > sure its this topic from Linus. Need to look at it further. Hrm, the problem is that it's not favoring basenames anymore. But I think it is because the loop in find_identical_files is inside out. For every source file, it picks the best destination file. But I think we want to do the opposite: for every destination file, pick the best source file. Otherwise, if a non-basename source file is connected with a particular destination file, we no longer try that destination file again. Patch is below (please just squash with the one from Linus). diff --git a/diffcore-rename.c b/diffcore-rename.c index 05d39db..8881818 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -252,17 +252,18 @@ static int find_identical_files(struct file_similarity *src, { int renames = 0; do { - struct diff_filespec *one = src->filespec; + struct diff_filespec *one = dst->filespec; struct file_similarity *p, *best; int i = 100; best = NULL; - for (p = dst; p; p = p->next) { + for (p = src; p; p = p->next) { struct diff_filespec *two = p->filespec; - /* Already picked as a destination? */ + /* Already picked as a source? */ if (!p->src_dst) continue; + /* False hash collission? */ if (hashcmp(one->sha1, two->sha1)) continue; @@ -276,10 +277,10 @@ static int find_identical_files(struct file_similarity *src, } if (best) { best->src_dst = 0; - record_rename_pair(best->index, src->index, MAX_SCORE); + record_rename_pair(dst->index, best->index, MAX_SCORE); renames++; } - } while ((src = src->next) != NULL); + } while ((dst = dst->next) != NULL); return renames; } - 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