Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-01-03 15:07:32 +0300
committerJunio C Hamano <gitster@pobox.com>2009-01-04 00:34:19 +0300
commit3442ea4a75a3c76f65efac71b414584f765e5a99 (patch)
tree1ba10fed9fb2ef89b102e0462579133e6d851502 /builtin-checkout.c
parent27c03aafdf29736f889c56777426066c74fa115d (diff)
git checkout: do not allow switching to a tree-ish that is not a commit
"git checkout -b newbranch $commit^{tree}" mistakenly created a new branch rooted at the current HEAD, because in that case, the two structure fields used to see if the command was invoked without any argument (hence it needs to default to checking out the HEAD) were populated incorrectly. Upon seeing a command line argument that we took as a rev, we should store that string in new.name, even if that does not name a commit. This will correctly trigger the existing safety logic. Signed-off-by: Junio C Hamano <gitster@pobox.com> Acked-by: Daniel Barkalow <barkalow@iabervon.org>
Diffstat (limited to 'builtin-checkout.c')
-rw-r--r--builtin-checkout.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin-checkout.c b/builtin-checkout.c
index c107fd643a..544aa5add1 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -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);