lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

lazygit fails to understand rebase editor text when git.core.commentChar is set to ;

Open niv opened this issue 1 year ago • 2 comments

I have commentChar set to ; because # interferes with markdown formatting. This breaks all editor-based interactive operations in lazygit.

To Reproduce

  • git config --global core.commentChar ";"
  • lazygit a git repo and try to move a commit up or down, or delete one.
  • Operation fails with error:
2023/05/05 09:06:20 failed to parse line "; Rebase 4169408..31a7ac7 onto 4169408 (4 comma
nds)": unexpected command
error: There was a problem with the editor '"/opt/homebrew/bin/lazygit"'.

Verified operation works ok if I remove commentChar from git config.

Expected behavior

Lazygit reads commentChar from git config and adjusts it's operation appropriately.

Version info: commit=, build date=, build source=homebrew, version=0.38.2, os=darwin, arch=arm64, git version=2.39.2 (Apple Git-143) git version 2.39.2 (Apple Git-143)

niv avatar May 05 '23 07:05 niv

Interesting, I didn't know you could do that. That's a deficiency in the git-todo-parser package, it hard-codes the comment character to #. We'll have to change the API to allow passing in a different one (I don't think it's the git-todo-parser's responsibility to query the git config).

stefanhaller avatar May 05 '23 07:05 stefanhaller

Or we could just pass -c core.commentChar=# in the git rebase calls we make, that's even easier. Since we never present the git-rebase-todo file to the user, this shouldn't be a problem. (Only when people press "edit" on a commit and then type : git rebase --edit-todo will they see the "wrong" comment character.)

This should be a good first issue; @niv, if you feel like tackling this yourself, there are two git rebase --interactive calls in rebase.go that need to be changed.

stefanhaller avatar May 05 '23 07:05 stefanhaller

This issue is a regression, since lazygit 0.37.0 and earlier versions work fine with a custom commentChar. I am forced to use version 0.37.0 until the bug is fixed.

jusid avatar May 24 '23 08:05 jusid

Fixed by #2639.

stefanhaller avatar Jul 02 '23 07:07 stefanhaller