Skip to content
  • Junio C Hamano's avatar
    checkout: Fix "initial checkout" detection · fa7b3c2f
    Junio C Hamano authored
    Earlier commit 55218834 (checkout: do not lose staged removal, 2008-09-07)
    tightened the rule to prevent switching branches from losing local
    changes, so that staged removal of paths can be protected, while
    attempting to keep a loophole to still allow a special case of switching
    out of an un-checked-out state.
    
    However, the loophole was made a bit too tight, and did not allow
    switching from one branch (in an un-checked-out state) to check out
    another branch.
    
    The change to builtin-checkout.c in this commit loosens it to allow this,
    by not insisting the original commit and the new commit to be the same.
    
    It also introduces a new function, is_index_unborn (and an associated
    macro, is_cache_unborn), to check if the repository is truly in an
    un-checked-out state more reliably, by making sure that $GIT_INDEX_FILE
    did not exist when populating the in-core index structure.  A few places
    the earlier commit 55218834 added the check for the initial checkout
    condition are upd...
    fa7b3c2f