From: Harald Nordgren via GitGitGadget Date: Tue, 09 Jun 2026 10:11:51 GMT Subject: [PATCH v14 0/6] branch: prune-merged Message-ID: In-Reply-To: * Fixed a git branch -d -r regression (broke t5404/t5505/t5514): the remotes path set a local force but not the DELETE_BRANCH_FORCE bit that check_branch_commit() reads, so it wrongly ran the merge check. * Made flags the single source of truth in delete_branches() so the bit and the derived locals can't disagree. * Works locally, but GitHub CI has problems that are there for other branches too, hopefully not related (https://github.com/git/git/pull/2285). Harald Nordgren (6): branch: add --forked filter for --list mode branch: let delete_branches warn instead of error on bulk refusal branch: prepare delete_branches for a bulk caller branch: add --prune-merged branch: add branch..pruneMerged opt-out branch: add --dry-run for --prune-merged Documentation/config/branch.adoc | 7 + Documentation/git-branch.adoc | 41 +++- builtin/branch.c | 186 +++++++++++++--- ref-filter.c | 70 ++++++ ref-filter.h | 10 + t/t3200-branch.sh | 367 +++++++++++++++++++++++++++++++ 6 files changed, 653 insertions(+), 28 deletions(-) base-commit: 600fe743028cbfb640855f659e9851522214bc0b Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2285%2FHaraldNordgren%2Ffetch-prune-local-branches-v14 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2285/HaraldNordgren/fetch-prune-local-branches-v14 Pull-Request: https://github.com/git/git/pull/2285 Range-diff vs v13: 1: ccd07cff25 = 1: 7383872f4b branch: add --forked filter for --list mode 2: a7672713f6 ! 2: 7ef9502e01 branch: let delete_branches warn instead of error on bulk refusal @@ builtin/branch.c: static int delete_branches(int argc, const char **argv, int fo int i; int ret = 0; int remote_branch = 0; -+ int force = flags & DELETE_BRANCH_FORCE; -+ int quiet = flags & DELETE_BRANCH_QUIET; ++ int force, quiet; struct strbuf bname = STRBUF_INIT; enum interpret_branch_kind allowed_interpret; struct string_list refs_to_delete = STRING_LIST_INIT_DUP; @@ builtin/branch.c: static int delete_branches(int argc, const char **argv, int force, int kinds, + remote_branch = 1; + allowed_interpret = INTERPRET_BRANCH_REMOTE; + +- force = 1; ++ flags |= DELETE_BRANCH_FORCE; + break; + case FILTER_REFS_BRANCHES: + fmt = "refs/heads/%s"; +@@ builtin/branch.c: static int delete_branches(int argc, const char **argv, int force, int kinds, + } + branch_name_pos = strcspn(fmt, "%"); + ++ force = flags & DELETE_BRANCH_FORCE; ++ quiet = flags & DELETE_BRANCH_QUIET; ++ + if (!force) + head_rev = lookup_commit_reference(the_repository, &head_oid); for (i = 0; i < argc; i++, strbuf_reset(&bname)) { char *target = NULL; 3: 5ee7643d3a ! 3: 259113e304 branch: prepare delete_branches for a bulk caller @@ builtin/branch.c: enum delete_branch_flags { static int check_branch_commit(const char *branchname, const char *refname, @@ builtin/branch.c: static int delete_branches(int argc, const char **argv, int kinds, + int i; + int ret = 0; int remote_branch = 0; - int force = flags & DELETE_BRANCH_FORCE; - int quiet = flags & DELETE_BRANCH_QUIET; -+ int dry_run = flags & DELETE_BRANCH_DRY_RUN; -+ int no_head_fallback = flags & DELETE_BRANCH_NO_HEAD_FALLBACK; +- int force, quiet; ++ int force, quiet, dry_run, no_head_fallback; struct strbuf bname = STRBUF_INIT; enum interpret_branch_kind allowed_interpret; struct string_list refs_to_delete = STRING_LIST_INIT_DUP; @@ builtin/branch.c: static int delete_branches(int argc, const char **argv, int kinds, - } - branch_name_pos = strcspn(fmt, "%"); + + force = flags & DELETE_BRANCH_FORCE; + quiet = flags & DELETE_BRANCH_QUIET; ++ dry_run = flags & DELETE_BRANCH_DRY_RUN; ++ no_head_fallback = flags & DELETE_BRANCH_NO_HEAD_FALLBACK; - if (!force) + if (!force && !no_head_fallback) 4: 5f913c445c = 4: 9924373da0 branch: add --prune-merged 5: 8e9a735ffe = 5: d691d5051b branch: add branch..pruneMerged opt-out 6: 511de4788e = 6: ede8c61729 branch: add --dry-run for --prune-merged -- gitgitgadget