Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli rebase: do not allow -r --skip-empty to empty descendants #2638

Merged
merged 1 commit into from
Nov 26, 2023

Conversation

ilyagr
Copy link
Contributor

@ilyagr ilyagr commented Nov 26, 2023

This follows up on @matts1 's #2609.

We still allow the -r commit to become empty. I would be more comfortable if
there 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 to jj abandon A,
and jj abandon does not remove emptied commits. It also doesn't seem very
useful 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 add
thorough tests and possibly improve the algorithm. I want to refactor rebase -r and add features to it, and having to consider cases of commits becoming
abandoned makes everything harder.

For example, if we have

root -> A -> B -> C

and jj rebase -r A -d C empties commit B (or C), I do not know whether
the 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.

@ilyagr ilyagr marked this pull request as ready for review November 26, 2023 06:44
@ilyagr
Copy link
Contributor Author

ilyagr commented Nov 26, 2023

(I briefly added a second commit to this, but now I think I should add a test to that, so I removed it again)

Copy link
Member

@martinvonz martinvonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

This follows up on @matts1 's jj-vcs#2609.

We still allow the `-r` commit to become empty. I would be more comfortable if
there 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 to `jj abandon A`,
and `jj abandon` does not remove emptied commits. It also doesn't seem very
useful 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 add
thorough tests and possibly improve the algorithm. I want to refactor `rebase
-r` and add features to it, and having to consider cases of commits becoming
abandoned makes everything harder.

For example, if we have

```
root -> A -> B -> C
```

and `jj rebase -r A -d C` empties commit `B` (or `C`), I do not know whether
the 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`.
@ilyagr ilyagr enabled auto-merge (rebase) November 26, 2023 18:49
@ilyagr ilyagr merged commit 3967f63 into jj-vcs:main Nov 26, 2023
15 checks passed
@ilyagr ilyagr deleted the rskipempty branch November 26, 2023 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants