diff options
-rw-r--r-- | builtin/checkout.c | 3 | ||||
-rwxr-xr-x | t/t2020-checkout-detach.sh | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c index 2e8b0d18f4..26e1a64569 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -1030,7 +1030,8 @@ static void update_refs_for_switch(const struct checkout_opts *opts, remove_branch_state(the_repository, !opts->quiet); strbuf_release(&msg); if (!opts->quiet && - (new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) + !opts->force_detach && + (new_branch_info->path || !strcmp(new_branch_info->name, "HEAD"))) report_tracking(new_branch_info); } diff --git a/t/t2020-checkout-detach.sh b/t/t2020-checkout-detach.sh index bce284c297..8d90d02850 100755 --- a/t/t2020-checkout-detach.sh +++ b/t/t2020-checkout-detach.sh @@ -176,7 +176,10 @@ test_expect_success 'tracking count is accurate after orphan check' ' git config branch.child.merge refs/heads/main && git checkout child^ && git checkout child >stdout && - test_cmp expect stdout + test_cmp expect stdout && + + git checkout --detach child >stdout && + test_grep ! "can be fast-forwarded\." stdout ' test_expect_success 'no advice given for explicit detached head state' ' |