Skip to content
Snippets Groups Projects
Select Git revision
1 result Searching

diffcore-delta.c

Blame
    • Linus Torvalds's avatar
      77cd6ab6
      Fix diff -B/--dirstat miscounting of newly added contents · 77cd6ab6
      Linus Torvalds authored
      
      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: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      77cd6ab6
      History
      Fix diff -B/--dirstat miscounting of newly added contents
      Linus Torvalds authored
      
      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: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    detect.py 14.02 KiB