git checkout: do not allow switching to a tree-ish that is not a commit
[gitweb.git] / builtin-checkout.c
index c107fd643a452edb016f7ad867d4b2a555d9abaf..544aa5add14b43f9d44caf3fecf874fd3498dd6e 100644 (file)
@@ -515,8 +515,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
                argv++;
                argc--;
 
+               new.name = arg;
                if ((new.commit = lookup_commit_reference_gently(rev, 1))) {
-                       new.name = arg;
                        setup_branch_path(&new);
                        if (resolve_ref(new.path, rev, 1, NULL))
                                new.commit = lookup_commit_reference(rev);