Re: [PATCH v9 1/4] branch: move the deleteMerged opt-out check into a helper
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 20, 2026, 19:10 UTC
- Message-ID
- <xmqqmrr3pbdo.fsf@gitster.g>
- In-Reply-To
- <xmqqy0anpbzb.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 26 quoted lines
>> +static bool branch_opted_out(struct strbuf *key, const char *branch_name, >> + unsigned int flags) > > I am afraid that this is a somewhat selfish choice of a name that we > would regret later, as it assumes that "delete once it is merged > elsewhere" will continue to be the only destructive operation that > people may want to exempt some branches from. The configuration key > is named very specifically for that destructive operation (i.e., > setting branch.<name>.deleteMerged to false is a way to say "no, > even if it is merged, do not delete it"), so there is an impedance > mismatch. > > Either > > (1) naming this function to make it clear that this is about > opting out of the deleteMerged operation, or > > (2) naming this function to make it clear that this is about opting > out of ANY destructive operation, and renaming the > configuration key to something less specific than deleteMerged > so that the user will be saved from any new destructive > operation we may add in the future, e.g., "force update to what > upstream says", by setting the same configuration variable to > opt out of it (e.g., branch.<name>.noClobber=true) > > would work better, perhaps?
I forgot that there is a third option.
branch_opted_out("main", "deleteMerged") can be a boolean function that asks if the user is OK with subjecting the "main" branch to the "deleteMerged" operation (and the implementation may be done by checking the "branch.<name>.deleteMerged" configuration variable). The function must continue to be purely about "is the branch opted out of operation X" without adding X-specific side effects, if we go that route.
Thanks.