Git development
 help / color / mirror / Atom feed
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 3/4] branch: add --delete-integrated to delete rebase and squash merged branches
Date: Fri, 20 Nov 2026 12:02:38 -0800	[thread overview]
Message-ID: <xmqqzev3nue9.fsf@gitster.g> (raw)
In-Reply-To: <1f922a00344f6b86dcc0054b3117f1bbad247810.1795184664.git.gitgitgadget@gmail.com> (Harald Nordgren via GitGitGadget's message of "Fri, 20 Nov 2026 14:24:23 +0000")

"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:

> Subject: Re: [PATCH v9 3/4] branch: add --delete-integrated to delete rebase and squash merged branches

The title is on a tad overlong side.

"rebase and squash merged branches" sounds awkward.  If a branch got
intergrated by squash merging is called "squash-merged branch",
shouldn't a branch that underwent "git rebase" to sit on top of the
upstream be called "rebased branch"?

IOW, "rebased or squash-merged branches"?

> diff --git a/Documentation/config/branch.adoc b/Documentation/config/branch.adoc
> index c2acd89c99..be9b296bda 100644
> --- a/Documentation/config/branch.adoc
> +++ b/Documentation/config/branch.adoc
> @@ -106,7 +106,7 @@ for details).
>  
>  `branch.<name>.deleteMerged`::
>  	If set to `false`, branch _<name>_ is exempt from
> -	`git branch --delete-merged`.  Useful for a topic branch you
> -	intend to develop further after an initial round has been
> -	merged upstream.  Defaults to true.  Explicit deletion via
> -	`git branch -d` is unaffected.
> +	`git branch --delete-merged` and `--delete-integrated`.  Useful
> +	for a topic branch you intend to develop further after an
> +	initial round has been merged upstream.  Defaults to true.
> +	Explicit deletion via `git branch -d` is unaffected.

Does the deleteMerged configuration variable affect the behavior of
the "--delete-integrated" option?  Knowing how the feature evolved,
it is understandable to me, but I suspect it won't be natural for
mere mortals.

Perhaps a single .deleteDone variable that governs both would be
more future-proof, as it anticipates that we may find other ways a
branch becomes "done", other than by getting merged or otherwise
integrated, and when that happens this variable will also deal with
such a new destructive operation.

> diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
> index 44336eef81..54461e90b3 100755
> --- a/t/t3200-branch.sh
> +++ b/t/t3200-branch.sh
> @@ -1963,6 +1963,39 @@ check_branches () {
>  	test_cmp expect actual
>  }
>  
> +test_expect_success '--delete-merged does not delete unrelated branches' '
> +	setup_repo_for_delete_merged &&
> +	(
> +		cd repo &&
> +		git checkout -b unrelated-topic --track origin/next &&
> +		test_write_lines 1 2 3 4 >file &&
> +		git add file &&
> +		git commit -m "add file" &&
> +		git push origin unrelated-topic &&
> +		git checkout --detach
> +	) &&
> +	(
> +		cd upstream &&
> +		git checkout next &&
> +		test_write_lines 1 2 3 4 >file &&
> +		test_write_lines 5 6 7 >elif &&
> +		git add file elif &&
> +		git commit --author="unrelated user <uu@example.com>" \
> +			-m "unrelated commit adding an identical file" &&
> +		git checkout main
> +	) &&
> +	(
> +		cd repo &&
> +		git fetch origin &&
> +		git branch --delete-merged origin/next >actual 2>&1 &&
> +		test_must_be_empty actual &&
> +		check_branches <<-\EOF
> +		main
> +		unrelated-topic
> +		EOF
> +	)
> +'
> +
>  test_expect_success '--delete-merged keeps cloned main without explicit push configuration' '
>  	setup_repo_for_delete_merged &&
>  	(
> @@ -2017,6 +2050,143 @@ test_expect_success '--delete-merged deletes only selected merged branches' '
>  	)
>  '
>  
> +push_topic () {
> +	branch=$1 &&
> +	shift &&
> +	(
> +		cd repo &&
> +		git checkout -b "$branch" --track origin/next &&
> +		for commit in "$@"
> +		do
> +			test_commit "$commit" || return 1
> +		done &&
> +		git push origin "$branch" &&
> +		git checkout --detach
> +	)
> +}
> +
> +squash_merge_upstream () {
> +	(
> +		cd upstream &&
> +		git checkout next &&
> +		git merge --squash "$1" &&
> +		git commit -m "Squash merge of $1" &&
> +		git checkout main
> +	)
> +}
> +
> +rebase_merge_upstream () {
> +	(
> +		cd upstream &&
> +		git rebase next "$1" &&
> +		git checkout next &&
> +		git merge --ff-only "$1" &&
> +		git checkout main
> +	)
> +}
> +
> +test_expect_success '--delete-integrated deletes a rebase merged branch' '
> +	setup_repo_for_delete_merged &&
> +	push_topic rebased rebased-one rebased-two &&
> +	(
> +		cd upstream &&
> +		git checkout next &&
> +		test_commit before-rebase &&
> +		git checkout main
> +	) &&
> +	rebase_merge_upstream rebased &&
> +	landed=$(git -C upstream rev-parse --short next) &&
> +	(
> +		cd repo &&
> +		git fetch origin &&
> +		sha=$(git rev-parse --short rebased) &&
> +
> +		git branch --delete-integrated origin/next >actual 2>&1 &&
> +		echo "Deleted branch rebased (was $sha, landed as $landed)." >expect &&
> +		test_cmp expect actual &&
> +
> +		check_branches <<-\EOF
> +		main
> +		EOF
> +	)
> +'
> +
> +test_expect_success '--delete-integrated deletes a squash merged branch' '
> +	setup_repo_for_delete_merged &&
> +	push_topic squashed squashed-one squashed-two &&
> +	push_topic partial lands-upstream stays-local &&
> +	squash_merge_upstream partial~1 &&
> +	squash_merge_upstream squashed &&
> +	squash=$(git -C upstream rev-parse --short next) &&
> +	(
> +		cd repo &&
> +		git fetch origin &&
> +		sha=$(git rev-parse --short squashed) &&
> +
> +		git branch --delete-integrated origin/next >actual 2>&1 &&
> +		echo "Deleted branch squashed (was $sha, landed as $squash)." >expect &&
> +		test_cmp expect actual &&
> +
> +		check_branches <<-\EOF
> +		main
> +		partial
> +		EOF
> +	)
> +'
> +
> +test_expect_success '--delete-integrated deletes a squash merged branch that was reverted' '
> +	setup_repo_for_delete_merged &&
> +	push_topic reverted reverted-work &&
> +	squash_merge_upstream reverted &&
> +	squash=$(git -C upstream rev-parse --short next) &&
> +	(
> +		cd upstream &&
> +		git checkout next &&
> +		git revert --no-edit HEAD &&
> +		git checkout main
> +	) &&
> +	(
> +		cd repo &&
> +		git fetch origin &&
> +		sha=$(git rev-parse --short reverted) &&
> +
> +		git branch --delete-integrated origin/next >actual 2>&1 &&
> +		echo "Deleted branch reverted (was $sha, landed as $squash)." >expect &&
> +		test_cmp expect actual &&
> +
> +		check_branches <<-\EOF
> +		main
> +		EOF
> +	)
> +'
> +
> +test_expect_success '--delete-integrated reports a merge plainly next to an unmerged branch' '
> +	setup_repo_for_delete_merged &&
> +	push_topic a-unmerged unmerged-work &&
> +	push_topic b-merged merged-work &&
> +	(
> +		cd upstream &&
> +		git checkout next &&
> +		test_commit upstream-work &&
> +		git merge --no-ff b-merged &&
> +		git checkout main
> +	) &&
> +	(
> +		cd repo &&
> +		git fetch origin &&
> +		sha=$(git rev-parse --short b-merged) &&
> +
> +		git branch --delete-integrated origin/next >actual 2>&1 &&
> +		echo "Deleted branch b-merged (was $sha)." >expect &&
> +		test_cmp expect actual &&
> +
> +		check_branches <<-\EOF
> +		a-unmerged
> +		main
> +		EOF
> +	)
> +'

Does "--dry-run --delete-integrated" combination have test coverage?
If not shouldn't it?

Does opting out of "--delete-integrated" feature by setting
branch.<name>.deleteMerged to false have test coverage?
If not shouldn't it?

>  test_expect_success '--delete-merged keeps main despite a different default push remote' '
>  	setup_repo_for_delete_merged &&
>  	create_merged_branch on-next &&
> @@ -2216,4 +2386,10 @@ test_expect_success '--dry-run without --delete-merged is rejected' '
>  	test_grep "requires --delete-merged" err
>  '

It now requires either --delete-merged or --delete-integrated.
At least, updating the expected message in the test we can see would
be helpful.  

Having said that, I do not agree with the design to make "--dry-run"
require anything.

If "git branch delete master" is run, and 'master' is checked out,
it would error out.  "git branch delete --dry-run master" should say
"we would not let you delete the currently checked out branch" the
same way and exit, no?


> +test_expect_success '--delete-integrated cannot be combined with --delete-merged' '
> +	test_must_fail git -C forked branch --delete-merged origin/next \
> +		--delete-integrated origin/next 2>err &&
> +	test_grep "cannot be used together" err
> +'

Good.  You added die-for-incompatible-opt to make them incompatible.

Also do we want to ensure "--quiet" does what it is designed to do?
I do not think I saw anything added to t3200 by this series that
mentioned the option.

Thanks.

  reply	other threads:[~2026-11-20 20:02 UTC|newest]

Thread overview: 103+ 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
2026-11-20 19:10       ` Junio C Hamano
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 19:32     ` Junio C Hamano
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 20:02     ` Junio C Hamano [this message]
2026-11-20 14:24   ` [PATCH v9 4/4] branch: let --delete-integrated find branches merged onto changed files Harald Nordgren via GitGitGadget
2026-11-20 20:08     ` Junio C Hamano

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=xmqqzev3nue9.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