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

Create Fixup Commits #829

Closed
pe opened this issue Jul 31, 2021 · 11 comments · Fixed by #1553
Closed

Create Fixup Commits #829

pe opened this issue Jul 31, 2021 · 11 comments · Fixed by #1553
Milestone

Comments

@pe
Copy link
Contributor

pe commented Jul 31, 2021

Is your feature request related to a problem? Please describe.
Creating a fixup commit is complex. It's not possible only with gitui and possibe but still cumbersome with other tools.

Describe the solution you'd like

  • stage the changes
  • instead of commit I hit the fixup shortcut
  • gitui shows the log and I can select the commit I want to fixup
  • gitui creates a fixup commit which I can rebase later

Describe alternatives you've considered

Using gitui:

  • stage the changes
  • switch to "log"
  • select the commit I want to fixup, copy the hash
  • quit gitui
  • git commit --fixup + pasted hash

In other git clients (sourcetree, tig) I created an external command git commit --fixup {SHA}. Then I

  • stage the changes
  • switch to the log
  • select the commit I want to fixup
  • launch my external command.

(I'm open to implement this myself. It would depend on the effort and your willingness to accept it though.)

@pe pe changed the title Fixup Commits Create Fixup Commits Aug 1, 2021
@extrawurst
Copy link
Owner

related to #32

@stale
Copy link

stale bot commented Nov 8, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the dormant Marked by stale bot on close label Nov 8, 2021
@stale stale bot closed this as completed Nov 16, 2021
@osnyx
Copy link

osnyx commented Nov 11, 2022

I'm still dearly missing this, is this blocked by the same missing library functionality as #32 (comment) ?

@pbirnzain
Copy link

Same here. I frequently use the amend feature in the commit window.
When I want to fixup an older commit, I usually revert to git log and git commit --fixup (I tend to forget the hashes immediately, so they have to remain on screen).
Having a fixup command in the log view that helps creating the commit message would already be a major improvement.

@extrawurst
Copy link
Owner

ok if its just about rewording a commit msg we can probbaly easily hack something together. reuse the CommitComponent and extend Mode with a Fixup variant that take a CommitId for input

@extrawurst extrawurst reopened this Feb 4, 2023
@stale stale bot removed the dormant Marked by stale bot on close label Feb 4, 2023
@extrawurst extrawurst added this to the v0.23 milestone Feb 4, 2023
@extrawurst
Copy link
Owner

@pe still interested to work on that?

@pe
Copy link
Contributor Author

pe commented Feb 4, 2023

Not really at the moment. Sorry.

@extrawurst
Copy link
Owner

#312 does most of the heavy lifting already

extrawurst added a commit that referenced this issue Feb 18, 2023
* reuse commit popup for reword
* switch to status after reword
* show command
* prepopulate with old msg
* changelog

Closes #829
@pbirnzain
Copy link

I built and tested the new reword feature locally. It's pretty cool, but only part of the solution.

Reword and fixup are the separate two actions an amendment does, the man page for git-commit (--fixup section) explains it quite nicely.

git commit --amend and git commit --fixup=amend:HEAD provide similar functionality,
the difference being that the --fixup variant can be applied to any commit, and has to be explicitly applied using git rebase --autosquash or git rebase --interactive.

gitui already can do what git commit --amend does, and now also git commit --fixup=reword:<commit> (but somehow without doing a rebase? Or does this happen implicitly, is this why a clean working tree is needed to reword?).

Unfortunately my Rust skills are very meager so far, so I have a hard time understanding the code, let alone contributing.
The amend mode already seems to take a commit id? Maybe the solution to this is not to far off.

@extrawurst
Copy link
Owner

extrawurst commented Feb 21, 2023

ok wait so what variants are there:

  1. git commit --amend
  2. git commit --fixup:amend:HEAD
  3. git commit --fixup:reword:

where we now have 1 and 3 but still miss 2? if so can you explain exactly what it does? Can you put that clear description into a new issue?

but somehow without doing a rebase? Or does this happen implicitly, is this why a clean working tree is needed to reword?

no it does rebase, that's why it needs a clean state

@Mirko-von-Leipzig
Copy link

Mirko-von-Leipzig commented Jan 17, 2024

I think this issue was closed incorrectly and I would love having the feature as originally described here.

I'll give a longer explanation since I think this issue was a bit misunderstood. Apologies if this is unecessary.

Sometimes you'll find yourself wanting to fix issues in your previous commits, but you want to preserve the commit history, at least temporarily, and then later squash these fixes into the original commits they fixed. A good example of this is submitting a PR for review. Its been reviewed and you now want to fix some of the previous commits - however you don't want to rebase as this would mess with anyone doing a follow-up review.

git provides git commit --fixup=<SHA> which enables the following workflow. It adds a new commit which is marked with some additional text. This acts like a completely normal commit and can be reviewed as normal. You can repeat this multiple times as you see fit. Once you're happy and you no longer need to conserve history for review purposes you do git rebase ... --autosquash which then rebases and squashes each fixup commit into the original target commit.

What would be nice is if gitui enabled doing git commit --fixup=<SHA> from its commit menu. As described by OP:

  1. Stage changes
  2. Move to commit pane
  3. Hit fixup shortcut e.g. Ctrl-f
  4. gitui presents a log view to let us select the target commit (this is much nicer than manually looking for the correct SHA)
  5. gitui then executes git commit --fixup=<SHA>

To be clear - there is no actual rebase involved here. Only git commit --fixup=<SHA>. The rebase would happen as a separate action.

IndianBoy42 pushed a commit to IndianBoy42/gitui that referenced this issue Jun 4, 2024
* reuse commit popup for reword
* switch to status after reword
* show command
* prepopulate with old msg
* changelog

Closes extrawurst#829
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants