diff --git a/main.go b/main.go index 534285afa..96665782c 100644 --- a/main.go +++ b/main.go @@ -24,7 +24,7 @@ func main() { flaggy.DefaultParser.ShowVersionWithVersionFlag = false repoPath := "" - flaggy.String(&repoPath, "p", "path", "Path of git repo. (Deprecated: use --git-dir for git directory and --work-tree for work tree directory)") + flaggy.String(&repoPath, "p", "path", "Path of git repo. (equivalent to --work-tree= --git-dir=/.git/)") filterPath := "" flaggy.String(&filterPath, "f", "filter", "Path to filter on in `git log -- `. When in filter mode, the commits, reflog, and stash are filtered based on the given path, and some operations are restricted") diff --git a/pkg/commands/git.go b/pkg/commands/git.go index da4324d4d..dcd1729af 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -1427,3 +1427,9 @@ func (c *GitCommand) WorkingTreeState() string { } return "normal" } + +func (c *GitCommand) IsBareRepo() bool { + // note: could use `git rev-parse --is-bare-repository` if we wanna drop go-git + _, err := c.Repo.Worktree() + return err == gogit.ErrIsBareRepository +} diff --git a/pkg/gui/recent_repos_panel.go b/pkg/gui/recent_repos_panel.go index dba8ac260..6d9e535a3 100644 --- a/pkg/gui/recent_repos_panel.go +++ b/pkg/gui/recent_repos_panel.go @@ -45,6 +45,14 @@ func (gui *Gui) handleCreateRecentReposMenu() error { // updateRecentRepoList registers the fact that we opened lazygit in this repo, // so that we can open the same repo via the 'recent repos' menu func (gui *Gui) updateRecentRepoList() error { + if gui.GitCommand.IsBareRepo() { + // we could totally do this but it would require storing both the git-dir and the + // worktree in our recent repos list, which is a change that would need to be + // backwards compatible + gui.Log.Info("Not appending bare repo to recent repo list") + return nil + } + recentRepos := gui.Config.GetAppState().RecentRepos currentRepo, err := os.Getwd() if err != nil {