Browse Source

Merge branch 'jc/maint-do-not-switch-to-non-commit' into maint

* jc/maint-do-not-switch-to-non-commit:
  git checkout: do not allow switching to a tree-ish that is not a commit
maint
Junio C Hamano 16 years ago
parent
commit
687004b512
  1. 2
      builtin-checkout.c
  2. 4
      t/t2011-checkout-invalid-head.sh

2
builtin-checkout.c

@ -681,8 +681,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) @@ -681,8 +681,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);

4
t/t2011-checkout-invalid-head.sh

@ -10,6 +10,10 @@ test_expect_success 'setup' ' @@ -10,6 +10,10 @@ test_expect_success 'setup' '
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 --

Loading…
Cancel
Save