summaryrefslogtreecommitdiff
path: root/diffcore-break.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-06-03 01:36:03 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-03 11:23:03 -0700
commit355e76a4a3c5e49ae15a642806457bce10fe2ef4 (patch)
tree61d1a1313ab1732458e47f55e14d6c1c7f1225ea /diffcore-break.c
parent5b86040679626e36c12345039f6df62f4622aef2 (diff)
downloadgit-355e76a4a3c5e49ae15a642806457bce10fe2ef4.tar.gz
[PATCH] Tweak count-delta interface
Make it return copied source and insertion separately, so that later implementation of heuristics can use them more flexibly. This does not change the heuristics implemented in diffcore-rename nor diffcore-break in any way. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'diffcore-break.c')
-rw-r--r--diffcore-break.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/diffcore-break.c b/diffcore-break.c
index c5e006df67..cab91a201a 100644
--- a/diffcore-break.c
+++ b/diffcore-break.c
@@ -23,7 +23,7 @@ static int very_different(struct diff_filespec *src,
* want to get the filepair broken.
*/
void *delta;
- unsigned long delta_size, base_size;
+ unsigned long delta_size, base_size, src_copied, literal_added;
if (!S_ISREG(src->mode) || !S_ISREG(dst->mode))
return 0; /* leave symlink rename alone */
@@ -61,10 +61,17 @@ static int very_different(struct diff_filespec *src,
return MAX_SCORE;
/* Estimate the edit size by interpreting delta. */
- delta_size = count_delta(delta, delta_size);
+ if (count_delta(delta, delta_size, &src_copied, &literal_added)) {
+ free(delta);
+ return 0;
+ }
free(delta);
- if (delta_size == UINT_MAX)
- return 0; /* error in delta computation */
+
+ /* Extent of damage */
+ if (src->size + literal_added < src_copied)
+ delta_size = 0;
+ else
+ delta_size = (src->size - src_copied) + literal_added;
if (base_size < delta_size)
return MAX_SCORE;