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 if opened from a .git folder #3507

Open
FedericoMuciaccia opened this issue Apr 20, 2024 · 0 comments
Open

crash if opened from a .git folder #3507

FedericoMuciaccia opened this issue Apr 20, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@FedericoMuciaccia
Copy link

Describe the bug
Lazygit crashes when invoked from the .git folder of a regular local Git repository.

Way to Reproduce it
The following commands

$ cd /my/local/repository/
$ cd .git/
$ lazygit

result in the following error:

2024/04/20 23:57:12 An error occurred! Please create an issue at: https://github.com/jesseduffield/lazygit/issues

*errors.errorString Error getting repo paths: 'git rev-parse --path-format=absolute --show-toplevel --absolute-git-dir --git-common-dir --show-superproject-working-tree' failed: fatal: this operation must be run in a work tree

/home/federico/go/pkg/mod/github.com/jesseduffield/[email protected]/pkg/commands/git.go:65 (0x9a7fc9)
	NewGitCommand: return nil, errors.Errorf("Error getting repo paths: %v", err)
/home/federico/go/pkg/mod/github.com/jesseduffield/[email protected]/pkg/gui/gui.go:300 (0xb312d5)
	(*Gui).onNewRepo: gui.git, err = commands.NewGitCommand(
/home/federico/go/pkg/mod/github.com/jesseduffield/[email protected]/pkg/gui/gui.go:692 (0xb34078)
	(*Gui).Run: if err := gui.onNewRepo(startArgs, context.NO_CONTEXT); err != nil {
/home/federico/go/pkg/mod/github.com/jesseduffield/[email protected]/pkg/gui/gui.go:711 (0xb34705)
	(*Gui).RunAndHandleError.func1: if err := gui.Run(startArgs); err != nil {
/home/federico/go/pkg/mod/github.com/jesseduffield/[email protected]/pkg/utils/utils.go:117 (0x82837c)
	SafeWithError: err := f()
/home/federico/go/pkg/mod/github.com/jesseduffield/[email protected]/pkg/gui/gui.go:710 (0xb3464e)
	(*Gui).RunAndHandleError: return utils.SafeWithError(func() error {
/home/federico/go/pkg/mod/github.com/jesseduffield/[email protected]/pkg/app/app.go:266 (0xb62396)
	Run: err := app.Gui.RunAndHandleError(startArgs)
/home/federico/go/pkg/mod/github.com/jesseduffield/[email protected]/pkg/app/app.go:49 (0xb62346)
	Run: err = app.Run(startArgs)
/home/federico/go/pkg/mod/github.com/jesseduffield/[email protected]/pkg/app/entry_point.go:150 (0xb64565)
	Start: Run(appConfig, common, appTypes.NewStartArgs(cliArgs.FilterPath, parsedGitArg, integrationTest))
/home/federico/go/pkg/mod/github.com/jesseduffield/[email protected]/main.go:23 (0xb65d98)
	main: app.Start(ldFlagsBuildInfo, nil)
/home/federico/.go/go1.22.1/src/runtime/internal/atomic/types.go:194 (0x44035d)
	(*Uint32).Load: return Load(&u.value)
/home/federico/.go/go1.22.1/src/runtime/asm_amd64.s:1695 (0x473501)
	goexit: BYTE	$0x90	// NOP

Expected behavior
Clean exit with a clear error message (like "Error: must be run inside the main folder of a git repository")

Version info:

$ lazygit --version
commit=, build date=, build source=unknown, version=unversioned, os=linux, arch=amd64, git version=2.34.1
$ git --version
git version 2.34.1
@FedericoMuciaccia FedericoMuciaccia added the bug Something isn't working label Apr 20, 2024
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

No branches or pull requests

1 participant