]> git.ipfire.org Git - thirdparty/git.git/commit - diffcore-delta.c
Fix diff -B/--dirstat miscounting of newly added contents
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 4 Dec 2009 20:07:47 +0000 (12:07 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sat, 5 Dec 2009 18:54:17 +0000 (10:54 -0800)
commit77cd6ab62108c2d4ddd4343abd9bae17c406be4b
tree0c3e054326d70a5b75bd9b7e5c7bbaf525c1cb70
parent952dfc6944b29582482ff50a85c04879406c06ba
Fix diff -B/--dirstat miscounting of newly added contents

What used to happen is that diffcore_count_changes() simply ignored any
hashes in the destination that didn't match hashes in the source. EXCEPT
if the source hash didn't exist at all, in which case it would count _one_
destination hash that happened to have the "next" hash value.  As a
consequence, newly added material was often undercounted, making output
from --dirstat and "complete rewrite" detection used by -B unrelialble.

This changes it so that:

 - whenever it bypasses a destination hash (because it doesn't match a
   source), it counts the bytes associated with that as "literal added"

 - at the end (once we have used up all the source hashes), we do the same
   thing with the remaining destination hashes.

 - when hashes do match, and we use the difference in counts as a value,
   we also use up that destination hash entry (the 'd++').

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diffcore-delta.c