• Thomas Rast's avatar
    commit: write cache-tree data when writing index anyway · 11c8a74a
    Thomas Rast authored
    In prepare_index(), we refresh the index, and then write it to disk if
    this changed the index data.  After running hooks we re-read the index
    and compute the root tree sha1 with the cache-tree machinery.
    
    This gives us a mostly free opportunity to write up-to-date cache-tree
    data: we can compute it in prepare_index() immediately before writing
    the index to disk.
    
    If we do this, we were going to write the index anyway, and the later
    cache-tree update has no further work to do.  If we don't do it, we
    don't do any extra work, though we still don't have have cache-tree
    data after the commit.
    
    The only case that suffers badly is when the pre-commit hook changes
    many trees in the index.  I'm writing this off as highly unusual.
    Signed-off-by: default avatarThomas Rast <trast@student.ethz.ch>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    11c8a74a
t0090-cache-tree.sh 2.15 KB