Skip to content
  • Junio C Hamano's avatar
    [PATCH] diff: Update -B heuristics. · eeaa4603
    Junio C Hamano authored
    
    
    As Linus pointed out on the mailing list discussion, -B should
    break a files that has many inserts even if it still keeps
    enough of the original contents, so that the broken pieces can
    later be matched with other files by -M or -C.  However, if such
    a broken pair does not get picked up by -M or -C, we would want
    to apply different criteria; namely, regardless of the amount of
    new material in the result, the determination of "rewrite"
    should be done by looking at the amount of original material
    still left in the result.  If you still have the original 97
    lines from a 100-line document, it does not matter if you add
    your own 13 lines to make a 110-line document, or if you add 903
    lines to make a 1000-line document.  It is not a rewrite but an
    in-place edit.  On the other hand, if you did lose 97 lines from
    the original, it does not matter if you added 27 lines to make a
    30-line document or if you added 997 lines to make a 1000-line
    document.  You did a complete rewrite in either case.
    
    This patch introduces a post-processing phase that runs after
    diffcore-rename matches up broken pairs diffcore-break creates.
    The purpose of this post-processing is to pick up these broken
    pieces and merge them back into in-place modifications.  For
    this, the score parameter -B option takes is changed into a pair
    of numbers, and it takes "-B99/80" format when fully spelled
    out.  The first number is the minimum amount of "edit" (same
    definition as what diffcore-rename uses, which is "sum of
    deletion and insertion") that a modification needs to have to be
    broken, and the second number is the minimum amount of "delete"
    a surviving broken pair must have to avoid being merged back
    together.  It can be abbreviated to "-B" to use default for
    both, "-B9" or "-B9/" to use 90% for "edit" but default (80%)
    for merge avoidance, or "-B/75" to use default (99%) "edit" and
    75% for merge avoidance.
    
    Signed-off-by: default avatarJunio C Hamano <junkio@cox.net>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    eeaa4603