Re: [PATCH v14 4/6] branch: add --prune-merged <branch>
- From
Harald Nordgren <haraldnordgren@gmail.com>
- Date
- Jun 16, 2026, 19:15 UTC
- Message-ID
- <CAHwyqnUsjpCHfS=eBphmkdDGYpQZ_LQUJi1mjrxV8ZXi+w4yhg@mail.gmail.com>
- In-Reply-To
- <78b6dfdd-df61-4c44-96eb-b527cb26243c@gmail.com>
Show 19 quoted lines
> > diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh > > index 4e7deddc04..27ea1319bb 100755 > > --- a/t/t3200-branch.sh > > +++ b/t/t3200-branch.sh > > @@ -1809,4 +1809,205 @@ test_expect_success '--forked requires a value' ' > > test_grep "requires a value" err > > ' > > > > +test_expect_success '--prune-merged: setup' ' > > + test_create_repo pm-upstream && > > The rest of this test would be easier to read if we did > > ( > cd pm-upstream && > ... > ) > > rather than prefixing every command with "-C pm-upstream"
I feel like the discussion to nest or not to nest has come up many times in other topics as well. I don't feel strongly about either way, but I just want to flag that if I change it now, another reviewer might ask me to change it back later.
Should the rules be to nest inside of setup functions (and helpers?) but not inside the actual tests?
Show 21 quoted lines
> > + test_commit -C pm-upstream base && > > + git -C pm-upstream checkout -b next && > > + test_commit -C pm-upstream one-commit && > > + test_commit -C pm-upstream two-commit && > > + git -C pm-upstream branch one HEAD~ && > > + git -C pm-upstream branch two HEAD && > > + git -C pm-upstream branch wip main && > > + git -C pm-upstream checkout main && > > + test_create_repo pm-fork > > +' > > + > > +test_expect_success '--prune-merged deletes branches integrated into upstream' ' > > + test_when_finished "rm -rf pm-merged" && > > + git clone pm-upstream pm-merged && > > + git -C pm-merged remote add fork ../pm-fork && > > + test_config -C pm-merged remote.pushDefault fork && > > + test_config -C pm-merged push.default current && > > So we clone upstream and add fork as the default push remote. I find the > pm- prefixes rather distracting. It would be clearer to me if we just > called the repositories "upstream", "fork" and "repo"
Good point.
Show 25 quoted lines
> > + test_must_fail git -C pm-local rev-parse --verify refs/heads/one > > +' > > + > > +test_expect_success '--prune-merged warns instead of erroring on un-integrated commits' ' > > + test_when_finished "rm -rf pm-unmerged" && > > + git clone pm-upstream pm-unmerged && > > + git -C pm-unmerged remote add fork ../pm-fork && > > + test_config -C pm-unmerged remote.pushDefault fork && > > + test_config -C pm-unmerged push.default current && > > + git -C pm-unmerged checkout -b wip origin/wip && > > + git -C pm-unmerged branch --set-upstream-to=origin/next wip && > > + test_commit -C pm-unmerged local-only && > > + git -C pm-unmerged checkout - && > > + > > + git -C pm-unmerged branch --prune-merged "origin/*" 2>err && > > + test_grep "not fully merged" err && > > + test_grep ! "If you are sure you want to delete it" err && > > I'm always suspicious of test_grep when we know what the output should > look like - it might be better to use test_cmp. This test does not check > that we also delete branches that are merged when we see one that isn't. > > I'm going to stop here - the tests I've read seem to me to be too much > like unit tests checking one aspect of the implementation in isolation > rather than checking that the whole feature works as expected.
I'll respond to the rest here: Excellent points regarding the testing aboce, I will take a look at doing this.
Harald