From f4afeed9ff57881156902b3b3ac0c6f343d7df86 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 30 Jul 2025 11:42:41 +0200 Subject: [PATCH 1/3] Improve .gitignoring debug executables --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6d9b25784..9b0ebaef6 100644 --- a/.gitignore +++ b/.gitignore @@ -22,7 +22,7 @@ test/git_server/data test/_results/** oryxBuildBinary -__debug_bin +__debug_bin* .worktrees demo/output/* From 6a17144ef4def87b0f89ed2613ccb34ea1f10723 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 30 Jul 2025 11:37:46 +0200 Subject: [PATCH 2/3] Don't exit after handling daemon mode The function that called us has just created a temp dir, and scheduled a defer to remove it again; by calling os.Exit we short-cut this defer, and don't clean up the temp dir. There is no reason to exit here, the calling function will return after having called us. --- pkg/app/daemon/daemon.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/app/daemon/daemon.go b/pkg/app/daemon/daemon.go index 16b9bf5e5..6b29fd62d 100644 --- a/pkg/app/daemon/daemon.go +++ b/pkg/app/daemon/daemon.go @@ -76,8 +76,6 @@ func Handle(common *common.Common) { if err := instruction.run(common); err != nil { log.Fatal(err) } - - os.Exit(0) } func InDaemonMode() bool { From 3a9dbf7341f0039ca3531ebb7b0ae4541ca274bf Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 30 Jul 2025 11:41:35 +0200 Subject: [PATCH 3/3] Create temp directories inside a "lazygit" folder rather than top-level in /tmp This is no longer as important now that we fixed the stale, left-over temp dirs caused by daemon mode, but it could still be helpful in case lazygit crashes, or if you have many instances of lazygit running. --- pkg/app/entry_point.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/app/entry_point.go b/pkg/app/entry_point.go index a812154fe..498abc7fe 100644 --- a/pkg/app/entry_point.go +++ b/pkg/app/entry_point.go @@ -124,7 +124,11 @@ func Start(buildInfo *BuildInfo, integrationTest integrationTypes.IntegrationTes os.Exit(0) } - tempDir, err := os.MkdirTemp("", "lazygit-*") + tmpDirBase := filepath.Join(os.TempDir(), "lazygit") + if err := os.MkdirAll(tmpDirBase, 0o700); err != nil { + log.Fatal(err.Error()) + } + tempDir, err := os.MkdirTemp(tmpDirBase, "") if err != nil { log.Fatal(err.Error()) }