author | Junio C Hamano <gitster@pobox.com> | |
Sat, 3 Jan 2009 12:07:32 +0000 (04:07 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 3 Jan 2009 21:34:19 +0000 (13:34 -0800) | ||
commit | 3442ea4a75a3c76f65efac71b414584f765e5a99 | |
tree | 1ba10fed9fb2ef89b102e0462579133e6d851502 | tree | snapshot |
parent | 27c03aafdf29736f889c56777426066c74fa115d | commit | 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>
"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>
builtin-checkout.c | diff | blob | history | |
t/t2011-checkout-invalid-head.sh | diff | blob | history |