aboutsummaryrefslogtreecommitdiff
path: root/builtin-checkout.c
diff options
context:
space:
mode:
authorDaniel Cordero <theappleman@gmail.com>2009-05-16 10:54:45 -0700
committerJunio C Hamano <gitster@pobox.com>2009-05-16 12:51:58 -0700
commit77ebd56dc3d2efaeac87edc990cc1b99f331527c (patch)
tree863f3db962ea7157fe925c8d8f20b9687e777044 /builtin-checkout.c
parentc646217e1366b0397552fad8c32acb47fbe8977d (diff)
downloadgit-77ebd56dc3d2efaeac87edc990cc1b99f331527c.tar.gz
git-77ebd56dc3d2efaeac87edc990cc1b99f331527c.tar.xz
builtin-checkout: Don't tell user that HEAD has moved before it has
Previously, checkout would tell the user this message before moving HEAD, without regard to whether the upcoming move will result in success. If the move failed, this causes confusion. Show the message after the move, unless the move failed. Signed-off-by: Daniel Cordero <theappleman@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-checkout.c')
-rw-r--r--builtin-checkout.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/builtin-checkout.c b/builtin-checkout.c
index dc4bfb5fc..f2d7ef01b 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -541,14 +541,6 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
parse_commit(new->commit);
}
- /*
- * If we were on a detached HEAD, but we are now moving to
- * a new commit, we want to mention the old commit once more
- * to remind the user that it might be lost.
- */
- if (!opts->quiet && !old.path && old.commit && new->commit != old.commit)
- describe_detached_head("Previous HEAD position was", old.commit);
-
if (!old.commit && !opts->force) {
if (!opts->quiet) {
warning("You appear to be on a branch yet to be born.");
@@ -561,6 +553,14 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
if (ret)
return ret;
+ /*
+ * If we were on a detached HEAD, but have now moved to
+ * a new commit, we want to mention the old commit once more
+ * to remind the user that it might be lost.
+ */
+ if (!opts->quiet && !old.path && old.commit && new->commit != old.commit)
+ describe_detached_head("Previous HEAD position was", old.commit);
+
update_refs_for_switch(opts, &old, new);
ret = post_checkout_hook(old.commit, new->commit, 1);