From: Harald Nordgren Date: Thu, 21 May 2026 19:16:44 GMT Subject: Re: [PATCH v9 3/5] branch: add --prune-merged Message-ID: In-Reply-To: > While we want to clean up topic branches, we want to avoid cleaning up > branches like "master" which follow an upstream branch and therefore > look like they've been merged straight after they've been pulled. So I > think as well as checking that the local branch is merged into its > upstream branch, we want to check that the local branch is not pushed to > the upstream branch i.e. that branch@{upstream} != branch@{push}. This one I handle already by letting the default branch be guarded. Harald On Thu, May 21, 2026 at 11:46 AM Phillip Wood wrote: > > Hi Harald > > A couple more thoughts ... > > On 18/05/2026 16:27, Phillip Wood wrote: > > On 13/05/2026 20:34, Harald Nordgren via GitGitGadget wrote: > >> From: Harald Nordgren > >> > >> Delete the local branches that --forked would list, but > >> only those whose tip is reachable from their configured upstream > >> remote-tracking branch (branch..merge): the work has already > >> landed on the upstream it tracks, so the local copy is no longer > >> needed. > > While we want to clean up topic branches, we want to avoid cleaning up > branches like "master" which follow an upstream branch and therefore > look like they've been merged straight after they've been pulled. So I > think as well as checking that the local branch is merged into its > upstream branch, we want to check that the local branch is not pushed to > the upstream branch i.e. that branch@{upstream} != branch@{push}. That > should also avoid deleting newly created topic branches that match their > upstream (I think that's probably less likely to happen in practice as > I'd expect the branch to be checked out and therefore protected against > deletion). > > Also as this is a destructive operation (there is no way to restore a > deleted branch and its reflog) it would be good to have a --dry-run option. > > Thanks > > Phillip >