Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazygit hangs terminal on listing commits #3529

Open
Ziwi01 opened this issue Apr 26, 2024 · 10 comments · May be fixed by #3533
Open

Lazygit hangs terminal on listing commits #3529

Ziwi01 opened this issue Apr 26, 2024 · 10 comments · May be fixed by #3533
Labels
bug Something isn't working

Comments

@Ziwi01
Copy link

Ziwi01 commented Apr 26, 2024

Describe the bug
I have a weird issue that Lazygit does not list the commits in the [4] Commits window (but it lists them in the Log graph window on the right hand side - see screenshot below). Moreover, when trying to do any operation on that branch, like trying to checkout different branch or list the commits by using in [3] Local branches view, the terminal hangs (in a way it has to be killed entirely).

The weird thing about this is that it is happening only in one particular repository on one particular branch (and any branches created from it). It doesn't happen for the same repo with a branch not derived from the develop (the problematic branch).

It started somewhat after updating lazygit from 0.40.x but I tried downgrading to 0.40.2 and the same happens. At this point I'm clueless and desperate as it really messed up my workflow.. Please help, any ideas are appreciated.

Testing
I tried to

  • re-clone the repo
  • run git fsck (no errors)
  • browse through commits until a merge-base of working branch (master) - nothing weird
  • reconfigured showUntrackedFiles
  • clean the .git objects and reset, update index
  • run all commands from lazygit --debug manually in the terminal. Nothing seems to return any error or hang the terminal
  • upgrade lazygit to latest build from master
  • go back to 0.40.2

Below is the debug log output from starting lazygit to issuing on [3] Local branches, which hangs the terminal:

Apr 26 19:21:17 |INFO| Receiving focus - refreshing
Apr 26 19:21:17 |INFO| refreshing all scopes in async mode
Apr 26 19:21:17 |INFO| Refresh took 105.474µs
Apr 26 19:21:17 |DEBU| using cache for key status.showUntrackedFiles
Apr 26 19:21:17 |DEBU| RunCommand command="git stash list -z --pretty=%ct|%gs"
Apr 26 19:21:17 |DEBU| RunCommand command="git merge-base refs/heads/develop develop@{u}"
Apr 26 19:21:17 |DEBU| RunCommand command="git status --untracked-files=all --porcelain -z"
Apr 26 19:21:17 |DEBU| RunCommand command="git tag --list -n --sort=-creatordate"
Apr 26 19:21:17 |DEBU| RunCommand command="git merge-base refs/heads/develop refs/remotes/origin/master"
Apr 26 19:21:17 |INFO| git stash list -z --pretty=%ct|%gs (1.983116ms)
Apr 26 19:21:17 |INFO| postRefreshUpdate for stash took 69.284µs
Apr 26 19:21:17 |INFO| git merge-base refs/heads/develop develop@{u} (2.189666ms)
Apr 26 19:21:17 |INFO| git -c log.showSignature=false log -g --abbrev=40 --format=%h%x00%ct%x00%gs%x00%p (2.617862ms)
Apr 26 19:21:17 |INFO| postRefreshUpdate for reflogCommits took 2.170871ms
Apr 26 19:21:17 |INFO| git tag --list -n --sort=-creatordate (5.262017ms)
Apr 26 19:21:17 |INFO| git for-each-ref --sort=-committerdate --format=%(refname:short) refs/remotes (5.744ms)
Apr 26 19:21:17 |INFO| postRefreshUpdate for remotes took 149.964µs
Apr 26 19:21:17 |INFO| postRefreshUpdate for remoteBranches took 24.894µs
Apr 26 19:21:17 |INFO| git merge-base refs/heads/develop refs/remotes/origin/master (8.076531ms)
Apr 26 19:21:17 |INFO| postRefreshUpdate for tags took 7.205243ms
Apr 26 19:21:17 |INFO| git status --untracked-files=all --porcelain -z (105.071484ms)
Apr 26 19:21:23 |INFO| refreshing the following scopes in sync mode: files
Apr 26 19:21:23 |INFO| refreshed merge conflicts in 13.297µs
Apr 26 19:21:23 |DEBU| using cache for key status.showUntrackedFiles
Apr 26 19:21:23 |DEBU| RunCommand command="git status --untracked-files=all --porcelain -z"
Apr 26 19:21:23 |INFO| git status --untracked-files=all --porcelain -z (98.220525ms)
Apr 26 19:21:23 |INFO| refreshed files in 98.665017ms
Apr 26 19:21:23 |INFO| Refresh took 99.019232ms
Apr 26 19:21:33 |INFO| refreshing the following scopes in sync mode: files
Apr 26 19:21:33 |INFO| refreshed merge conflicts in 4.099µs
Apr 26 19:21:33 |DEBU| using cache for key status.showUntrackedFiles
Apr 26 19:21:33 |DEBU| RunCommand command="git status --untracked-files=all --porcelain -z"
Apr 26 19:21:33 |INFO| git status --untracked-files=all --porcelain -z (80.626224ms)
Apr 26 19:21:33 |INFO| refreshed files in 81.263667ms
Apr 26 19:21:33 |INFO| Refresh took 81.691062ms

