Re: [PATCH v19 5/7] branch: add --delete-merged <branch>
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Jul 19, 2026, 19:42 UTC
- Message-ID
- <9b9b9a2c-dd0f-44f8-b80e-565eed9a55a8@gmail.com>
- In-Reply-To
- <xmqqik6an5t3.fsf@gitster.g>
On 19/07/2026 20:22, Junio C Hamano wrote:
Show 24 quoted lines
> Harald Nordgren <haraldnordgren@gmail.com> writes: > >> I think I can fix this with >> >> ``` >> -+ if (strset_contains(data->deletable, ref->name)) >> ++ if (strset_contains(data->deletable, ref->name) || >> ++ strset_contains(data->spared, ref->name)) >> ``` >> >> I used your example to write a test about it as well. >> >> >> Harald > > I do not claim that the single example I gave covers all the issues > that arise from failing to analyze the dependency graph, or from > attempting to solve the problem sequentially, which makes the > solution depend on the order in which branches are visited. > > I have a suspicion that it may be unavoidable to employ a multi-pass > approach that iteratively identifies all branches transitively > needed by any surviving branch, though that is merely a hunch, > unsupported by any proof.
I think it would certainly be easier to reason about if we did not mutate data->deletable in spare_stacked_base() in removed the spared branches with
strset_for_each_entry(&spared, &iter, entry) strset_remove(&deletable, entry);
after the call to refs_for_each_branch_ref() returns in spare_stacked_branches().
I'll try and have a proper look at this iteration in the comming week.
Thanks
Phillip