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

Crash when the current directory is a symlink to a directory in a GIT repo #3015

Open
chmouel opened this issue Sep 20, 2023 · 5 comments
Open
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@chmouel
Copy link

chmouel commented Sep 20, 2023

Describe the bug
Crash when the current directory is a symlink to a directory in a GIT repo
To Reproduce

% cd /tmp
% mkdir repotest
% cd repotest
% git init
Initialized empty Git repository in /tmp/repotest/.git/
% mkdir foobar
% git init
% touch foobar/blah
% git add .
% git commit -m "test ignore" -a
[main (root-commit) c8bccd0] test ignore
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 foobar/blah
% ln -s /tmp/repotest/foobar /tmp
% cd /tmp/foobar
% git log -1 --pretty="%h %s"
c8bccd0 test ignore
% lazygit
2023/09/20 09:55:27 An error occurred! Please create an issue at: https://github.com/jesseduffield/lazygit/issues

*errors.errorString Must open lazygit in a git repository
github.com/jesseduffield/lazygit/pkg/commands/git.go:235 (0x55818ecc1da6)
github.com/jesseduffield/lazygit/pkg/commands/git.go:87 (0x55818ecc0936)
github.com/jesseduffield/lazygit/pkg/gui/gui.go:271 (0x55818edf06eb)
github.com/jesseduffield/lazygit/pkg/gui/gui.go:656 (0x55818edf32db)
github.com/jesseduffield/lazygit/pkg/gui/gui.go:675 (0x55818edf39c5)
github.com/jesseduffield/lazygit/pkg/utils/utils.go:108 (0x55818eb4f0fc)
github.com/jesseduffield/lazygit/pkg/gui/gui.go:674 (0x55818edf390e)
github.com/jesseduffield/lazygit/pkg/app/app.go:263 (0x55818ee1f57d)
github.com/jesseduffield/lazygit/pkg/app/app.go:48 (0x55818ee1f512)
github.com/jesseduffield/lazygit/pkg/app/entry_point.go:150 (0x55818ee216ea)
github.com/jesseduffield/lazygit/main.go:23 (0x55818ee22e78)
runtime/internal/atomic/types.go:194 (0x55818e77ceb2)
runtime/asm_amd64.s:1650 (0x55818e7ad121)

Expected behavior
no crash or at least a error message maybe :)

Screenshots
If applicable, add screenshots to help explain your problem.

Version info:
commit=v0.40.2, build date=2023-08-12T17:47:33Z, build source=binaryRelease, version=0.40.2, os=linux, arch=amd64, git version=2.42.0

Additional context

arch package fwiw

Note: please try updating to the latest version or manually building the latest master to see if the issue still occurs.

@chmouel chmouel added the bug Something isn't working label Sep 20, 2023
@jesseduffield
Copy link
Owner

We have a function resolveSymlink in pkg/commands/git_commands/repo_paths.go that we could call right after line 75 in pkg/commands/git.go. I'll chuck a good-first-label on this issue.

Would you be up to the challenge of raising a PR for this @chmouel ?

@jesseduffield jesseduffield added the good first issue Good for newcomers label Sep 20, 2023
@chmouel
Copy link
Author

chmouel commented Sep 20, 2023

sure @jesseduffield will send the pr :)

@Velrok
Copy link

Velrok commented Oct 12, 2023

I'm seeing the same issue. Thanks for looking at this. 🙇🏻

@adiSuper94
Copy link

What caused this regression ?
I use lg on multiple machines with same setup. The newer setup has this issue but the older on doesn't.

@jwhitley
Copy link
Contributor

jwhitley commented Jan 1, 2024

This issue is also fixed by PR #3183. For clarity, I assumed that there's some minor mistakes in the repro instructions which otherwise don't make sense as written. The command sequence:

[...]
mkdir foobar
git init
touch foobar blah
[...]

should instead be:

mkdir foobar
cd foobar
git init
touch blah

jwhitley added a commit to jwhitley/lazygit that referenced this issue Jan 14, 2024
This is a test that covers jesseduffield#3144 and its dupe jesseduffield#3015, where lazygit
is run from a symlink outside of a repo into a subdirectory of that
repo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants