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

feat(squash): Add --keep-emptied flag #3830

Merged
merged 2 commits into from
Jul 3, 2024
Merged

feat(squash): Add --keep-emptied flag #3830

merged 2 commits into from
Jul 3, 2024

Conversation

matts1
Copy link
Collaborator

@matts1 matts1 commented Jun 5, 2024

If the user was thinking in terms of files, instead of commits, then we shouldn't abandon the commit, as that can have side effects such as moving branch pointers.

Fixes #3815

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • [N/A] I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

@matts1 matts1 marked this pull request as ready for review June 5, 2024 01:04
Copy link
Collaborator

@mlcui-corp mlcui-corp left a comment

Choose a reason for hiding this comment

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

Thank you for implementing this! A few drive-by nits.

cli/src/commands/squash.rs Outdated Show resolved Hide resolved
cli/src/commands/squash.rs Outdated Show resolved Hide resolved
cli/src/commands/squash.rs Outdated Show resolved Hide resolved
cli/src/commands/squash.rs Outdated Show resolved Hide resolved
@matts1 matts1 force-pushed the squash branch 2 times, most recently from 725779a to f0a36cb Compare June 5, 2024 01:56
cli/src/commands/squash.rs Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
cli/src/commands/move.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@yuja yuja left a comment

Choose a reason for hiding this comment

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

Thanks for updating the patch. This looks good to me.

cli/src/commands/squash.rs Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
cli/tests/test_squash_command.rs Show resolved Hide resolved
cli/tests/test_squash_command.rs Show resolved Hide resolved
cli/tests/test_squash_command.rs Show resolved Hide resolved
cli/src/commands/squash.rs Outdated Show resolved Hide resolved
@matts1 matts1 changed the title Feat: Only abandon empty commits with squash if the user intended it. feat(squash): Add --keep-emptied flag Jun 14, 2024
@matts1 matts1 force-pushed the squash branch 2 times, most recently from f359352 to 2072c5f Compare June 14, 2024 01:48
@matts1
Copy link
Collaborator Author

matts1 commented Jun 14, 2024

One last thing I'd like to discuss before submitting is what the name of the flag would be. I'll wait for a few days before submitting for any feed back on if people want the name changed.

Our options seem to be (feel free to add more if you have any ideas):

  • keep-emptied
    • The most technically accurate mapping of behavior to name
    • Is "keep" going to be the term we always use in the future for "don't abandon". I'd like to be consistent about this.
  • keep-empty
    • Technically, this would imply that we abandon all empty commits, which isn't correct in the one edge case where we squash two empty commits together.
  • no-abandon
    • Would imply that the default is abandon (in reality, the default is abandon empty commits)
  • never-abandon
    • Doesn't have the downsides of the implications of --no-abandon
    • A less common way of phrasing it
      • May be confusing, or intentionality may provoke thought and understanding of what it actually does.

@matts1 matts1 requested a review from martinvonz June 14, 2024 01:57
CHANGELOG.md Outdated Show resolved Hide resolved
@matts1 matts1 merged commit ca4eb60 into jj-vcs:main Jul 3, 2024
17 checks passed
matts1 added a commit to matts1/jj that referenced this pull request Jul 3, 2024
This is based on @martinvonz's comment in jj-vcs#3830 about the inconsistency between squash --keep-emptied and rebase --skip-empty.
@matts1 matts1 deleted the squash branch July 3, 2024 02:04
matts1 added a commit to matts1/jj that referenced this pull request Jul 3, 2024
This is based on @martinvonz's comment in jj-vcs#3830 about the inconsistency between squash --keep-emptied and rebase --skip-empty.
matts1 added a commit to matts1/jj that referenced this pull request Jul 3, 2024
This is based on @martinvonz's comment in jj-vcs#3830 about the inconsistency between squash --keep-emptied and rebase --skip-empty.
matts1 added a commit to matts1/jj that referenced this pull request Jul 3, 2024
This is based on @martinvonz's comment in jj-vcs#3830 about the inconsistency between squash --keep-emptied and rebase --skip-empty.
matts1 added a commit to matts1/jj that referenced this pull request Jul 4, 2024
This is based on @martinvonz's comment in jj-vcs#3830 about the inconsistency between squash --keep-emptied and rebase --skip-empty.
matts1 added a commit that referenced this pull request Jul 4, 2024
This is based on @martinvonz's comment in #3830 about the inconsistency between squash --keep-emptied and rebase --skip-empty.
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.

FR: jj squash should allow you to preserve the commit even if it was made empty
6 participants