author | Junio C Hamano <gitster@pobox.com> | |
Sat, 3 Jan 2009 21:57:30 +0000 (13:57 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 3 Jan 2009 21:57:30 +0000 (13:57 -0800) |
* jc/maint-do-not-switch-to-non-commit:
git checkout: do not allow switching to a tree-ish that is not a commit
git checkout: do not allow switching to a tree-ish that is not a commit
builtin-checkout.c | patch | blob | history | |
t/t2011-checkout-invalid-head.sh | patch | blob | history |
diff --git a/builtin-checkout.c b/builtin-checkout.c
index c2c05613b67d7cc8bd3500bdbca4fc3533afaeee..b5dd9c07b42e0130384259715730f52bc8c4e6c3 100644 (file)
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
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);
index 764bb0a6bc3de1f3313fb16c384bbd37c82ae5da..15ebdc26ebaaf7881b1f51eb788c2eb2922b6d4f 100755 (executable)
git commit -m initial
'
+test_expect_success 'checkout should not start branch from a tree' '
+ test_must_fail git checkout -b newbranch master^{tree}
+'
+
test_expect_success 'checkout master from invalid HEAD' '
echo 0000000000000000000000000000000000000000 >.git/HEAD &&
git checkout master --