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.