To Reproduce
No clue how to reproduce that as it happens only on one branch on particular repository

Expected behavior
Commits are listed properly in Commit window, Lazygit does not hang the terminal when trying to enter branch commits or checkout another branch

Screenshots
lazygit-issue

Version info:
commit=aa81e191e2905e6959f1d8e51c8589764ca0c520, build date=2024-04-25T06:53:14Z, build source=unknown, version=aa81e191, os=linux, arch=amd64, git version=2.43.2
Ubuntu 22.04 on WSL2

@Ziwi01 Ziwi01 added the bug Something isn't working label Apr 26, 2024
@stefanhaller
Copy link
Collaborator

I don't suppose you can share that repo?

@Ziwi01
Copy link
Author

Ziwi01 commented Apr 26, 2024

I'm afraid not, unfortunately.

@stefanhaller
Copy link
Collaborator

Ok, then it's going to be a bit more cumbersome to figure this out...

My suspicion is that it has something to do with the git log command that lazygit issues to load the commits. I don't see this in the log that you posted; look for a line that has -300 in it. Can you issue that command in the terminal (when the branch is checked out) and see if anything looks unusual about it?

@Ziwi01
Copy link
Author

Ziwi01 commented Apr 26, 2024

I don't see any lines starting with -300. However, when starting the --logs first and then lazygit debug, I can see couple errors on startup, but doesn't seem related.

Errors:

Apr 26 21:51:33 |DEBU| Error getting git config value for key: rebase.updateRefs. Error: the key is not found for [git config --get --null rebase.updateRefs]
Apr 26 21:51:33 |ERRO| fatal: no such branch: 'main'
 command="git rev-parse --symbolic-full-name main@{u}"
Apr 26 21:51:33 |ERRO| <no msg> command="git rev-parse --verify --quiet refs/remotes/origin/main"
Apr 26 21:51:33 |ERRO| <no msg> command="git rev-parse --verify --quiet refs/heads/main"

Not sure why it is trying to reach out for main branch, as its not there. After creating main branch on both local and remote the errors are gone, except the updateRefs one.

Full log:

