• Michael S. Tsirkin's avatar
    patch-id: make it stable against hunk reordering · 30e12b92
    Michael S. Tsirkin authored
    Patch id changes if users reorder file diffs that make up a patch.
    
    As the result is functionally equivalent, a different patch id is
    surprising to many users.
    In particular, reordering files using diff -O is helpful to make patches
    more readable (e.g. API header diff before implementation diff).
    
    Add an option to change patch-id behaviour making it stable against
    these kinds of patch change:
    calculate SHA1 hash for each hunk separately and sum all hashes
    (using a symmetrical sum) to get patch id
    
    We use a 20byte sum and not xor - since xor would give 0 output
    for patches that have two identical diffs, which isn't all that
    unlikely (e.g. append the same line in two places).
    
    The new behaviour is enabled
    - when patchid.stable is true
    - when --stable flag is present
    
    Using a new flag --unstable or setting patchid.stable to false force
    the historical behaviour.
    
    In the documentation, clarify that patch ID can now be a sum of hashes,
    not a hash.
    Document how command line and config options affect the
    behaviour.
    Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    30e12b92
git-patch-id.txt 2.1 KB