From: Junio C Hamano <gitster@pobox.com>
To: "Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com>
Cc: git@vger.kernel.org, "Simon Cheng" <cyqsimon@gmail.com>
Subject: Re: [PATCH 2/2] checkout: tell "parse_remote_branch" which command is calling it
Date: Tue, 27 Jan 2026 13:22:32 -0800 [thread overview]
Message-ID: <xmqq343qg38n.fsf@gitster.g> (raw)
In-Reply-To: <fa7f1648-3cf6-4e5f-bee9-fb5e8700d01d@app.fastmail.com> (Kristoffer Haugsbakk's message of "Tue, 27 Jan 2026 21:35:43 +0100")
"Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com> writes:
>> + # DWIM
>> + test_must_fail git checkout trunk 2>hint &&
>> + test_grep "hint: *git checkout --track" hint &&
>> + test_grep ! "hint: *git switch --track" hint &&
>> +
>> + { git update-ref -d refs/heads/trunk || :; } &&
>
> I don’t understand what the purpose of this is after `git checkout` but
> before `git switch`. I can delete it and the test still passes. Is it
> post-test cleanup?
Just in case "git checkout trunk" that was expected to fail still
creates the 'trunk' branch by a bug. I do not want the failure of
the next "git switch trunk" to be due to "hey, you already have a
local branch of that name", and make sure the failure is from "you
have two remotes with trunk, and I cannot tell which one you meant".
>> + test_must_fail git switch trunk 2>hint &&
>> + test_grep ! "hint: *git checkout --track" hint &&
>> + test_grep "hint: *git switch --track" hint
>> +'
>
> Maybe just the positive greps are enough. I read these a few times
> because I thought the order was wrong, i.e. that `hint` was overwritten
> before it got tested. The regression that they test are unlikely and
> these negative greps might not make immediate sense for future
> readers. I dunno.
Possibly. These tests to expect concrete strings in the output are
already familiar with how these output strings are built, so they
should know that when 'git checkout --track' appears, it is very
unlikely that 'git switch --track' would appear there, for example.
Thanks.
next prev parent reply other threads:[~2026-01-27 21:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-27 19:29 [PATCH 0/2] Improving advise messages from "switch" Junio C Hamano
2026-01-27 19:29 ` [PATCH 1/2] checkout: pass program-readable token to unified "main" Junio C Hamano
2026-01-27 19:29 ` [PATCH 2/2] checkout: tell "parse_remote_branch" which command is calling it Junio C Hamano
2026-01-27 20:35 ` Kristoffer Haugsbakk
2026-01-27 21:22 ` Junio C Hamano [this message]
2026-01-29 19:06 ` [PATCH v2 0/2] Improving advise messages from "switch" Junio C Hamano
2026-01-29 19:06 ` [PATCH v2 1/2] checkout: pass program-readable token to unified "main" Junio C Hamano
2026-02-06 16:05 ` Patrick Steinhardt
2026-02-19 22:21 ` Junio C Hamano
2026-01-29 19:06 ` [PATCH v2 2/2] checkout: tell "parse_remote_branch" which command is calling it Junio C Hamano
2026-02-06 16:05 ` Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq343qg38n.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=cyqsimon@gmail.com \
--cc=git@vger.kernel.org \
--cc=kristofferhaugsbakk@fastmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox