jesseduffield / lazygit

simple terminal UI for git commands
MIT License
52.99k stars 1.85k forks source link

Lazygit can't launch editor when adding a tag, even though it launches the editor for commits. #3423

Open jbrains opened 7 months ago

jbrains commented 7 months ago

Describe the bug

When I use the command T to add a tag, lazygit doesn't launch my editor, even though it launches the editor correctly for commit messages, both for new commits and rewording existing commits.

To Reproduce

  1. Select a commit.
  2. T
  3. Enter a tag name.
Fatal error: stdout is not a tty.
error: There was a problem with the editor (path to correct editor executable).
Please supply the message using either -m or -F option.

Expected behavior

Lazygit opens my editor so that I can enter a message.

Version info: I ran this on 2024-03-24 at 11:29 ADT.

go install github.com/jesseduffield/lazygit@latest

go: downloading github.com/jesseduffield/lazygit v0.41.0
go: downloading github.com/jesseduffield/gocui v0.3.1-0.20240309085756-86e0d5a312de
go: downloading github.com/adrg/xdg v0.4.0
go: downloading github.com/gdamore/tcell/v2 v2.7.4

The problem persists.

Additional context I haven't used tags in a long time, so I can't remember whether this has ever worked or always failed. When I run exactly the same command from my shell, everything works fine. I used lazygit --debug to copy/paste the exact command that lazygit runs.

stefanhaller commented 7 months ago

I'm confused. Lazygit is not supposed to open an editor when creating a tag. It opens its own message panel which lets you enter the tag name, and optionally a tag description; if you enter a description, it creates an annotated tag, otherwise a lightweight tag. No editor involved.

I used lazygit --debug to copy/paste the exact command that lazygit runs.

And what was it? I don't see it in your bug report. You should also see the exact command in lazygit's command log panel (in the lower right of the window, you can open it with @ if you don't see it).

jbrains commented 7 months ago

The command was

git tag -- <sha1>

When I run this from the command line, it opens $EDITOR so that I can annotate the tag.

I presume that if I don't enter a "Tag description" in lazygit's window, then git tries to open the editor. I infer from your comment that that isn't supported.

At best, then, this is a confusing user experience. :)

Indeed, when I enter text into the "Tag description" window, lazygit creates an annotated tag without any problems.

It seems, then, that I can't create a lightweight tag, but only an annotated one. Why might that be?

stefanhaller commented 7 months ago

The command was

git tag -- <sha1>

I find this hard to believe. No tag name? Lazygit uses the command git tag -- <tagname> <sha1> to create a lightweight tag.

When I run this from the command line, it opens $EDITOR so that I can annotate the tag.

Again I can only assume that this wasn't the exact command line that you typed, as this would have created a lightweight tag from HEAD with the name <sha1>.

But what's puzzling is that you get the editor. This sounds as if you had typed git tag -a, but you didn't (and neither did lazygit, of course). It sounds like there might be a git config that makes -a the default for every tag, but I couldn't find any such option. Weird.

jbrains commented 7 months ago

The command was

git tag -- <sha1>

I find this hard to believe. No tag name? Lazygit uses the command git tag -- to create a lightweight tag.

Indeed, I got that wrong. I just tried again and here is the relevant log output.

Mar 27 10:27:35 |DEBU| RunCommand command="git tag -- draft-0 10d8ec03c6b1bd4ffec012cd44c4df5dacd44203"
Mar 27 10:27:35 |ERRO| Fatal error: stdout is not a tty                                                                                           error: There was a problem with the editor '/home/jbrains/.local/bin/kak'.  
Please supply the message using either -m or -F option.                                                                                                                                                                    
Mar 27 10:27:35 |INFO| git tag -- draft-0 10d8ec03c6b1bd4ffec012cd44c4df5dacd44203 (98.715059ms) 
Mar 27 10:27:35 |INFO| refreshing all scopes in async mode       

But what's puzzling is that you get the editor. This sounds as if you had typed git tag -a, but you didn't (and neither did lazygit, of course). It sounds like there might be a git config that makes -a the default for every tag, but I couldn't find any such option. Weird.

I went in search of the same kind of setting and didn't find one. I am hoping that someone here can suggest where to look. I went to the various git configuration files and saw nothing obvious. I'm searching all my dotfiles right now.