From: Harald Nordgren Date: Wed, 21 Oct 2026 07:05:12 GMT Subject: Re: [PATCH] branch: strip refs/heads/ from the --set-upstream-to hint Message-ID: In-Reply-To: > When git switch fails to write the tracking config, it prints a hint > with the command to set the upstream by hand. For example, if > .git/config.lock exists: > > error: could not lock config file .git/config: File exists > error: unable to write upstream branch configuration > hint: > hint: After fixing the error cause you may try to fix up > hint: the remote tracking information by invoking: > 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. Very nice find! > +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 > +' Would be good to test the full multiline hint message. After all, it's the point of the topic. Right now, you are asserting that the correct form 'hintremote/hintbranch' works, but we want to make sure that the hint actually gives that. Harald