git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] checkout: tell "parse_remote_branch" which command is calling it

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 27, 2026, 21:22 UTC
Message-ID
<xmqq343qg38n.fsf@gitster.g>
In-Reply-To
<fa7f1648-3cf6-4e5f-bee9-fb5e8700d01d@app.fastmail.com>
"Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com> writes:
Show 10 quoted lines
>> +	# 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".

Show 10 quoted lines
>> +	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.
Previous: Kristoffer HaugsbakkNext: Junio C Hamano
Message 5 of 11 in “Improving advise messages from "switch"”
  1. 0/2 Improving advise messages from "switch"Junio C Hamano, Jan 27, 2026
  2. 1/2 checkout: pass program-readable token to unified "main"Junio C Hamano, Jan 27, 2026
  3. 2/2 checkout: tell "parse_remote_branch" which command is calling itJunio C Hamano, Jan 27, 2026
  4. Kristoffer HaugsbakkJan 27, 2026
  5. Junio C HamanoJan 27, 2026
  6. 0/2 Improving advise messages from "switch"Junio C Hamano, Jan 29, 2026
  7. 1/2 checkout: pass program-readable token to unified "main"Junio C Hamano, Jan 29, 2026
  8. Patrick SteinhardtFeb 6, 2026
  9. Junio C HamanoFeb 19, 2026
  10. 2/2 checkout: tell "parse_remote_branch" which command is calling itJunio C Hamano, Jan 29, 2026
  11. Patrick SteinhardtFeb 6, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.