summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin-checkout.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin-checkout.c b/builtin-checkout.c
index fe7c8584ca..ad3c01fdd9 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -745,8 +745,10 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
new.name = arg;
if ((new.commit = lookup_commit_reference_gently(rev, 1))) {
setup_branch_path(&new);
- if (resolve_ref(new.path, rev, 1, NULL))
- new.commit = lookup_commit_reference(rev);
+
+ if ((check_ref_format(new.path) == CHECK_REF_FORMAT_OK) &&
+ resolve_ref(new.path, rev, 1, NULL))
+ ;
else
new.path = NULL;
parse_commit(new.commit);