{"thread":{"id":"62474","subject":"Feature Request: Interactively pick fixup revision","startedAt":"2024-11-09T11:41:21Z","lastAt":"2024-11-16T17:39:31Z","messageCount":12,"participants":["Martin Imre","rsbecker@nexbridge.com","Matěj Cepl","Kristoffer Haugsbakk","Stefan Haller","Oswald Buddenhagen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"506898","messageId":"CABg7He2asYQbdRvSvfh1YZ2FRPchVfvta8yBv4PFdVNnhzX6Ow@mail.gmail.com","threadId":"62474","inReplyTo":null,"subject":"Feature Request: Interactively pick fixup revision","fromName":"Martin Imre","fromEmail":"martinimre25@gmail.com","sentAt":"2024-11-09T11:41:08Z","receivedAt":"2024-11-09T11:41:21Z","isPatch":false,"sender":{"key":"martinimre25@gmail.com","avatar":null},"body":"Hi,\n\nfirst email to this list, so please forgive me if I'm doing something wrong.\n\nMy usual workflow is using `git commit --fixup <revision>` quite\nfrequently, as it eases the code reviewing process and allows for a\nclean history later on.\n\nOne thing that is always cumbersome is to first find the SHA of the\nrevision that I plan to commit a fixup to.\nI usually use git log and then copy the revision.\nI even wrote a script that eases this process using fzf:\n```\n#!/bin/bash\n\nres=$(git log --oneline | fzf)\nref=$(echo $res | cut -d ' ' -f1)\n\ngit commit --fixup ${ref}\n```\n\nI don't think fzf is really necessary here, but it speeds things up.\n\nAnyhow, I'm really surprised that this isn't a feature of git.\nI could see a `git commit --fixup` (without a revision) or `git commit\n--fixup --interactive` open up the git log and let one pick the\nrevision they want to commit a fixup to.\n\nCheers,\nMartin\n"},{"id":"506901","messageId":"03c201db32a8$96e66e20$c4b34a60$@nexbridge.com","threadId":"62474","inReplyTo":"CABg7He2asYQbdRvSvfh1YZ2FRPchVfvta8yBv4PFdVNnhzX6Ow@mail.gmail.com","subject":"RE: Feature Request: Interactively pick fixup revision","fromName":"","fromEmail":"rsbecker@nexbridge.com","sentAt":"2024-11-09T13:09:14Z","receivedAt":"2024-11-09T13:14:14Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On November 9, 2024 6:41 AM, Martin Imre wrote:\n>first email to this list, so please forgive me if I'm doing something wrong.\n>\n>My usual workflow is using `git commit --fixup <revision>` quite frequently, as it\n>eases the code reviewing process and allows for a clean history later on.\n>\n>One thing that is always cumbersome is to first find the SHA of the revision that I\n>plan to commit a fixup to.\n>I usually use git log and then copy the revision.\n>I even wrote a script that eases this process using fzf:\n>```\n>#!/bin/bash\n>\n>res=$(git log --oneline | fzf)\n>ref=$(echo $res | cut -d ' ' -f1)\n>\n>git commit --fixup ${ref}\n>```\n>\n>I don't think fzf is really necessary here, but it speeds things up.\n>\n>Anyhow, I'm really surprised that this isn't a feature of git.\n>I could see a `git commit --fixup` (without a revision) or `git commit --fixup --\n>interactive` open up the git log and let one pick the revision they want to commit a\n>fixup to.\n\nYou might find that git rebase --autosquash -i <commit> might do what\nyou are looking for. This allows you to clean up your topic branch prior\nto creating a pull request. Loads of documentation online about its use.\n\nGood luck,\nRandall\n\n"},{"id":"506902","messageId":"CABg7He38ctGSx75HLw7xgu85nBUFAgwtxmJS4b5iBhGgoCu-ug@mail.gmail.com","threadId":"62474","inReplyTo":"03c201db32a8$96e66e20$c4b34a60$@nexbridge.com","subject":"Re: Feature Request: Interactively pick fixup revision","fromName":"Martin Imre","fromEmail":"martinimre25@gmail.com","sentAt":"2024-11-09T13:39:53Z","receivedAt":"2024-11-09T13:40:07Z","isPatch":false,"sender":{"key":"martinimre25@gmail.com","avatar":null},"body":"On Sat, Nov 9, 2context for all your replies. Please also see\nbelow.024 at 2:09 PM <rsbecker@nexbridge.com> wrote:\n>\n> On November 9, 2024 6:41 AM, Martin Imre wrote:\n> >first email to this list, so please forgive me if I'm doing something wrong.\n> >\n> >My usual workflow is using `git commit --fixup <revision>` quite frequently, as it\n> >eases the code reviewing process and allows for a clean history later on.\n> >\n> >One thing that is always cumbersome is to first find the SHA of the revision that I\n> >plan to commit a fixup to.\n> >I usually use git log and then copy the revision.\n> >I even wrote a script that eases this process using fzf:\n> >```\n> >#!/bin/bash\n> >\n> >res=$(git log --oneline | fzf)\n> >ref=$(echo $res | cut -d ' ' -f1)\n> >\n> >git commit --fixup ${ref}\n> >```\n> >\n> >I don't think fzf is really necessary here, but it speeds things up.\n> >\n> >Anyhow, I'm really surprised that this isn't a feature of git.\n> >I could see a `git commit --fixup` (without a revision) or `git commit --fixup --\n> >interactive` open up the git log and let one pick the revision they want to commit a\n> >fixup to.\n>\n> You might find that git rebase --autosquash -i <commit> might do what\n> you are looking for. This allows you to clean up your topic branch prior\n> to creating a pull request. Loads of documentation online about its use.\n>\n> Good luck,\n> Randall\n>\n\nI think you might have misunderstood what I'm trying to achieve.\n\nAfter adding a fixup commit, I'm anyway running `git rebase\n--autosquash -i <commit>`.\n\nHowever, my request is to get an interactive way to pick _which_\ncommit a fixup is targeting.\nIe, I'm trying to run something that pops up a pager with the commit\nlog for me to pick a commit that is then passed to `git commit --fixup\n<commit>`.\n\nIf you have fzf, try running my script in a git repo with some changes\nand you'll see what I'm trying to achieve.\n\nCheers,\nMartin\n"},{"id":"506909","messageId":"D5HQH12Y4SWF.2W70SKEDB7HBF@cepl.eu","threadId":"62474","inReplyTo":"CABg7He2asYQbdRvSvfh1YZ2FRPchVfvta8yBv4PFdVNnhzX6Ow@mail.gmail.com","subject":"Re: Feature Request: Interactively pick fixup revision","fromName":"Matěj Cepl","fromEmail":"mcepl@cepl.eu","sentAt":"2024-11-09T14:55:44Z","receivedAt":"2024-11-09T15:04:45Z","isPatch":false,"sender":{"key":"mcepl@cepl.eu","avatar":"https://avatars.githubusercontent.com/u/198999?v=4"},"body":"On Sat Nov 9, 2024 at 12:41 PM CET, Martin Imre wrote:\n> My usual workflow is using `git commit --fixup <revision>` quite\n> frequently, as it eases the code reviewing process and allows for a\n> clean history later on.\n\nhttps://github.com/keis/git-fixup/\n\nbut at least as a minimal improvement, I would limit list of\ncommits to those which are touched in the staging area:\n\n  ref=$(git log --oneline -- $(git diff --cached|lsdiff --strip 1)|fzf|cut -d ' ' -f1)\n\n(lsdiff is from patchutils)\n\nBest,\n\nMatěj\n\n-- \nhttp://matej.ceplovi.cz/blog/, @mcepl@floss.social\nGPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8\n \nTy zlý dávaj’ ty hodný pryč. // Those evil ones put away those good ones.\n  -- Magda Ceplová\n\n"},{"id":"506911","messageId":"1d383dbd-a409-4199-84bc-652784835167@app.fastmail.com","threadId":"62474","inReplyTo":"CABg7He2asYQbdRvSvfh1YZ2FRPchVfvta8yBv4PFdVNnhzX6Ow@mail.gmail.com","subject":"Re: Feature Request: Interactively pick fixup revision","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2024-11-09T17:08:36Z","receivedAt":"2024-11-09T17:08:59Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Sat, Nov 9, 2024, at 12:41, Martin Imre wrote:\n> Hi,\n>\n> first email to this list, so please forgive me if I'm doing something wrong.\n>\n> My usual workflow is using `git commit --fixup <revision>` quite\n> frequently, as it eases the code reviewing process and allows for a\n> clean history later on.\n>\n> One thing that is always cumbersome is to first find the SHA of the\n> revision that I plan to commit a fixup to.\n> I usually use git log and then copy the revision.\n> I even wrote a script that eases this process using fzf:\n> ```\n> #!/bin/bash\n>\n> res=$(git log --oneline | fzf)\n> ref=$(echo $res | cut -d ' ' -f1)\n>\n> git commit --fixup ${ref}\n> ```\n>\n> I don't think fzf is really necessary here, but it speeds things up.\n>\n> Anyhow, I'm really surprised that this isn't a feature of git.\n> I could see a `git commit --fixup` (without a revision) or `git commit\n> --fixup --interactive` open up the git log and let one pick the\n> revision they want to commit a fixup to.\n>\n> Cheers,\n> Martin\n\nThis could be useful for a lot of commands.  I use git-notes(1) a lot\n(just as a niche example).  I often wanna just get a list of the last\ncommits (e.g. `@{u}..`) when I want to edit a note.  (I should try to\nuse fzf for that, thanks by the way!)\n\nI’m imagining that some RFC implementation of this could get replies\nlike “but why just for `git commit --fixup/--squash…`?”\n\nAs far as third-party programs are concerned: see this section of the\nLazygit readme:[1]\n\n> Pressing shift+a on any commit will amend that commit with the\n> currently staged changes (running an interactive rebase in the\n> background).\n\nNot the exact same thing of course.  You don’t get intermediary fixup\ncommit since it just runs interactive rebase in the background (so it\nruns an uninteractive rebase…).\n\nI haven’t tried Lazygit myself.\n\n🔗 1: https://github.com/jesseduffield/lazygit\n"},{"id":"506912","messageId":"debabf92-7d23-4d17-bb0e-36691c94430a@app.fastmail.com","threadId":"62474","inReplyTo":"D5HQH12Y4SWF.2W70SKEDB7HBF@cepl.eu","subject":"Re: Feature Request: Interactively pick fixup revision","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2024-11-09T17:13:16Z","receivedAt":"2024-11-09T17:13:38Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Sat, Nov 9, 2024, at 15:55, Matěj Cepl wrote:\n> On Sat Nov 9, 2024 at 12:41 PM CET, Martin Imre wrote:\n>> My usual workflow is using `git commit --fixup <revision>` quite\n>> frequently, as it eases the code reviewing process and allows for a\n>> clean history later on.\n>\n> https://github.com/keis/git-fixup/\n>\n> but at least as a minimal improvement, I would limit list of\n> commits to those which are touched in the staging area:\n>\n>   ref=$(git log --oneline -- $(git diff --cached|lsdiff --strip\n> 1)|fzf|cut -d ' ' -f1)\n>\n> (lsdiff is from patchutils)\n\nThis or git-absorb(1) (I have only tried the latter) is good if you want\nto fixup previously touched lines.  That is likely to be the case for a\nfixup command.  But maybe you for example want to add a test to some\nchange which is in a different file.  In which case you want to pick the\ncommit manually.\n\nI haven’t heard of lsdiff(1) though.  That’s something I have been\nwanting lately.  Thanks.\n\n-- \nKristoffer Haugsbakk\n\n"},{"id":"506923","messageId":"D5HWL26B3HOT.1ZVXUC37BCGL@cepl.eu","threadId":"62474","inReplyTo":"debabf92-7d23-4d17-bb0e-36691c94430a@app.fastmail.com","subject":"Re: Feature Request: Interactively pick fixup revision","fromName":"Matěj Cepl","fromEmail":"mcepl@cepl.eu","sentAt":"2024-11-09T19:43:07Z","receivedAt":"2024-11-09T19:43:09Z","isPatch":false,"sender":{"key":"mcepl@cepl.eu","avatar":"https://avatars.githubusercontent.com/u/198999?v=4"},"body":"On Sat Nov 9, 2024 at 6:13 PM CET, Kristoffer Haugsbakk wrote:\n> I haven’t heard of lsdiff(1) though.  That’s something I have been\n> wanting lately.  Thanks.\n\nhttps://github.com/twaugh/patchutils (part of any Linux distro)\n… it is absolutely indispensable set of tools for any developer,\nIMHO.\n\nMatěj\n\n-- \nhttp://matej.ceplovi.cz/blog/, @mcepl@floss.social\nGPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8\n \nThe state is the great fictitious entity by which everyone seeks\nto live at the expense of everyone else.\n      -- Frederick Bastiat\n\n"},{"id":"506926","messageId":"CABg7He0upi8kmagGO13UMwSWOLeHoryZQU5CGsfbhgqedBKw=Q@mail.gmail.com","threadId":"62474","inReplyTo":"D5HWL26B3HOT.1ZVXUC37BCGL@cepl.eu","subject":"Re: Feature Request: Interactively pick fixup revision","fromName":"Martin Imre","fromEmail":"martinimre25@gmail.com","sentAt":"2024-11-10T07:55:25Z","receivedAt":"2024-11-10T07:55:37Z","isPatch":false,"sender":{"key":"martinimre25@gmail.com","avatar":null},"body":"Thanks for pointing me towards https://github.com/keis/git-fixup/ and\ngit-absorb (https://github.com/tummychow/git-absorb).\nI'll try them out and see if I like the ergonomics of them.\n\nJust as a general question: With 2 (or even more) different\nimplementations that solve the same problem, wouldn't this be a good\naddition for a future version of git?\n\nAlso, out of curiosity, how do they achieve their binaries to be\ncalled as git commands, ie, why can I call the binary `git-fixup` via\n`git fixup`?\n\nCheers,\nMartin\n"},{"id":"506927","messageId":"7c1cb2ca-308f-482c-aaac-5ca30b47da2b@app.fastmail.com","threadId":"62474","inReplyTo":"CABg7He0upi8kmagGO13UMwSWOLeHoryZQU5CGsfbhgqedBKw=Q@mail.gmail.com","subject":"Re: Feature Request: Interactively pick fixup revision","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2024-11-10T07:59:48Z","receivedAt":"2024-11-10T08:00:11Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Sun, Nov 10, 2024, at 08:55, Martin Imre wrote:\n> Also, out of curiosity, how do they achieve their binaries to be\n> called as git commands, ie, why can I call the binary `git-fixup` via\n> `git fixup`?\n\nThey don’t do anything special.  Any script or binary that you define\nyourself will be treated the same.  `git` takes care of it.\n"},{"id":"506941","messageId":"d9832c11-7c2b-43a8-a7d7-a1de137a5b13@haller-berlin.de","threadId":"62474","inReplyTo":"CABg7He0upi8kmagGO13UMwSWOLeHoryZQU5CGsfbhgqedBKw=Q@mail.gmail.com","subject":"Re: Feature Request: Interactively pick fixup revision","fromName":"Stefan Haller","fromEmail":"lists@haller-berlin.de","sentAt":"2024-11-10T16:09:12Z","receivedAt":"2024-11-10T16:19:05Z","isPatch":false,"sender":{"key":"lists@haller-berlin.de","avatar":null},"body":"On 10.11.24 08:55, Martin Imre wrote:\n> Thanks for pointing me towards https://github.com/keis/git-fixup/ and\n> git-absorb (https://github.com/tummychow/git-absorb).\n> I'll try them out and see if I like the ergonomics of them.\n> \n> Just as a general question: With 2 (or even more) different\n> implementations that solve the same problem, wouldn't this be a good\n> addition for a future version of git?\n\nI'll throw a third one into the mix: lazygit. It's a TUI client that has\nsimilar functionality built in. (See [1])\n\nAs for why this isn't built in: there are a lot of subtleties to how\nexactly it works, and people might not agree on these. For example,\ngit-absorb seems to have certain design goals that I don't agree with; I\nhave written a longish document about that if you're interested. [2]\n\n\n[1] <https://github.com/jesseduffield/lazygit/blob/master/\n     docs/Fixup_Commits.md#finding-the-commit-to-create-a-fixup-for>\n\n[2] <https://github.com/jesseduffield/lazygit/blob/master/docs/\n     dev/Find_Base_Commit_For_Fixup_Design.md>\n\n"},{"id":"506958","messageId":"D5J0DCN2Y2V1.3C2JLTMGY8VAM@cepl.eu","threadId":"62474","inReplyTo":"CABg7He0upi8kmagGO13UMwSWOLeHoryZQU5CGsfbhgqedBKw=Q@mail.gmail.com","subject":"Re: Feature Request: Interactively pick fixup revision","fromName":"Matěj Cepl","fromEmail":"mcepl@cepl.eu","sentAt":"2024-11-11T02:53:47Z","receivedAt":"2024-11-11T02:53:55Z","isPatch":false,"sender":{"key":"mcepl@cepl.eu","avatar":"https://avatars.githubusercontent.com/u/198999?v=4"},"body":"On Sun Nov 10, 2024 at 8:55 AM CET, Martin Imre wrote:\n> Just as a general question: With 2 (or even more) different\n> implementations that solve the same problem, wouldn’t this be a good\n> addition for a future version of git?\n\nThere are few problems, one which is the implementation language:\ngit-absorb is Rust and git-fixup is bash (using arrays and other\nnon-POSIX constructs).\n\nDocumentation/howto/new-command.txt declares:\n\n    Most subcommands are written in C or shell.  A few are written in\n    Perl.\n\n    (And Python scripts are allowed for some specific tasks, namely GUI)\n\nShell script here quite emphatically means POSIX shell (or at\nleast not using widely non-POSIX constructs like arrays), not\nbash. In order to even be able to consider any of these commands\nto be submitted to git proper, it would have to be ported first.\n\nBest,\n\nMatěj\n\n-- \nhttp://matej.ceplovi.cz/blog/, @mcepl@floss.social\nGPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8\n \nNever ascribe to malice that which is adequately explained by\nstupidity.\n    -- Napoleon Bonaparte (or many other people to whom this\n       quote is ascribed)\n\n"},{"id":"507412","messageId":"ZzjYzTfmZLVXgJ9R@ugly","threadId":"62474","inReplyTo":"D5J0DCN2Y2V1.3C2JLTMGY8VAM@cepl.eu","subject":"Re: Feature Request: Interactively pick fixup revision","fromName":"Oswald Buddenhagen","fromEmail":"oswald.buddenhagen@gmx.de","sentAt":"2024-11-16T17:39:25Z","receivedAt":"2024-11-16T17:39:31Z","isPatch":false,"sender":{"key":"oswald.buddenhagen@gmx.de","avatar":"https://avatars.githubusercontent.com/u/812380?v=4"},"body":"On Mon, 11 Nov 2024 03:53:47 +0100, Matěj Cepl wrote:\n> On Sun Nov 10, 2024 at 8:55 AM CET, Martin Imre wrote:\n> > Just as a general question: With 2 (or even more) different\n> > implementations that solve the same problem, wouldn’t this be a good\n> > addition for a future version of git?\n>\n> There are few problems, one which is the implementation language:\n> git-absorb is Rust and git-fixup is bash (using arrays and other\n> non-POSIX constructs).\n>\nfwiw, i just stumbled over https://github.com/torbiak/git-autofixup\nwhich is written in perl. no idea how good it is compared to git-absorb.\n\n"}]}