Re: [PATCH v14 5/6] branch: add branch.<name>.pruneMerged opt-out
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Jun 16, 2026, 09:57 UTC
- Message-ID
- <fe752544-b076-4aa4-a9d6-d48fe15ce57b@gmail.com>
- In-Reply-To
- <d691d5051b35a569dbd3f4a0488030a7d84d72f9.1780999917.git.gitgitgadget@gmail.com>
Hi Harald
On 09/06/2026 11:11, Harald Nordgren via GitGitGadget wrote:
Show 7 quoted lines
> From: Harald Nordgren <haraldnordgren@gmail.com> > > Setting branch.<name>.pruneMerged=false exempts that branch from > "git branch --prune-merged", which is useful for a topic you want > to keep developing after an early round of it has been merged > upstream. Unless --quiet is given, each skip is reported so the > user knows why their topic was kept.
Sounds good
Show 15 quoted lines
> @@ -755,6 +757,18 @@ static int prune_merged_branches(int argc, const char **argv,
> if (!push || !strcmp(push, upstream))
> continue;
>
> + strbuf_addf(&key, "branch.%s.prunemerged", short_name);
> + if (!repo_config_get_bool(the_repository, key.buf, &opt_out) &&
> + !opt_out) {
> + if (!quiet)
> + fprintf(stderr,
> + _("Skipping '%s' (branch.%s.pruneMerged is false)\n"),
> + short_name, short_name);
> + strbuf_release(&key);
> + continue;
> + }
> + strbuf_release(&key);As this is in a loop we don't want to free the buffer on each iteration, only at the end. You should call strbuf_reset() just before strbuf_addf() above and then move this call to strbuf_release() out of the loop.
Show 17 quoted lines
> +test_expect_success '--prune-merged honours branch.<name>.pruneMerged=false' ' > + test_when_finished "rm -rf pm-optout" && > + git clone pm-upstream pm-optout && > + git -C pm-optout remote add fork ../pm-fork && > + test_config -C pm-optout remote.pushDefault fork && > + test_config -C pm-optout push.default current && > + git -C pm-optout branch one one-commit && > + git -C pm-optout branch --set-upstream-to=origin/next one && > + git -C pm-optout branch two two-commit && > + git -C pm-optout branch --set-upstream-to=origin/next two && > + test_config -C pm-optout branch.one.pruneMerged false && > + > + git -C pm-optout branch --prune-merged "origin/*" 2>err && > + > + git -C pm-optout rev-parse --verify refs/heads/one && > + test_must_fail git -C pm-optout rev-parse --verify refs/heads/two && > + test_grep "Skipping .one." err
Do we really need a whole new setup to test this - can't we just add a protected branch to an existing test?
Thanks
Phillip
Show 13 quoted lines
> + > +test_expect_success 'branch -d still deletes a pruneMerged=false branch' ' > + test_when_finished "rm -rf pm-optout-d" && > + git clone pm-upstream pm-optout-d && > + git -C pm-optout-d branch one one-commit && > + git -C pm-optout-d branch --set-upstream-to=origin/next one && > + test_config -C pm-optout-d branch.one.pruneMerged false && > + > + git -C pm-optout-d branch -d one && > + test_must_fail git -C pm-optout-d rev-parse --verify refs/heads/one > +' > + > test_done