On Mon, May 05, 2025 at 04:59:14AM -0400, Eric Sunshine wrote: > On Fri, May 2, 2025 at 4:44 AM Patrick Steinhardt <ps@xxxxxx> wrote: > > + limit--; > > + > > + if (!limit) { > > + should_prune = 1; > > + goto out; > > + } > > + } > > + free(wtpath); > > This leaks `wtpath` when it takes the `goto out` arm. Good catch, fixed now. > > + } > > + > > +out: > > + strvec_clear(&worktrees); > > + strbuf_release(&reason); > > + return should_prune; > > +} > > diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh > > @@ -493,6 +493,77 @@ test_expect_success 'reflog-expire task --auto only packs when exceeding limits' > > +test_expect_success 'worktree-prune task with --auto honors maintenance.worktree-prune.auto' ' > > + # A negative value should always prune. > > + test_expect_worktree_prune git -c maintenance.worktree-prune.auto=-1 maintenance run --auto --task=worktree-prune && > > + > > + mkdir .git/worktrees && > > + : >.git/worktrees/first && > > + : >.git/worktrees/second && > > + : >.git/worktrees/third && > > + > > + # Zero should never prune. > > + test_expect_worktree_prune ! git -c maintenance.worktree-prune.auto=0 maintenance run --auto --task=worktree-prune && > > + # A positive value should require at least this man prunable worktrees. > > s/man/many/ Fixed, as well. Patrick