Re: [PATCH v2 0/3] reflog: add --operations and --historical-branch
- From
D. Ben Knoble <ben.knoble@gmail.com>
- Date
- Oct 24, 2026, 15:22 UTC
- Message-ID
- <CALnO6CCtm2PLOfnNF8p2aGU5Pn71qimdC4aAS130O5PrzQb_oQ@mail.gmail.com>
- In-Reply-To
- <bfc2b43a-6198-47b0-8868-d92551548f22@gmail.com>
On Sat, Oct 24, 2026 at 9:51 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
Show 19 quoted lines
> > Hi Harald > > On 18/10/2026 19:27, Harald Nordgren via GitGitGadget wrote: > > Create a better reflog. Follows the discussion in > > https://lore.kernel.org/git/akZfm-igZKeHaDST@pks.im/. > > > > "git reflog" lists every step of a rebase and every branch switch, which > > makes it hard to see what was done and on which branch. This adds two > > options to "git reflog" and "git log -g": > > > > * --operations shows one entry per command, folding a rebase into the entry > > that finished or aborted it, and leaves out entries that change no > > branch. > > I'm rather skeptical of this in its current form. Not all commands that > modify the working tree update the reflog and some commands such as "git > cherry-pick A B C" create multiple reflog entires that are > indistinguishable from multiple invocations of a single command.
Great point. I thought it was very neat that we could make progress towards this simply by parsing out existing reflogs, but it's always going to be a bit heuristic.
> The > message you cite above is arguing that we need a separate operations log > if we want to overcome these problems.
I also thought this series would be doing something like a true ops log, which would be very cool.
Show 6 quoted lines
> Most of what this option does can > be achieved by looking at the branch reflog instead (I really wish that > "git reflog" defaulted to the current branch rather than HEAD). I'm not > opposed to supporting some kind of filtering/simplification particularly > for HEAD, but we should not pretend we're showing users one entry per > command.
Ditto
Show 9 quoted lines
> > * --historical-branch decorates each entry with the branch HEAD was on when
> > it was recorded.
>
> I quite like this idea, but think it would be nicer implemented as a
> format specifier ("%gb" seems to be free) so that users can use it in
> their custom formats. I'd be quite happy to change the default format do
> for HEAD to include the branch name after the reflog message but I'm not
> sure others would be so keen (perhaps we could get away with guarding
> any change by isatty()/GIT_PAGER_IN_USE?).I'm quite a bit more positive on this change, but I like the composability of a format-specifier. Great idea.
Show 11 quoted lines
> If we're going to do this we should make sure it supports "git rebase
> <upstream> <branch>" so that the branch names are accurate. That is a
> bit involved because you have to compare the name of the branch being
> rebased (which is in the "(finish)" reflog message) to the name of the
> branch that was checked out before (which isn't in that message so you
> have to go looking for a previous rebase or checkout). It also needs to
> take account of rebases that checkout a detached HEAD which don't have
> the "(finish)" message and those that checkout an up-to-date branch or
> detached HEAD where the message is "$GIT_REFLOG_ACTION: checkout
> $revision". I've got a patch [1] that fixes this for "@{-N}" which I
> think works, but it needs some more tests.Ouch. This definitely points to my "heuristic" above, and while we could maybe invest time in the reflog + parsing to make this work, it seems somehow simpler to have an event or ops log with more structure for this new purpose.
-- D. Ben Knoble