Bug 569846 - Add fixup process in the Staging View
Summary: Add fixup process in the Staging View
Status: NEW
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-20 13:29 EST by Julian Ruppel CLA
Modified: 2022-06-15 05:45 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Julian Ruppel CLA 2020-12-20 13:29:44 EST
The commit area in the staging view already features actions for e.g. amend and signing. Having a fixup button would feel natural in this row.

The idea is that you want to fix a previeous commit (however, not the very recent one) with the current changes. So you would click on fixup, which would open a new dialog with the history in the current branch to choose the to-be-fixed commit. After that, clicking commit would basicall add --fixup <commit-hash> to the commit command.

One could also think about streamlining this process even further by automating the rebase interactive workflow, e.g. via adding a checkbox "autosquash after commit" in the before mentioned dialog that basically triggers a rebase -i --autosquash <commit-hash> directly after the commit. 

Whith this, the experience for fixing a previous commit would be much more handy and simple and probably more people will do it which in the end is beneficial for the git history in general.

Reference: https://fle.github.io/git-tip-keep-your-branch-clean-with-fixup-and-autosquash.html
Comment 1 Matthias Sohn CLA 2020-12-21 19:01:44 EST
Are you aware that you can already edit a previous commit which isn't the last one ?
- select the commit you want to edit in the history view
- click "Modify > Edit"
this automates preparing and starting an interactive rebase which allows to edit the selected commit. The action automatically creates the rebase command list, puts the rebase edit command for the selected commit and starts the rebase -i which rewinds to the selected commit so that you can edit it.

After editing, continue like you would continue a manually started rebase -i:
- commit --amend the modifications in the staging view
- click "Continue" in the staging view to complete the rebase

If you still want to implement commit --fixup and rebase -i --autosquash [2], these options first need to be implemented in JGit. Also support for the config option rebase.autoSquash [3] should be added.

Another similar option is commit --squash which can be used similarly in combination with rebase -i --autosquash.

Also note [4] that rebase -i --autosquash not only allows to select the commit to be auto squashed by giving the commit id of the target commit but you can also give some text which appears in the commit message of the target commit. Then it will select the first commit containing this text in its commit message starting from HEAD.

[1] https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---fixupltcommitgt
[2] https://git-scm.com/docs/git-rebase#Documentation/git-rebase.txt---autosquash
[3] https://git-scm.com/docs/git-rebase#Documentation/git-rebase.txt-rebaseautoSquash
[4] https://thoughtbot.com/blog/autosquashing-git-commits
Comment 2 Julian Ruppel CLA 2020-12-22 07:07:20 EST
Thank you, I was not aware of this option. Nevertheless, it underlines my point that such great functionality is not very prominent in the UI and the process not quite obvious for beginners.

Actually, the idea was to start simple by adding a fixup action beside the amend action in the StagingView. This action should then open a dialog containing more or less the same content of the GitHistoryPage to select the to-be-fixed commit. The chosen commit should then be used for the commit --fixup <commit-hash>. Obviously, this feature is missing in JGit and needs to be implemented, too. However, I am not familiar with the functionalities of JGit and would need some guiding information for that.

With this rather simple fixup action, the fixup functionality in general would at least gain more awareness, even though there is no automatic rebase -i --autosquash yet, which I would see as a more complicated second implementation step.

Additionally, thanks for the hint to --squash. Since it goes into the same direction as --fixup, it might make sense to add a squash action to the StagingView as well. Alternatively, one could combine both options in a single „combine with previous commit“ action and let the user choose whether to fixup or squash via radio buttons in the appearing GitHistory dialog.