From: Junio C Hamano Date: Thu, 22 Oct 2026 05:49:18 GMT Subject: Re: [PATCH v3 0/3] branch: let --delete-merged find squash merged branches Message-ID: In-Reply-To: "Harald Nordgren via GitGitGadget" writes: > This series finds the first upstream commit since the fork point that has > the branch's version of every file the branch changed, comparing only object > ids. With --squashed, a file that upstream also changed counts when merging > the branch's version into upstream's leaves it unchanged. Timed on my clone > with 65 branches, this takes 0.5s. It would be very surprising for the unsuspecting users to loosen the behaviour of "--delete-merged" like this series does. As requested elsewhere [*], do not change the behaviour of the "--delete-merged" when no other "please make it looser" option requests otherwise. * https://lore.kernel.org/git/20261019044005.99247-1-me@jaspermayone.com/ The attached new test illustrates the extent of damage. We add a file on a private branch while the upstream adds two files, one of which has an identical contents to our file, under author identity different from ours. If we run "--delete-merged" in our repository, we should not lose our branch that we never pushed, or asked them to pull, or anything. But when applied on top of this series, we do. With the following applied on top of the series, with all changes to builtin/branch.c reverted, it passes. Of course, later tests that assumes the looser criteria is used without an explicit opt-in will fail with your code changes reverted, but that is to be expected. t/t3200-branch.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git c/t/t3200-branch.sh w/t/t3200-branch.sh index f3980106fa..adbcf937b5 100755 --- c/t/t3200-branch.sh +++ w/t/t3200-branch.sh @@ -1925,6 +1925,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 && + test_write_lines 5 6 7 >elif && + git add file elif && + git commit -m "add file and elif" && + git push origin unrelated-topic && + git checkout --detach + ) && + ( + cd upstream && + git checkout next && + test_write_lines 1 2 3 4 >file && + git add file && + git commit --author="unrelated user " \ + -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 && (