From: Phillip Wood Date: Mon, 13 Jul 2026 16:39:56 GMT Subject: Re: [PATCH v18 5/7] branch: add --delete-merged Message-ID: <279e6d69-191b-437a-b1b1-ecd879343f3d@gmail.com> In-Reply-To: <5212d968-6121-466c-8225-36b4bad6b211@gmail.com> Hi Harald On 13/07/2026 16:39, Phillip Wood wrote: > On 11/07/2026 20:36, Harald Nordgren wrote: >> >> Digging more into this, probably the most elegant solution is to >> replace mainline with main, but then also do this: >> >>      git config branch.main.pushRemote origin >> >> This exposes something that I don't love about this feature, > > by "this feature" do you mean "git branch --delete-merged"? > >> which is >> that when using a pushDefault (like we do in the tests with 'git >> config remote.pushDefault fork') if not adding a special case for the >> main/master branch (like 'git config branch.main.pushRemote origin'), >> then it will get cleaned up as a forked branch. > > Oh, so because the default push remote is not "origin" we need to > override that for the branches that we do push to "origin". That's a > pain, but even if we did add a special case for the default branch, it > would not protect other branches like "next" and "seen". Thinking about this a bit more, rather than protecting branches where $branch@{push} == $branch@{upstream}, perhaps we should be protecting branches that are merged into their upstream but git push branch.$branch.remote $branch would update $branch@{upstream}. So we'd apply the push refspec to the branch name, then apply the fetch refspec to that and check the result did not match the name of the upstream branch. Does that make sense? Thanks Phillip