lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

When rewording a merge commit with the editor, lazygit calls git incorrectly

Open nullishamy opened this issue 3 years ago • 16 comments

Describe the bug When rewording a merge commit using the editor, lazy git calls git with an incorrect set of arguments. This results in the operation failing.

To Reproduce Steps to reproduce the behavior:

  1. Create a merge commit
  2. Reword it with the editor
  3. Observe failed editor launch

Expected behavior The editor should open without issue, allowing a reword.

Screenshots image

Desktop (please complete the following information):

  • OS: Arch
  • Lazygit Version 0.35.367b0d33

nullishamy avatar Jul 27 '22 16:07 nullishamy

Note: it works fine using the builtin editor.

nullishamy avatar Jul 27 '22 16:07 nullishamy

For the time being, does the merge commit you're trying to reword happen to be the same as HEAD?

If so, could you give #2065 a spin to see if it helps?

mark2185 avatar Jul 29 '22 06:07 mark2185

Yeah, it was the HEAD commit. I'll try that PR now, do you have instructions on how to grab it? Will i just clone & compile or is there another process?

nullishamy avatar Jul 29 '22 20:07 nullishamy

Just clone it, be sure to check out the branch, and run it with go run main.go.

mark2185 avatar Jul 29 '22 21:07 mark2185

Got it, also in my testing today I am realising that the merge could not have been HEAD, because when it is actually HEAD, lazygit just runs git commit --amend instead of the previously posted git rebase.

nullishamy avatar Jul 29 '22 21:07 nullishamy

That branch did not fix the issue.

nullishamy avatar Jul 29 '22 21:07 nullishamy

Strangely, it now complains that rewording is not available for GPG users when using the builtin editor, which was not the case when i last tested. I did testing in /tmp the last time and have since rebooted, so i'm not sure if that's the issue?

EDIT: With further testing, it's probably because it cant resign the commits if they arent the HEAD? I'm not sure, this limitation doesnt exist within git itself though.

nullishamy avatar Jul 29 '22 21:07 nullishamy

lazygit just runs git commit --amend instead of the previously posted git rebase

When using editor on current master to reword a commit it always starts an interactive rebase. It shouldn't be so, but hey.

I did testing in /tmp the last time and have since rebooted, so i'm not sure if that's the issue?

I've had issues using my editor in /tmp for some reason, never got to the bottom of it, though. I'd advise cloning the repo somewhere else in your $HOME.

With further testing, it's probably because it cant resign the commits if they arent the HEAD?

Uhhh... now it literally runs git commit --allow-empty --amend --only, does that work when invoked from the CLI?

mark2185 avatar Jul 29 '22 21:07 mark2185

I can try moving the repo, just to rule it out.

The command mentioned does work from the CLI, though of course it just redoes HEAD, which worked anyways.

nullishamy avatar Jul 29 '22 21:07 nullishamy

Very strange behaviour indeed.

nullishamy avatar Jul 29 '22 21:07 nullishamy

which worked anyways

Not with the editor it didn't :)

mark2185 avatar Jul 29 '22 21:07 mark2185

That was an error in my part:

[..] I am realising that the merge could not have been HEAD, because when it is actually HEAD, lazygit just runs git commit --amend instead of the previously posted git rebase.

The amend command works, including with the editor, its the rebase thats failing.

nullishamy avatar Jul 29 '22 21:07 nullishamy

To summarise:

Reword HEAD (builtin): Works (uses --amend) Reword HEAD (editor): Works (uses --amend)

Reword not HEAD (builtin): Does not work, complains about GPG (uses rebase) Reword not HEAD (editor): Does not work, git errors (uses rebase)

(All of them operating on merge commits)

nullishamy avatar Jul 29 '22 21:07 nullishamy

The amend command works, including with the editor, its the rebase thats failing.

On master it didn't work, on the PR it should work.

The amend command works, including with the editor, its the rebase thats failing.

Alright, then we need a bit deeper rework. Thanks for the report!

If you'd be willing to take a dive, please let us know and feel free to visit us on slack if you need any pointers or have questions!

mark2185 avatar Jul 29 '22 21:07 mark2185

Ah, right, yeah. The reword on HEAD works fine on the PR branch. I can take a look now, I don't have much go knowledge but it should be enough to make this work. Should I just PR / push onto the existing fix branch?

As for slack, I'll need to grab an account, and I'll see you there.

nullishamy avatar Jul 29 '22 21:07 nullishamy

Should I just PR / push onto the existing fix branch?

I believe you don't have the permission to do that, but you can create a fork.

I don't have much go knowledge but it should be enough to make this work.

I don't think knowledge of go (or lack thereof) will be a problem here, git intricacies might be, though.

mark2185 avatar Jul 29 '22 21:07 mark2185