cli rebase: do not allow -r --skip-empty
to empty descendants
#2638
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This follows up on @matts1 's #2609.
We still allow the
-r
commit to become empty. I would be more comfortable ifthere was a test for that, but I haven't done that (yet?) and it seems pretty
safe. If that's a problem, I'm happy to forbid
-r --skip-empty
entirely,since it is far less useful than
-s --skip-empty
or-b --skip-empty
.I think it is undesired to abandon emptied descendants. As far as descendants
of
A
are concerned,jj rebase -r A
should be equivalent tojj abandon A
,and
jj abandon
does not remove emptied commits. It also doesn't seem veryuseful to do that, since I think descendant commits of an abandoned (or moved
with
-r
) commit only become empty in pathological cases.Additionally, if we did want -r to empty descendants of
A
, we'd have to addthorough tests and possibly improve the algorithm. I want to refactor
rebase -r
and add features to it, and having to consider cases of commits becomingabandoned makes everything harder.
For example, if we have
and
jj rebase -r A -d C
empties commitB
(orC
), I do not know whetherthe current algorithm will work correctly. It seems possible that it would, but
that depends on the fact that empty merge commits are not abandoned for
descendants. That seems dangerous to rely on without tests.
I hope (but can't promise) that in the near future, making DescendantRebaser
return more information should help make it possible to create such
functionality in a more robust way. I am likely to attempt this as part of
implementing
-r --after
.