From: Junio C Hamano <gitster@pobox.com>
To: "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,
Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>,
"D. Ben Knoble" <ben.knoble@gmail.com>,
Phillip Wood <phillip.wood123@gmail.com>,
Jasper Mayone <me@jaspermayone.com>,
Tuomas Ahola <taahol@utu.fi>,
Harald Nordgren <haraldnordgren@gmail.com>
Subject: Re: [PATCH v9 1/4] branch: move the deleteMerged opt-out check into a helper
Date: Fri, 20 Nov 2026 10:57:28 -0800 [thread overview]
Message-ID: <xmqqy0anpbzb.fsf@gitster.g> (raw)
In-Reply-To: <37ef7636e069ce528728c43cd79f678293e0d035.1795184664.git.gitgitgadget@gmail.com> (Harald Nordgren via GitGitGadget's message of "Fri, 20 Nov 2026 14:24:21 +0000")
"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Harald Nordgren <haraldnordgren@gmail.com>
>
> A later commit adds "git branch --delete-integrated", which deletes
> branches whose tips are not reachable from their upstream. Those must
> honor branch.<name>.deleteMerged=false as well. Move the check into a
> helper so it can be used in both places.
>
> No change in behavior.
>
> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
> ---
> builtin/branch.c | 32 +++++++++++++++++++-------------
> 1 file changed, 19 insertions(+), 13 deletions(-)
>
> diff --git a/builtin/branch.c b/builtin/branch.c
> index b536b619bb..2c1a8b8395 100644
> --- a/builtin/branch.c
> +++ b/builtin/branch.c
> @@ -824,6 +824,23 @@ static int branch_pushes_to_upstream(struct branch *branch,
> return ret;
> }
>
> +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?
> +{
> + int opt_out;
> +
> + strbuf_reset(key);
> + strbuf_addf(key, "branch.%s.deletemerged", branch_name);
> + if (repo_config_get_bool(the_repository, key->buf, &opt_out) ||
> + opt_out)
> + return false;
The lack of a key, or the key explicitly set to true, will cause
this function to say "no, this branch is not opted out", which
smells like a risky default to me.
Putting the devil's advocate hat on (because I understand why the
inventor of a feature wants it to apply as widely as possible),
shouldn't this be the other way around? If the user does not
explicitly say "I am fine losing this once we are done", shouldn't
we be treating it as precious?
next prev parent reply other threads:[~2026-11-20 18:57 UTC|newest]
Thread overview: 99+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 7:30 [PATCH] branch: let --delete-merged find squash merged branches Harald Nordgren via GitGitGadget
2026-09-29 7:46 ` Kristoffer Haugsbakk
2026-09-29 7:52 ` Harald Nordgren
2026-09-29 8:08 ` Kristoffer Haugsbakk
2026-09-29 11:18 ` D. Ben Knoble
2026-09-29 13:31 ` Kristoffer Haugsbakk
2026-09-29 11:26 ` D. Ben Knoble
2026-09-29 13:44 ` Harald Nordgren
2026-09-29 13:52 ` Harald Nordgren
2026-09-29 15:28 ` D. Ben Knoble
2026-09-29 18:34 ` Harald Nordgren
2026-10-04 9:54 ` Phillip Wood
2026-10-04 22:28 ` Harald Nordgren
2026-10-08 15:25 ` Phillip Wood
2026-10-08 18:42 ` Harald Nordgren
2026-10-09 8:16 ` Kristoffer Haugsbakk
2026-10-09 11:11 ` Harald Nordgren
2026-10-09 11:18 ` Harald Nordgren
2026-10-09 13:40 ` Phillip Wood
2026-10-09 13:37 ` Phillip Wood
2026-10-09 15:27 ` Harald Nordgren
2026-10-08 17:51 ` D. Ben Knoble
2026-10-09 13:34 ` Phillip Wood
2026-10-11 9:41 ` [PATCH v2 0/2] " Harald Nordgren via GitGitGadget
2026-10-11 9:41 ` [PATCH v2 1/2] " Harald Nordgren via GitGitGadget
2026-10-11 9:41 ` [PATCH v2 2/2] branch: add --no-squashed to skip the squash search Harald Nordgren via GitGitGadget
2026-10-12 0:30 ` [PATCH v2 0/2] branch: let --delete-merged find squash merged branches Junio C Hamano
2026-10-12 9:50 ` Phillip Wood
2026-10-12 14:31 ` Harald Nordgren
2026-10-12 16:50 ` Junio C Hamano
2026-10-12 17:44 ` Harald Nordgren
2026-10-13 2:23 ` Junio C Hamano
2026-10-17 22:23 ` Harald Nordgren
2026-10-19 4:40 ` Jasper Mayone
2026-10-18 15:09 ` Harald Nordgren
2026-10-12 12:41 ` Harald Nordgren
2026-10-12 15:49 ` D. Ben Knoble
2026-10-21 12:28 ` [PATCH v3 0/3] " Harald Nordgren via GitGitGadget
2026-10-21 12:28 ` [PATCH v3 1/3] branch: move the deleteMerged opt-out check into a helper Harald Nordgren via GitGitGadget
2026-10-21 12:28 ` [PATCH v3 2/3] branch: let --delete-merged find rebase merged branches Harald Nordgren via GitGitGadget
2026-10-21 12:28 ` [PATCH v3 3/3] branch: add --squashed to find squash " Harald Nordgren via GitGitGadget
2026-10-21 17:35 ` [PATCH v3 0/3] branch: let --delete-merged " Jasper Mayone
2026-10-21 18:51 ` Harald Nordgren
2026-10-22 12:55 ` D. Ben Knoble
2026-10-22 14:41 ` Harald Nordgren
2026-10-22 5:49 ` Junio C Hamano
2026-10-22 7:18 ` Harald Nordgren
2026-10-22 16:33 ` Junio C Hamano
2026-10-22 16:57 ` Junio C Hamano
2026-10-22 17:31 ` Harald Nordgren
2026-10-22 17:44 ` Jasper Mayone
2026-10-22 17:56 ` Junio C Hamano
2026-10-23 9:07 ` Harald Nordgren
2026-10-22 17:44 ` Harald Nordgren
2026-10-22 12:59 ` D. Ben Knoble
2026-10-26 8:33 ` [PATCH v4 0/4] " Harald Nordgren via GitGitGadget
2026-10-26 8:33 ` [PATCH v4 1/4] branch: move the deleteMerged opt-out check into a helper Harald Nordgren via GitGitGadget
2026-10-26 8:33 ` [PATCH v4 2/4] branch: let delete_branches() name where a branch landed Harald Nordgren via GitGitGadget
2026-10-26 8:33 ` [PATCH v4 3/4] branch: add --delete-integrated to delete rebase and squash merged branches Harald Nordgren via GitGitGadget
2026-10-26 8:33 ` [PATCH v4 4/4] branch: let --delete-integrated find branches merged onto changed files Harald Nordgren via GitGitGadget
2026-10-29 4:30 ` [PATCH v4 0/4] branch: let --delete-merged find squash merged branches Jasper Mayone
2026-10-29 8:30 ` Harald Nordgren
2026-10-30 10:52 ` [PATCH v5 " Harald Nordgren via GitGitGadget
2026-10-30 10:52 ` [PATCH v5 1/4] branch: move the deleteMerged opt-out check into a helper Harald Nordgren via GitGitGadget
2026-10-30 10:53 ` [PATCH v5 2/4] branch: let delete_branches() name where a branch landed Harald Nordgren via GitGitGadget
2026-10-30 10:53 ` [PATCH v5 3/4] branch: add --delete-integrated to delete rebase and squash merged branches Harald Nordgren via GitGitGadget
2026-10-30 19:14 ` Junio C Hamano
2026-10-31 8:09 ` Harald Nordgren
2026-10-30 10:53 ` [PATCH v5 4/4] branch: let --delete-integrated find branches merged onto changed files Harald Nordgren via GitGitGadget
2026-10-30 19:25 ` Junio C Hamano
2026-10-31 8:10 ` Harald Nordgren
2026-11-01 8:22 ` [PATCH v6 0/4] branch: let --delete-merged find squash merged branches Harald Nordgren via GitGitGadget
2026-11-01 8:22 ` [PATCH v6 1/4] branch: move the deleteMerged opt-out check into a helper Harald Nordgren via GitGitGadget
2026-11-01 8:22 ` [PATCH v6 2/4] branch: let delete_branches() name where a branch landed Harald Nordgren via GitGitGadget
2026-11-01 8:22 ` [PATCH v6 3/4] branch: add --delete-integrated to delete rebase and squash merged branches Harald Nordgren via GitGitGadget
2026-11-01 8:22 ` [PATCH v6 4/4] branch: let --delete-integrated find branches merged onto changed files Harald Nordgren via GitGitGadget
2026-11-11 8:30 ` Harald Nordgren
2026-11-11 15:27 ` Jasper Mayone
2026-11-14 11:08 ` Harald Nordgren
2026-11-14 13:24 ` [PATCH v7 0/4] branch: let --delete-merged find squash merged branches Harald Nordgren via GitGitGadget
2026-11-14 13:24 ` [PATCH v7 1/4] branch: move the deleteMerged opt-out check into a helper Harald Nordgren via GitGitGadget
2026-11-14 13:24 ` [PATCH v7 2/4] branch: let delete_branches() name where a branch landed Harald Nordgren via GitGitGadget
2026-11-14 13:24 ` [PATCH v7 3/4] branch: add --delete-integrated to delete rebase and squash merged branches Harald Nordgren via GitGitGadget
2026-11-14 13:24 ` [PATCH v7 4/4] branch: let --delete-integrated find branches merged onto changed files Harald Nordgren via GitGitGadget
2026-11-14 17:14 ` Tuomas Ahola
2026-11-16 16:16 ` Jasper Mayone
2026-11-17 13:24 ` [PATCH v8 0/4] branch: let --delete-merged find squash merged branches Harald Nordgren via GitGitGadget
2026-11-17 13:24 ` [PATCH v8 1/4] branch: move the deleteMerged opt-out check into a helper Harald Nordgren via GitGitGadget
2026-11-17 13:24 ` [PATCH v8 2/4] branch: let delete_branches() name where a branch landed Harald Nordgren via GitGitGadget
2026-11-17 13:24 ` [PATCH v8 3/4] branch: add --delete-integrated to delete rebase and squash merged branches Harald Nordgren via GitGitGadget
2026-11-17 13:24 ` [PATCH v8 4/4] branch: let --delete-integrated find branches merged onto changed files Harald Nordgren via GitGitGadget
2026-11-18 23:05 ` Junio C Hamano
2026-11-19 15:14 ` Jasper Mayone
2026-11-20 14:24 ` [PATCH v9 0/4] branch: let --delete-merged find squash merged branches Harald Nordgren via GitGitGadget
2026-11-20 14:24 ` [PATCH v9 1/4] branch: move the deleteMerged opt-out check into a helper Harald Nordgren via GitGitGadget
2026-11-20 18:57 ` Junio C Hamano [this message]
2026-11-20 14:24 ` [PATCH v9 2/4] branch: let delete_branches() name where a branch landed Harald Nordgren via GitGitGadget
2026-11-20 14:24 ` [PATCH v9 3/4] branch: add --delete-integrated to delete rebase and squash merged branches Harald Nordgren via GitGitGadget
2026-11-20 14:24 ` [PATCH v9 4/4] branch: let --delete-integrated find branches merged onto changed files Harald Nordgren via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqy0anpbzb.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=ben.knoble@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=haraldnordgren@gmail.com \
--cc=kristofferhaugsbakk@fastmail.com \
--cc=me@jaspermayone.com \
--cc=phillip.wood123@gmail.com \
--cc=taahol@utu.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox