Skip to content
  • Petr Baudis's avatar
    git-mv: Keep moved index entries inact · 81dc2307
    Petr Baudis authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    The rewrite of git-mv from a shell script to a builtin was perhaps
    a little too straightforward: the git add and git rm queues were
    emulated directly, which resulted in a rather complicated code and
    caused an inconsistent behaviour when moving dirty index entries;
    git mv would update the entry based on working tree state,
    except in case of overwrites, where the new entry would still have
    sha1 of the old file.
    
    This patch introduces rename_index_entry_at() into the index toolkit,
    which will rename an entry while removing any entries the new entry
    might render duplicate. This is then used in git mv instead
    of all the file queues, resulting in a major simplification
    of the code and an inevitable change in git mv -n output format.
    
    Also the code used to refuse renaming overwriting symlink with a regular
    file and vice versa; there is no need for that.
    
    A few new tests have been added to the testsuite to reflect this change.
    
    Signed-off-by: default avatarPetr Baudis <pasky@suse.cz>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    81dc2307