summaryrefslogtreecommitdiff
path: root/diffcore-break.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-11-30 22:22:38 -0800
committerJunio C Hamano <gitster@pobox.com>2007-12-02 02:24:46 -0800
commitb45563a229f5150271837cf487a91ddd8224fbd3 (patch)
treea0b363c225777490a4c22adaf280ea7ef69f7772 /diffcore-break.c
parent1c46ab1fada6eb449336a624995293cdd74f2b08 (diff)
downloadgit-b45563a229f5150271837cf487a91ddd8224fbd3.tar.gz
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 <gitster@pobox.com>
Diffstat (limited to 'diffcore-break.c')
-rw-r--r--diffcore-break.c12
1 files changed, 8 insertions, 4 deletions
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)) {