Re: [PATCH v9 3/5] branch: add --prune-merged <remote>
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- May 22, 2026, 09:47 UTC
- Message-ID
- <6ae90274-3fbb-4d2a-b0f4-cd9260e4d6b3@gmail.com>
- In-Reply-To
- <CAHwyqnVhhwT80Ao+7QLUAsTnUJaN5vE=ZiaxeqF3rYxxiD_Qww@mail.gmail.com>
Hi Harald
On 21/05/2026 20:16, Harald Nordgren wrote:
Show 8 quoted lines
>> 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.I used "master" as an example of a branch name above. There is no guarantee that a remote even defines a default branch, let alone that there is only one local branch where the its upstream and push destinations match. I don't see how you can avoid checking that the branch pushes to a different ref than its upstream and still be safe.
I'm going to be off the list from now until the week after next, I'll catch up with this thread when I'm back on line.
Thanks
Phillip
Show 38 quoted lines
>
> Harald
>
> On Thu, May 21, 2026 at 11:46 AM Phillip Wood <phillip.wood123@gmail.com> 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 <haraldnordgren@gmail.com>
>>>>
>>>> Delete the local branches that --forked <remote> would list, but
>>>> only those whose tip is reachable from their configured upstream
>>>> remote-tracking branch (branch.<name>.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
>>
>