1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-12 15:16:09 +02:00

Merge branch 'jc/checkout-detach-wo-tracking-report' into next

"git checkout/switch --detach foo", after switching to the detached
HEAD state, gave the tracking information for the 'foo' branch,
which was pointless.

* jc/checkout-detach-wo-tracking-report:
  checkout: omit "tracking" information on a detached HEAD
This commit is contained in:
Junio C Hamano 2024-04-04 14:59:00 -07:00
commit 161eca247d
2 changed files with 6 additions and 2 deletions

View File

@ -1035,7 +1035,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);
}

View File

@ -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' '