• Erik Faye-Lund's avatar
    checkout: do not corrupt HEAD on empty repo · 8338f771
    Erik Faye-Lund authored
    In abe19980 ("git checkout -b: allow switching out of an unborn
    branch"), a code-path overly-optimisticly assumed that a
    branch-name was specified. This is not always the case, and as
    a result a NULL-pointer was attempted printed to .git/HEAD.
    This could lead to at least two different failure modes:
     1) vsnprintf formated the NULL-string as something useful (e.g
     2) vsnprintf crashed
    Neither were very convenient for formatting a new HEAD-reference.
    To fix this, reintroduce some strictness so we only take this
    new codepath if a banch-name was specified.
    Signed-off-by: Erik Faye-Lund's avatarErik Faye-Lund <kusmabite@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
t2015-checkout-unborn.sh 1.37 KB