Re: [PATCH v19 5/7] branch: add --delete-merged <branch>

Phillip Wood <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <[email protected]>
On 19/07/2026 20:22, Junio C Hamano wrote:
> Harald Nordgren <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.