Apr 26 21:51:33 |INFO| language: C
Apr 26 21:51:33 |DEBU| RunCommand command="git --version"
Apr 26 21:51:33 |INFO| git --version (2.095629ms)
Apr 26 21:51:33 |DEBU| RunCommand command="git rev-parse --git-dir"
Apr 26 21:51:33 |INFO| git rev-parse --git-dir (4.186858ms)
Apr 26 21:51:33 |DEBU| RunCommand command="git rev-parse --is-bare-repository"
Apr 26 21:51:33 |INFO| git rev-parse --is-bare-repository (3.135544ms)
Apr 26 21:51:33 |DEBU| RunCommand command="git rev-parse --path-format=absolute --show-toplevel --absolute-git-dir --git-common-dir --show-superproject-working-tree"
Apr 26 21:51:33 |INFO| git rev-parse --path-format=absolute --show-toplevel --absolute-git-dir --git-common-dir --show-superproject-working-tree (4.938524ms)
Apr 26 21:51:33 |INFO| starting main loop
Apr 26 21:51:33 |INFO| Binary is not built with the buildBinary flag so we won't check for an update
Apr 26 21:51:33 |DEBU| RunCommand command="git rev-parse --is-bare-repository"
Apr 26 21:51:33 |DEBU| RunCommand command="git fetch --all --no-write-fetch-head"
Apr 26 21:51:33 |INFO| git rev-parse --is-bare-repository (2.220506ms)
Apr 26 21:51:33 |INFO| refreshing all scopes in async mode
Apr 26 21:51:33 |INFO| Refresh took 213.962µs
Apr 26 21:51:33 |DEBU| RunCommand command="git for-each-ref --sort=-committerdate --format=%(HEAD)%00%(refname:short)%00%(upstream:short)%00%(upstream:track)%00%(subject)%00%(objectname)%00%(committerdate:unix) refs/heads"
Apr 26 21:51:33 |DEBU| RunCommand command="git tag --list -n --sort=-creatordate"
Apr 26 21:51:33 |DEBU| RunCommand command="git stash list -z --pretty=%ct|%gs"
Apr 26 21:51:33 |DEBU| RunCommand command="git rev-parse --abbrev-ref --verify HEAD"
Apr 26 21:51:33 |DEBU| Error getting git config value for key: rebase.updateRefs. Error: the key is not found for [git config --get --null rebase.updateRefs]
Apr 26 21:51:33 |INFO| git stash list -z --pretty=%ct|%gs (2.025941ms)
Apr 26 21:51:33 |INFO| git rev-parse --abbrev-ref --verify HEAD (1.981649ms)
Apr 26 21:51:33 |INFO| postRefreshUpdate for stash took 216.862µs
Apr 26 21:51:33 |DEBU| RunCommand command="git merge-base develop develop@{u}"
Apr 26 21:51:33 |DEBU| RunCommand command="git rev-parse --symbolic-full-name main@{u}"
Apr 26 21:51:33 |DEBU| RunCommand command="git rev-parse --symbolic-full-name master@{u}"
Apr 26 21:51:33 |ERRO| fatal: no such branch: 'main'
 command="git rev-parse --symbolic-full-name main@{u}"
Apr 26 21:51:33 |INFO| git rev-parse --symbolic-full-name main@{u} (1.893664ms)
Apr 26 21:51:33 |INFO| git rev-parse --symbolic-full-name master@{u} (1.878067ms)
Apr 26 21:51:33 |DEBU| RunCommand command="git status --untracked-files=all --porcelain -z"
Apr 26 21:51:33 |INFO| git merge-base develop develop@{u} (3.21383ms)
Apr 26 21:51:33 |DEBU| RunCommand command="git rev-parse --verify --quiet refs/remotes/origin/main"
Apr 26 21:51:33 |INFO| git tag --list -n --sort=-creatordate (7.127036ms)
Apr 26 21:51:33 |ERRO| <no msg> command="git rev-parse --verify --quiet refs/remotes/origin/main"
Apr 26 21:51:33 |INFO| git rev-parse --verify --quiet refs/remotes/origin/main (3.863615ms)
Apr 26 21:51:33 |DEBU| RunCommand command="git rev-parse --verify --quiet refs/heads/main"
Apr 26 21:51:33 |INFO| git for-each-ref --sort=-committerdate --format=%(HEAD)%00%(refname:short)%00%(upstream:short)%00%(upstream:track)%00%(subject)%00%(objectname)%00%(committerdate:unix) refs/heads (13.19516ms)
Apr 26 21:51:33 |INFO| postRefreshUpdate for tags took 5.830665ms
Apr 26 21:51:33 |DEBU| RunCommand command="git worktree list --porcelain"
Apr 26 21:51:33 |INFO| git for-each-ref --sort=refname --format=%(refname:short) refs/remotes (19.559031ms)
Apr 26 21:51:33 |INFO| git worktree list --porcelain (6.919873ms)
Apr 26 21:51:33 |ERRO| <no msg> command="git rev-parse --verify --quiet refs/heads/main"
Apr 26 21:51:33 |INFO| git rev-parse --verify --quiet refs/heads/main (9.638591ms)
Apr 26 21:51:33 |INFO| postRefreshUpdate for remotes took 664.982µs
Apr 26 21:51:33 |INFO| postRefreshUpdate for remoteBranches took 28.195µs
Apr 26 21:51:33 |DEBU| RunCommand command="git -C /home/eryk/projects/anywhere/anywhere rev-parse --path-format=absolute --absolute-git-dir"
Apr 26 21:51:33 |DEBU| RunCommand command="git merge-base HEAD refs/remotes/origin/master"
Apr 26 21:51:33 |INFO| git -C /home/eryk/projects/anywhere/anywhere rev-parse --path-format=absolute --absolute-git-dir (4.309935ms)
Apr 26 21:51:33 |INFO| postRefreshUpdate for worktrees took 829.253µs
Apr 26 21:51:33 |INFO| postRefreshUpdate for localBranches took 1.549926ms

