Skip to content
  • Jonathan Tan's avatar
    diff: define block by number of alphanumeric chars · f0b8fb6e
    Jonathan Tan authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    The existing behavior of diff --color-moved=zebra does not define the
    minimum size of a block at all, instead relying on a heuristic applied
    later to filter out sets of adjacent moved lines that are shorter than 3
    lines long. This can be confusing, because a block could thus be colored
    as moved at the source but not at the destination (or vice versa),
    depending on its neighbors.
    
    Instead, teach diff that the minimum size of a block is 20 alphanumeric
    characters, the same heuristic used by "git blame". This allows diff to
    still exclude uninteresting lines appearing on their own (such as those
    solely consisting of one or a few closing braces), as was the intention
    of the adjacent-moved-line heuristic.
    
    This requires a change in some tests in that some of their lines are no
    longer considered to be part of a block, because they are too short.
    
    Signed-off-by: default avatarJonathan Tan <jonathantanmy@google.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    f0b8fb6e