Skip to content

squash: support --restore-descendants - #9487

Open
LoganDark wants to merge 1 commit into
jj-vcs:mainfrom
LoganDark:squash-restore-descendants
Open

squash: support --restore-descendants#9487
LoganDark wants to merge 1 commit into
jj-vcs:mainfrom
LoganDark:squash-restore-descendants

Conversation

@LoganDark

Copy link
Copy Markdown

Sometimes it is convenient to be able to make changes to a commit in the past without affecting descendants -- I already have a workflow that tracks the commits of all children, makes the changes, and then restores manually, but that performs a lot more rebases than necessary, which adds up when history is long. Supporting --restore-descendants for jj squash helps this workflow greatly.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added/updated tests to cover my changes
  • I fully understand the code that I am submitting (what it does,
    how it works, how it's organized), including any code drafted by an LLM.
  • For any prose generated by an LLM, I have proof-read and copy-edited with
    an eye towards deleting anything that is irrelevant, clarifying anything
    that is confusing, and adding details that are relevant. This includes,
    for example, commit descriptions, PR descriptions, and code comments.

Prior Art

I found #6141 but haven't looked too far into it.

@LoganDark
LoganDark requested a review from a team as a code owner May 12, 2026 20:15

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The following commits do not follow our format for subject lines:

  • 72f1215: support --restore-descendants for squash

Commits should have a subject line following the format <topic>: <description>. Please review the commit guidelines for more information.

@PhilipMetzger

Copy link
Copy Markdown
Contributor

Please move the motivation from the PR into the commit description to adhere to our commit style. Also adjust the topic like the bot suggests.

Comment thread lib/src/rewrite.rs Outdated
@LoganDark

Copy link
Copy Markdown
Author

Please move the motivation from the PR into the commit description to adhere to our commit style. Also adjust the topic like the bot suggests.

Sorry, internet went out. Working on it now.

@LoganDark
LoganDark force-pushed the squash-restore-descendants branch from 72f1215 to a661892 Compare May 12, 2026 20:59
@github-actions
github-actions Bot dismissed their stale review May 12, 2026 20:59

All commits are now correctly formatted. Thank you for your contribution!

@LoganDark
LoganDark force-pushed the squash-restore-descendants branch from a661892 to 220ca06 Compare May 12, 2026 21:00
@LoganDark
LoganDark requested a review from PhilipMetzger May 12, 2026 21:01
@LoganDark LoganDark changed the title support --restore-descendants for squash jj·squash:·support·--restore-descendants May 12, 2026
@LoganDark
LoganDark force-pushed the squash-restore-descendants branch from 220ca06 to 016b462 Compare May 12, 2026 21:08

@PhilipMetzger PhilipMetzger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm, still needs maintainer approval though

@josephlou5

Copy link
Copy Markdown
Contributor

Following https://docs.jj-vcs.dev/latest/contributing/#commit-guidelines, maybe the topic of the commit subject should be squash: instead of `jj squash`:?

Also, there is a missing backtick after `--restore-descendants in the second to last line.

@LoganDark
LoganDark force-pushed the squash-restore-descendants branch from 016b462 to b3506b2 Compare May 13, 2026 00:44
@LoganDark LoganDark changed the title jj·squash:·support·--restore-descendants squash: support --restore-descendants May 13, 2026
@LoganDark

Copy link
Copy Markdown
Author

Following https://docs.jj-vcs.dev/latest/contributing/#commit-guidelines, maybe the topic of the commit subject should be squash: instead of `jj squash`:?

Oops, didn't notice that part of the page. (I was there.)

Also, there is a missing backtick after `--restore-descendants in the second to last line.

Fixed as well.

@martinvonz

Copy link
Copy Markdown
Contributor

I found #6141 but haven't looked too far into it.

I think it's worth doing that so we don't need to rehash the same things here.

@LoganDark

LoganDark commented May 13, 2026

Copy link
Copy Markdown
Author

I found #6141 but haven't looked too far into it.

I think it's worth doing that so we don't need to rehash the same things here.

My implementation differs, so it's not trivial to translate the feedback. I can't reproduce the bugs mentioned in the discussions there. Conflicts work correctly if you squash to a destination where the diff doesn't apply cleanly, the flag works in combination with -A/-B, nothing weird happens when the squash source has descendants, etc. No need to disallow anything. I would really prefer some individual feedback.

The only thing that seems potentially relevant is partial squashing into ancestors, but with my implementation that moves the change to exclusively that ancestor and correctly propagates the lack of it to descendants, so I don't see an issue there either. Everything seems to be fairly obvious and there don't seem to be any unintuitive edge cases that I can tell.

@martinvonz

Copy link
Copy Markdown
Contributor

@ilyagr: Any chance you can review this PR?

@LoganDark
LoganDark force-pushed the squash-restore-descendants branch 2 times, most recently from d5968eb to e091a96 Compare May 18, 2026 00:18
@LoganDark
LoganDark force-pushed the squash-restore-descendants branch 2 times, most recently from b3d5806 to 583ca7e Compare May 27, 2026 02:16
@LoganDark
LoganDark force-pushed the squash-restore-descendants branch from 583ca7e to b6d460e Compare June 14, 2026 09:07
@LoganDark
LoganDark force-pushed the squash-restore-descendants branch from b6d460e to 1a96b8c Compare July 14, 2026 11:32
@LoganDark
LoganDark marked this pull request as draft July 14, 2026 15:41
@LoganDark
LoganDark force-pushed the squash-restore-descendants branch from 1a96b8c to 8386d3f Compare July 14, 2026 15:47
@LoganDark
LoganDark marked this pull request as ready for review July 14, 2026 15:47
@LoganDark

Copy link
Copy Markdown
Author

rebased onto the latest master. (or "main")

Do we know if a review is likely to happen?

@PhilipMetzger

Copy link
Copy Markdown
Contributor

I'd really like this or #6141 to land, since I've now repeatedly hit cases where it is extremely useful.

@jennings jennings left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I did not review the implementation, but the tests seem to show a reasonable behavior. I just added some suggestions for making the tests easier to show how the graph changes.

Comment thread cli/tests/test_squash_command.rs Outdated
Comment thread cli/tests/test_squash_command.rs Outdated
Comment thread cli/tests/test_squash_command.rs
@LoganDark
LoganDark force-pushed the squash-restore-descendants branch from 8386d3f to 89508db Compare July 17, 2026 11:03
@LoganDark
LoganDark requested a review from jennings July 17, 2026 11:05
@LoganDark
LoganDark force-pushed the squash-restore-descendants branch from 89508db to 6756772 Compare July 19, 2026 05:50
Sometimes it is convenient to be able to make changes to a commit in the
past without affecting descendants -- I already have a workflow that
tracks the commits of all children, makes the changes, and then restores
manually, but that performs a lot more rebases than necessary, which
adds up when history is long. Supporting `--restore-descendants` for
`jj squash` helps this workflow greatly.
@LoganDark
LoganDark force-pushed the squash-restore-descendants branch from 6756772 to 169be4e Compare August 1, 2026 21:16
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.

5 participants