diff options
author | Dennis Kaarsemaker <dennis@kaarsemaker.net> | 2014-11-30 08:24:56 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-12-01 19:00:18 (GMT) |
commit | 3473ad0cf6c90917813aba978dada6c10352baaa (patch) | |
tree | a9da5a1234c09008f816b9d1e7e25a82882949e2 /t | |
parent | 6cfbdcb2ab70b238fca9b3811f5b58368fd077c6 (diff) | |
download | git-3473ad0cf6c90917813aba978dada6c10352baaa.zip git-3473ad0cf6c90917813aba978dada6c10352baaa.tar.gz git-3473ad0cf6c90917813aba978dada6c10352baaa.tar.bz2 |
checkout: don't require a work tree when checking out into a new one
For normal use cases, it does not make sense for 'checkout' to work on
a bare repository, without a worktree. But "checkout --to" is an
exception because it _creates_ a new worktree. Allow this option to
run on bare repositories.
People who check out from a bare repository should remember that
core.logallrefupdates is off by default and it should be turned back
on. `--to` cannot do this automatically behind the user's back because
some user may deliberately want no reflog.
For people interested in repository setup/discovery code,
is_bare_repository_cfg (aka "core.bare") is unchanged by this patch,
which means 'true' by default for bare repos. Fortunately when we get
the repo through a linked checkout, is_bare_repository_cfg is never
used. So all is still good.
[nd: commit message]
Signed-off-by: Dennis Kaarsemaker <dennis@kaarsemaker.net>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t2025-checkout-to.sh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/t/t2025-checkout-to.sh b/t/t2025-checkout-to.sh index e2db078..4bd1df4 100755 --- a/t/t2025-checkout-to.sh +++ b/t/t2025-checkout-to.sh @@ -81,4 +81,19 @@ test_expect_success 'not die on re-checking out current branch' ' ) ' +test_expect_success 'checkout --to from a bare repo' ' + ( + git clone --bare . bare && + cd bare && + git checkout --to ../there2 -b bare-master master + ) +' + +test_expect_success 'checkout from a bare repo without --to' ' + ( + cd bare && + test_must_fail git checkout master + ) +' + test_done |