rbong / vim-flog

A blazingly fast, stunningly beautiful, exceptionally powerful git branch viewer for Vim/Neovim.
750 stars 22 forks source link

Reword grabs wrong commit #100

Closed jrwrigh closed 1 year ago

jrwrigh commented 1 year ago

Using the reword command (ie. rw), the commit above the cursor is set as reword rather than the commit under the cursor like the documentation says.

Example, if my cursor is on commit ee18212d

• 2023-03-17 21:57:33 -0600 [fa963a7d] {James Wright} (HEAD -> jrwrigh/newtonian_ddsgs) fixup! fluids: Setup strain rate and vorticity projection
• 2023-03-17 21:57:33 -0600 [17c629b1] {James Wright} fixup! fluids: Setup strain rate and vorticity projection
• 2023-03-17 21:57:33 -0600 [ee18212d] {James Wright} fixup! fluids: Setup strain rate and vorticity projection

and I press rw, the subsequent todo list is:

reword 17c629b1 fixup! fluids: Setup strain rate and vorticity projection
pick fa963a7d fixup! fluids: Setup strain rate and vorticity projection

rather than the intended:

reword ee18212d fixup! fluids: Setup strain rate and vorticity projection
pick 17c629b1 fixup! fluids: Setup strain rate and vorticity projection
pick fa963a7d fixup! fluids: Setup strain rate and vorticity projection
rbong commented 1 year ago

Thanks for reporting.

Some context is important here; all rebase commands were changed to target the commit under the cursor rather than the parent of that commit, which is how it worked before. This means that the commit under the cursor no longer appears in the interactive TODO list.

There are a few reasons for this:

1) Targeting the parent is how it works in Fugitive, but we don't necessarily want to copy it in this case. In Fugitive it makes sense to target the parent because you can't actually see the parent of the last commit in the :Git window. In Flog, you can. 2) Targeting the parent makes it impossible to target certain commits - i.e. the tip of a branch. 3) Even though it's less intuitive at times, this is how it works on the CLI. It does not automatically target the parent for you.

All this to say - I've fixed this, but because of the factors above, some rebase commands remain the same. So rw, rm and rd target the parent of the commit under the cursor, while all other rebase commands target the commit under the cursor. So just be aware that these commands work slightly differently and this is why.

Now the rebase system is even less intuitive. I'm not happy with that, but the reasoning is solid.

Side note - because rw, rm and rd target the parent, they don't work with the root commit. git rebase can target the root commit but it requires some extra work. I may fix this if anyone cares enough to post an issue but at this moment it's an edge case and Fugitive has the same problem.

jrwrigh commented 1 year ago

Even though it's less intuitive at times, this is how it works on the CLI. It does not automatically target the parent for you.

Yeah, that's what I figured the primary reason for the behavior was. Thanks for the fix!