diff options
author | Junio C Hamano <junkio@cox.net> | 2006-02-28 16:01:36 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-02-28 20:20:04 -0800 |
commit | 65416758cd83772f2f3c69f1bd1f501608e64745 (patch) | |
tree | f485bb85d2c949372344265842466669d0a167d0 /diffcore-delta.c | |
parent | aeecd23ae2785a0462d42191974e9d9a8e439fbe (diff) | |
download | git-65416758cd83772f2f3c69f1bd1f501608e64745.tar.gz git-65416758cd83772f2f3c69f1bd1f501608e64745.tar.xz |
diffcore-rename: split out the delta counting code.
This is to rework diffcore break/rename/copy detection code
so that it does not affected when deltifier code gets improved.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'diffcore-delta.c')
-rw-r--r-- | diffcore-delta.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/diffcore-delta.c b/diffcore-delta.c new file mode 100644 index 000000000..1e6a6911e --- /dev/null +++ b/diffcore-delta.c @@ -0,0 +1,43 @@ +#include "cache.h" +#include "diff.h" +#include "diffcore.h" +#include "delta.h" +#include "count-delta.h" + +static int diffcore_count_changes_1(void *src, unsigned long src_size, + void *dst, unsigned long dst_size, + unsigned long delta_limit, + unsigned long *src_copied, + unsigned long *literal_added) +{ + void *delta; + unsigned long delta_size; + + delta = diff_delta(src, src_size, + dst, dst_size, + &delta_size, delta_limit); + if (!delta) + /* If delta_limit is exceeded, we have too much differences */ + return -1; + + /* Estimate the edit size by interpreting delta. */ + if (count_delta(delta, delta_size, src_copied, literal_added)) { + free(delta); + return -1; + } + free(delta); + return 0; +} + +int diffcore_count_changes(void *src, unsigned long src_size, + void *dst, unsigned long dst_size, + unsigned long delta_limit, + unsigned long *src_copied, + unsigned long *literal_added) +{ + return diffcore_count_changes_1(src, src_size, + dst, dst_size, + delta_limit, + src_copied, + literal_added); +} |