git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Feature Request: Interactively pick fixup revision

From
KHKristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Date
Nov 9, 2024, 17:08 UTC
Message-ID
<1d383dbd-a409-4199-84bc-652784835167@app.fastmail.com>
In-Reply-To
<CABg7He2asYQbdRvSvfh1YZ2FRPchVfvta8yBv4PFdVNnhzX6Ow@mail.gmail.com>
On Sat, Nov 9, 2024, at 12:41, Martin Imre wrote:
Show 30 quoted lines
> Hi,
>
> first email to this list, so please forgive me if I'm doing something wrong.
>
> My usual workflow is using `git commit --fixup <revision>` quite
> frequently, as it eases the code reviewing process and allows for a
> clean history later on.
>
> One thing that is always cumbersome is to first find the SHA of the
> revision that I plan to commit a fixup to.
> I usually use git log and then copy the revision.
> I even wrote a script that eases this process using fzf:
> ```
> #!/bin/bash
>
> res=$(git log --oneline | fzf)
> ref=$(echo $res | cut -d ' ' -f1)
>
> git commit --fixup ${ref}
> ```
>
> I don't think fzf is really necessary here, but it speeds things up.
>
> Anyhow, I'm really surprised that this isn't a feature of git.
> I could see a `git commit --fixup` (without a revision) or `git commit
> --fixup --interactive` open up the git log and let one pick the
> revision they want to commit a fixup to.
>
> Cheers,
> Martin

This could be useful for a lot of commands. I use git-notes(1) a lot (just as a niche example). I often wanna just get a list of the last commits (e.g. `@{u}..`) when I want to edit a note. (I should try to use fzf for that, thanks by the way!)

I’m imagining that some RFC implementation of this could get replies like “but why just for `git commit --fixup/--squash…`?”

As far as third-party programs are concerned: see this section of the Lazygit readme:[1]

> Pressing shift+a on any commit will amend that commit with the
> currently staged changes (running an interactive rebase in the
> background).

Not the exact same thing of course. You don’t get intermediary fixup commit since it just runs interactive rebase in the background (so it runs an uninteractive rebase…).

I haven’t tried Lazygit myself.
🔗 1: https://github.com/jesseduffield/lazygit
Previous: Oswald Buddenhagen
Message 12 of 12 in “Feature Request: Interactively pick fixup revision”
  1. Martin ImreNov 9, 2024
  2. rsbecker@nexbridge.comNov 9, 2024
  3. Martin ImreNov 9, 2024
  4. Matěj CeplNov 9, 2024
  5. Kristoffer HaugsbakkNov 9, 2024
  6. Matěj CeplNov 9, 2024
  7. Martin ImreNov 10, 2024
  8. Kristoffer HaugsbakkNov 10, 2024
  9. Stefan HallerNov 10, 2024
  10. Matěj CeplNov 11, 2024
  11. Oswald BuddenhagenNov 16, 2024
  12. Kristoffer HaugsbakkNov 9, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.