From: Daniel Cordero <theappleman@gmail.com>
To: Nanako Shiraishi <nanako3@lavabit.com>
Cc: git@vger.kernel.org
Subject: [PATCH] builtin-checkout: Don't tell user that HEAD has moved before it has
Date: Sat, 16 May 2009 10:54:45 -0700 [thread overview]
Message-ID: <20090516175444.GA1000@cumin.applehq.eu> (raw)
In-Reply-To: <20090516192531.6117@nanako3.lavabit.com>
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>
---
builtin-checkout.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/builtin-checkout.c b/builtin-checkout.c
index dc4bfb5..f2d7ef0 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);
--
1.6.3.1.93.g8d138
next prev parent reply other threads:[~2009-05-16 17:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-16 10:25 [buglet] misleading error message from git checkout Nanako Shiraishi
2009-05-16 17:54 ` Daniel Cordero [this message]
2009-05-16 19:57 ` [PATCH] builtin-checkout: Don't tell user that HEAD has moved before it has Junio C Hamano
2009-05-17 2:43 ` [PATCH] test: checkout shouldn't say that HEAD has moved if it didn't Nanako Shiraishi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090516175444.GA1000@cumin.applehq.eu \
--to=theappleman@gmail.com \
--cc=git@vger.kernel.org \
--cc=nanako3@lavabit.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).