From b45563a229f5150271837cf487a91ddd8224fbd3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 30 Nov 2007 22:22:38 -0800 Subject: rename: Break filepairs with different types. When we consider if a path has been totally rewritten, we did not touch changes from symlinks to files or vice versa. But a change that modifies even the type of a blob surely should count as a complete rewrite. While we are at it, modernise diffcore-break to be aware of gitlinks (we do not want to touch them). Signed-off-by: Junio C Hamano --- diffcore-break.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'diffcore-break.c') diff --git a/diffcore-break.c b/diffcore-break.c index c71a22621a..31cdcfe8bc 100644 --- a/diffcore-break.c +++ b/diffcore-break.c @@ -52,8 +52,10 @@ static int should_break(struct diff_filespec *src, * is the default. */ - if (!S_ISREG(src->mode) || !S_ISREG(dst->mode)) - return 0; /* leave symlink rename alone */ + if (S_ISREG(src->mode) != S_ISREG(dst->mode)) { + *merge_score_p = (int)MAX_SCORE; + return 1; /* even their types are different */ + } if (src->sha1_valid && dst->sha1_valid && !hashcmp(src->sha1, dst->sha1)) @@ -168,11 +170,13 @@ void diffcore_break(int break_score) struct diff_filepair *p = q->queue[i]; int score; - /* We deal only with in-place edit of non directory. + /* + * We deal only with in-place edit of blobs. * We do not break anything else. */ if (DIFF_FILE_VALID(p->one) && DIFF_FILE_VALID(p->two) && - !S_ISDIR(p->one->mode) && !S_ISDIR(p->two->mode) && + object_type(p->one->mode) == OBJ_BLOB && + object_type(p->two->mode) == OBJ_BLOB && !strcmp(p->one->path, p->two->path)) { if (should_break(p->one, p->two, break_score, &score)) { -- cgit v1.2.3