зеркало из https://github.com/microsoft/git.git
Merge branch 'ef/checkout-empty'
Running "git checkout" on an unborn branch used to corrupt HEAD (regression in 1.7.10); this makes it error out. By Erik Faye-Lund * ef/checkout-empty: checkout: do not corrupt HEAD on empty repo
This commit is contained in:
Коммит
a735b79c63
|
@ -1092,7 +1092,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
|
||||||
if (opts.writeout_stage)
|
if (opts.writeout_stage)
|
||||||
die(_("--ours/--theirs is incompatible with switching branches."));
|
die(_("--ours/--theirs is incompatible with switching branches."));
|
||||||
|
|
||||||
if (!new.commit) {
|
if (!new.commit && opts.new_branch) {
|
||||||
unsigned char rev[20];
|
unsigned char rev[20];
|
||||||
int flag;
|
int flag;
|
||||||
|
|
||||||
|
|
|
@ -46,4 +46,15 @@ test_expect_success 'checking out another branch from unborn state' '
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'checking out in a newly created repo' '
|
||||||
|
test_create_repo empty &&
|
||||||
|
(
|
||||||
|
cd empty &&
|
||||||
|
git symbolic-ref HEAD >expect &&
|
||||||
|
test_must_fail git checkout &&
|
||||||
|
git symbolic-ref HEAD >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Загрузка…
Ссылка в новой задаче