]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/checkout.c
checkout: rearrange update_refs_for_switch for clarity
authorJonathan Nieder <jrnieder@gmail.com>
Tue, 8 Feb 2011 10:34:34 +0000 (04:34 -0600)
committerJunio C Hamano <gitster@pobox.com>
Tue, 8 Feb 2011 19:14:26 +0000 (11:14 -0800)
commitf8bd36a433768f1b11642faff5b88e3510aa8af8
treeb2af33785acca45118e2004102edb8693c423c88
parent32669671c7746888aa1e3832907deb7fc8405061
checkout: rearrange update_refs_for_switch for clarity

Take care of simple, exceptional cases before the meat of the "check
out by branch name" code begins.  After this change, the function
vaguely follows the following pseudocode:

if (-B or -b)
create branch;
if (plain "git checkout" or "git checkout HEAD")
;
else if (--detach or checking out by non-branch commit name)
detach HEAD;
else if (checking out by branch name)
attach HEAD;

One nice side benefit is to make it possible to remove handling of
the --detach option from outside switch_branches.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c