Skip to content

Add support for drop!/reword! commits to git rebase -i #259

@dscho

Description

@dscho
Member

This was already discussed briefly on the Git mailing list: https://public-inbox.org/git/alpine.DEB.2.21.1.1710151754070.40514@virtualbox/

In short, the reword! semantics are relatively easy in my mind: it would be called as

git commit --reword <commit>

would take staged changes (if any), otherwise implicitly --allow-empty,
then create a commit message to be edited in this style:

reword! <original-oneline>

<original-oneline>

<original-body>

This would be presented to the user in an editor (similar to git commit --amend).

Upon rebase --autosquash, it would work like a squash! but comment out all
previous commit messages, and also comment out the reword! line and the
empty line after that.

In case of multiple reword!, the last one would win, and it would
naturally integrate in any fixup!/squash! workflow.

What is more difficult is something else I frequently need: drop!
. That is, I want to explicitly mark a commit to be excluded in
subsequent rebase --autosquash. I guess the best way would be to
implement a

git revert --drop <commit>

that would work as if you called git revert -n <commit> && git commit -m 'drop! '"$(git show -s --oneline <commit>)", and upon rebase --autosquash, it would reorder like fixup!/squash!/reword!, replace the pickof the previous line (if it was apick) by dropand comment out the currentpick drop! ` line.

The reason why the semantics are more difficult in that case is that drop!
does not mix well with fixup!/squash!/reword!.

Activity

Hasaber8

Hasaber8 commented on Mar 8, 2020

@Hasaber8

Has this project already been taken up or is still available to be worked upon?
-Rohan

dscho

dscho commented on Mar 8, 2020

@dscho
MemberAuthor

I am unaware of any effort so far, so go right ahead!

Hasaber8

Hasaber8 commented on Mar 9, 2020

@Hasaber8

Correct me if I'm wrong , currently even if we try and skip a single commit in git rebase -i it gets squashed, without it been shown in th editor.

dscho

dscho commented on Mar 9, 2020

@dscho
MemberAuthor

Correct me if I'm wrong , current even if we try and skip a single commit in git rebase -i it gets squashed, without it been shown in th editor.

If I understand your question right, you're asking whether git rebase --skip still applies the currently-picked commit? It does not...

Hasaber8

Hasaber8 commented on Mar 9, 2020

@Hasaber8

Correct me if I'm wrong , current even if we try and skip a single commit in git rebase -i it gets squashed, without it been shown in th editor.

If I understand your question right, you're asking whether git rebase --skip still applies the currently-picked commit? It does not...

The drop! semantics if executed properly will be a very good thing to use! This surely will be an interesting project to do!

phillipwood

phillipwood commented on Sep 18, 2020

@phillipwood

I've got some patches that implement the reword! part of this as amend! They need a little work - adding documentation, checking the test coverage and adjusting them to accommodate the recent changes to handling empty commits if anyone wants to pick them up

phillipwood

phillipwood commented on Sep 18, 2020

@phillipwood
git revert --drop <commit>

that would work as if you called git revert -n <commit> && git commit -m 'drop! '"$(git show -s --oneline <commit>)",

Do we need to actually do the revert? - If we want to drop the commit can't we use an empty commit (git commit -m 'drop! '"$(git show -s --oneline <commit>)")? If we actually try to revert the commit there is the potential for conflicts when running revert which would create unnecessary work for the user.

Edit: We need the revert so that the effects of the dropped commit are reversed for any commits we build on top of the drop! commit before we rebase.

dscho

dscho commented on Sep 23, 2020

@dscho
MemberAuthor
git revert --drop <commit>

that would work as if you called git revert -n <commit> && git commit -m 'drop! '"$(git show -s --oneline <commit>)",

Do we need to actually do the revert?

Yes. The point of dropping a given commit is to drop its changes, too, and that's a revert. Otherwise the tree after git revert --drop <commit> would not have dropped the changes!

LemmingAvalanche

LemmingAvalanche commented on Sep 28, 2024

@LemmingAvalanche

Isn’t all of this implemented now?

dscho

dscho commented on Sep 29, 2024

@dscho
MemberAuthor

Isn’t all of this implemented now?

I might have missed it, is the drop! part implemented now?

LemmingAvalanche

LemmingAvalanche commented on Sep 30, 2024

@LemmingAvalanche

@dscho Oh no sorry, I just tested (git version 2.46.2) and git rebase -i --autosquash does not translate drop! commits to the drop command in the todo editor.

Disregard that.

dscho

dscho commented on Sep 30, 2024

@dscho
MemberAuthor

All good. Thank you for keeping better tabs on these here tickets than I manage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @dscho@LemmingAvalanche@phillipwood@Hasaber8

        Issue actions

          Add support for drop!/reword! commits to `git rebase -i` · Issue #259 · gitgitgadget/git