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

Re: [PATCH] branch: strip refs/heads/ from the --set-upstream-to hint

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 20, 2026, 19:51 UTC
Message-ID
<xmqq7bjcup46.fsf@gitster.g>
In-Reply-To
<pull.2268.git.1792458904027.gitgitgadget@gmail.com>
"tsukasa-ino via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 5 quoted lines
>     hint:   git branch --set-upstream-to=origin/refs/heads/feat
>
> The hint says origin/refs/heads/feat, but the correct name is
> origin/feat. Running the command as printed fails, because the full
> ref name is not a valid remote-tracking branch name here.
Good observation.  Thanks for noticing.
Show 13 quoted lines
> +test_expect_success '--set-upstream-to hint uses short remote-tracking branch name on locked config' '
> +	test_when_finished "git branch -D hint-local" &&
> +	test_when_finished "git update-ref -d refs/remotes/hintremote/hintbranch" &&
> +	test_config remote.hintremote.url . &&
> +	test_config remote.hintremote.fetch "+refs/heads/*:refs/remotes/hintremote/*" &&
> +	git update-ref refs/remotes/hintremote/hintbranch HEAD &&
> +	git branch hint-local &&
> +	test_when_finished "rm -f .git/config.lock" &&
> +	>.git/config.lock &&
> +	test_must_fail git -c core.configLockTimeout=0 \
> +		branch --set-upstream-to=hintremote/hintbranch hint-local 2>err &&
> +	test_grep "git branch --set-upstream-to=hintremote/hintbranch\$" err &&
> +	test_grep ! "refs/heads/" err

Perhaps it makes sense to also test that the suggested command line is accepted after all of the above?

> +'
Thanks.
Previous: tsukasa-ino via GitGitGadgetNext: Harald Nordgren
Message 2 of 9 in “branch: strip refs/heads/ from the --set-upstream-to hint”
  1. branch: strip refs/heads/ from the --set-upstream-to hinttsukasa-ino via GitGitGadget, Oct 20, 2026
  2. Junio C HamanoOct 20, 2026
  3. Harald NordgrenOct 21, 2026
  4. 0/3 checkout: finish switch when tracking config cannot be writtentsukasa-ino via GitGitGadget, Oct 21, 2026
  5. 1/3 branch: strip refs/heads/ from the --set-upstream-to hinttsukasa inoue via GitGitGadget, Oct 21, 2026
  6. 2/3 branch: return an error from setup_tracking()tsukasa inoue via GitGitGadget, Oct 21, 2026
  7. 3/3 checkout: finish switching when the tracking config cannot be writtentsukasa inoue via GitGitGadget, Oct 21, 2026
  8. Junio C HamanoOct 21, 2026
  9. 井上司Oct 22, 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.