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>
Daniel Cordero committed
May 16, 2009 at 10:54 UTC
77ebd56dc3d2efaeac87edc990cc1b99f331527c
1 file changed
+8
-8
builtin-checkout.c
+8
-8
@@ -541,14 +541,6 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
541
parse_commit(new->commit);
542
}
543
544
- /*
545
- * If we were on a detached HEAD, but we are now moving to
546
- * a new commit, we want to mention the old commit once more
547
- * to remind the user that it might be lost.
548
- */
549
- if (!opts->quiet && !old.path && old.commit && new->commit != old.commit)
550
- describe_detached_head("Previous HEAD position was", old.commit);
551
-
544
if (!old.commit && !opts->force) {
545
if (!opts->quiet) {
546
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)
553
if (ret)
554
return ret;
555
556
+ /*
557
+ * If we were on a detached HEAD, but have now moved to
558
+ * a new commit, we want to mention the old commit once more
559
+ * to remind the user that it might be lost.
560
+ */
561
+ if (!opts->quiet && !old.path && old.commit && new->commit != old.commit)
562
+ describe_detached_head("Previous HEAD position was", old.commit);
563
+
564
update_refs_for_switch(opts, &old, new);
565
566
ret = post_checkout_hook(old.commit, new->commit, 1);