@stefanhaller
Copy link
Collaborator

The errors that you see in the log are normal, nothing to worry about. And no, you don't need a main branch. We should find a way to avoid logging these errors, as it confuses people who are looking for problems.

The reason why you don't see the git log command seems to be because we only log it once it has completed, so from that I can only conclude that this command hangs for some reason. Can you try running this in the terminal:

git log HEAD --topo-order --oneline --pretty=format:%H%x00%at%x00%aN%x00%ae%x00%D%x00%p%x00%s%x00%m --abbrev=40 -300 --no-show-signature -- | cat

@Ziwi01
Copy link
Author

Ziwi01 commented Apr 27, 2024

Ok, so I think I found the issue thanks to the command above.

First, I have cat aliased to bat and running the above gives me

❯ g log HEAD --topo-order --oneline --pretty=format:%H%x00%at%x00%aN%x00%ae%x00%D%x00%p%x00%s%x00%m --abbrev=40 -300 --no-show-signature -- | cat
       │ STDIN   <BINARY>

Using unaliased \cat gives the proper commit list. However, this doesn't seem to be the issue I believe.

Proper commit list revealed, that in one commit, when converting pom.xml line endings, git (or someone accidentally) put the whole file diff in the description field.

diff --git a/pom.xml b/pom.xml
index 666b6208b..7e58aa731 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,1598 +1,1598 @@
-<?xml version="1.0"?>
-<!--

(...)

When I rebased the branch and removed the problematic commit, it started working. However, I'm not sure I can force push to that repo. Strange that no other git tool / command finds that output problematic. Maybe there is a way to escape the commit descriptions in lazygit?

Also maybe a good idea to figure out the actual unaliased cat command so the output is consistent (someone can alias cat with additional switches maybe, or use bat like me)

@stefanhaller
Copy link
Collaborator

We are not actually using cat in lazygit, I only added this to the command line to simulate the environment that the command is run in by lazygit (with output going to a pipe instead of a tty). Without that, it would have presented the output in a pager, which might have changed things. You could have added --no-pager to the command line instead.

I'm not sure I understand the problem yet. You are talking about the description field, but the diff output you pasted only shows the diff, not the description, which doesn't seem to be relevant here.

Could you paste the output of

❯ git --no-pager log <hash-of-the-bad-commit> --oneline --pretty=format:%H%x00%at%x00%aN%x00%ae%x00%D%x00%p%x00%s%x00%m -1 --

@Ziwi01
Copy link
Author

Ziwi01 commented Apr 27, 2024

We are not actually using cat in lazygit, I only added this to the command line to simulate the environment that the command is run in by lazygit (with output going to a pipe instead of a tty).

Ooh, sure, didn't get that, sorry.

You are talking about the description field, but the diff output you pasted only shows the diff, not the description

This is the commit description (the whole diff) :)

The output of the command:

0545af6c9d9e22f63bdbc4b355ab927dcdfaa3a11712302733someone@gmail.comdab515ab4fix: Convert pom.xml diff --git a/pom.xml b/pom.xml index 666b6208b..7e58aa731 100644 --- a/pom.xml +++ b/pom.xml @@ -1,1598 +1,1598 @@ -<?xml version="1.0"?> -<!-- -  ~ Copyright © 2021 -  --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> (...)

And it goes for plethora of lines.

@stefanhaller stefanhaller linked a pull request Apr 27, 2024 that will close this issue
@stefanhaller
Copy link
Collaborator

I can reproduce it here, it happens whenever you have a commit whose subject is longer than about 65535 characters (a bit less than that, but that's details).

Here's a fix: #3533. Can you build from source and try it?

@Ziwi01
Copy link
Author

Ziwi01 commented Apr 27, 2024

I can reproduce it here, it happens whenever you have a commit whose subject is longer than about 65535 characters (a bit less than that, but that's details).

Here's a fix: #3533. Can you build from source and try it?

Whoa, that was fast. It works like a charm :). Thanks for the (lightning fast) help, really appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants