Skip to content
  • Michael Haggerty's avatar
    close_lock_file(): if close fails, roll back · 8e86c155
    Michael Haggerty authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    If closing an open lockfile fails, then we cannot be sure of the
    contents of the lockfile, so there is nothing sensible to do but
    delete it. This change also insures that the lock_file object is left
    in a defined state in this error path (namely, unlocked).
    
    The only caller that is ultimately affected by this change is
    try_merge_strategy() -> write_locked_index(), which can call
    close_lock_file() via various execution paths. This caller uses a
    static lock_file object which previously could have been reused after
    a failed close_lock_file() even though it was still in locked state.
    This change causes the lock_file object to be unlocked on failure,
    thus fixing this error-handling path.
    
    Signed-off-by: default avatarMichael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    8e86c155