forgit icon indicating copy to clipboard operation
forgit copied to clipboard

Feature request: add interactive commit metadata amend command

Open vw2x opened this issue 3 months ago • 5 comments

Check list

  • [x] I have read through the README
  • [x] I have the latest version of forgit
  • [x] I have searched through the existing issues and pull requests

Environment info

  • OS
    • [ ] Linux
    • [x] Mac OS X
    • [ ] Windows
    • [ ] Others:
  • Shell
    • [ ] bash
    • [x] zsh
    • [ ] fish

Problem / Steps to reproduce

forgit already offers grw for interactively selecting an earlier commit and rewriting its message. There is no corresponding workflow for correcting commit metadata such as author name, author email, author date, committer name, committer email, or committer date.

Today, correcting one field requires manually combining an interactive rebase with git commit --amend and environment variables. This is powerful but difficult to remember, especially when the target is not HEAD.

Proposal

Add an interactive amend command, with the default alias gam:

  1. Select one commit from the current branch with fzf and preview its diff.
  2. Choose which metadata fields to edit.
  3. Preserve every unselected field exactly.
  4. Rewrite the selected commit through Git's normal amend/rebase workflow.

The initial scope should be one commit only. Batch normalization belongs to tools such as git-filter-repo, not forgit.

Questions for maintainers:

  • Is amend / gam an acceptable command name and alias?
  • Should the initial version reject merge commits and show an explicit confirmation when the selected commit is already upstream?
  • Are there existing conventions for handling rewritten signed commits?

Contribution

I am happy to implement this feature and submit a focused pull request if the proposed scope and command naming are acceptable.

vw2x avatar Aug 16 '26 04:08 vw2x

@vwww-droid Thanks a lot for your request. While I can see the benefit of this, I think it would enter a new territory in forgit. Right now forgit is just a wrapper around the git CLI, i.e. all output you see comes directly from git. An interactive metadata selector and patcher would require implementing our own logic in some form. I don't see this in forgit right now. Curious what the other maintainers say, though. @wfxr @cjappl @sandr01d

carlfriedrich avatar Aug 22 '26 11:08 carlfriedrich

I agree that this seems a little outside the current purview of forgit. I think this may open a can of worms we may not want to in terms of complexity/maintainability.

Not a hill I'd die on though, if other maintainers are OK with it.

cjappl avatar Aug 22 '26 15:08 cjappl

Thanks for the feedback. I understand that this would require some custom UI, while grw can rely more directly on Git’s existing rebase and message-editing flow.

Could you clarify whether the main maintainability concern is the metadata-editing UI itself, or the additional edge cases around rewriting author/committer names, emails, and dates?

The intended scope is one commit at a time, with no batch rewriting. It could reuse the same rebase workflow as grw and delegate the actual rewrite to git commit --amend, while initially leaving merge commits, signed commits, and other advanced cases unsupported.

If this still does not fit forgit’s scope, I understand. Since this is a fairly specialized use case, I can develop it as a standalone script instead.

vw2x avatar Aug 22 '26 18:08 vw2x

I agree with @cjappl and @carlfriedrich. Regarding the question where the complexity stems from: forgit heavily piggybacks on the features provided by the git CLI, meaning we try not to build new workflows but wrappers around the existing ones. gfu and grw make use of git rebase --fixup and git rebase --fixup=reword respectively, which do most of the heavy lifting for us. Git does not provide a dedicated workflow for amending a commit other than HEAD. The recommended workflow to do so is, AFAIK, the rebase you outlined above. Adding a workflow for this would require us to invent our own. IMO this is not only a question in regards to complexity, but also the philosphy of this project. We usually try to stay close to gits existing commands to keep forgit intuitive for people that already know how to use git and to prevent feature creep.

sandr01d avatar Aug 29 '26 15:08 sandr01d

Thanks for your feedback @sandr01d and @cjappl . I will close this then, as we have agreed that this is out of scope for forgit.

carlfriedrich avatar Sep 03 '26 10:09 carlfriedrich