Re: [PATCH 27/30] subtree: allow --squash to be used with --rejoin
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Apr 24, 2021, 05:50 UTC
- Message-ID
- <CAPig+cTdTTq+W-QM3y60621GqqgXiHOueKF_Yk35=bL5p8o9uw@mail.gmail.com>
- In-Reply-To
- <20210423194230.1388945-28-lukeshu@lukeshu.com>
On Fri, Apr 23, 2021 at 3:43 PM Luke Shumaker <lukeshu@lukeshu.com> wrote:
Show 22 quoted lines
> Besides being a genuinely useful thing to do, this also just makes sense > and harmonizes which flags may be used when. `git subtree split > --rejoin` amounts to "automatically go ahead and do a `git subtree > merge` after doing the main `git subtree split`", so it's weird and > arbitrary that you can't pass `--squash` to `git subtree split --rejoin` > like you can `git subtree merge`. It's weird that `git subtree split > --rejoin` inherits `git subtree merge`'s `--message` but not `--squash`. > > Reconcile the situation by just having `split --rejoin` actually just > call `merge` internally (or call `add` instead, as appropriate), so it > can get access to the full `merge` behavior, including `--squash`. > > Signed-off-by: Luke Shumaker <lukeshu@datawire.io> > --- > diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh > @@ -324,6 +324,41 @@ test_expect_success 'split sub dir/ with --rejoin and --message' ' > +test_expect_success 'split "sub dir"/ with --rejoin and --squash' ' > + [...] > + SPLIT=$(git subtree split --prefix="sub dir" --annotate="*" --rejoin --squash) && > + > + ! git merge-base --is-ancestor $SUB HEAD && > + ! git merge-base --is-ancestor $SPLIT HEAD &&
It's preferable to use `test_must_fail` rather than `!` for Git commands (but not for non-Git commands) since `test_must_fail` correctly distinguishes between an expected failure and an unexpected one such as a crash, whereas `!` can't make that distinction and would even consider a crashed Git invocation to be successful.
Existing tests in this script already employ `test_must_fail` rather than `!`, so using `test_must_fail` would also match precedent.