From 3d80e466ceffb5639fc45b48b91c100233890c7b Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 8 Aug 2026 09:34:46 +0200 Subject: [PATCH] Say why runInParentModule can name a relative directory Its working directory resolves against the process rather than against the repo the command builder pins commands to, which is only safe because nothing but foreground commands come through here. Co-Authored-By: Claude Opus 5 (1M context) --- pkg/commands/git_commands/submodule.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/commands/git_commands/submodule.go b/pkg/commands/git_commands/submodule.go index d8c1208bc..e2012942f 100644 --- a/pkg/commands/git_commands/submodule.go +++ b/pkg/commands/git_commands/submodule.go @@ -225,6 +225,13 @@ func (self *SubmoduleCommands) UpdateAll() error { // temporarily chdir-ing the process there, which would leak the parent // module's directory into whatever other commands run concurrently (e.g. a // background refresh's). +// +// That directory is relative, so it resolves against the process working +// directory rather than against the repo directory the command builder +// otherwise pins commands to. Only foreground commands the user issued end up +// here, and lazygit won't switch repos while one of those is in flight, so the +// two are the same directory; don't call this from background work, where they +// need not be. func (self *SubmoduleCommands) runInParentModule(submodule *models.SubmoduleConfig, cmdObj *oscommands.CmdObj) error { if submodule.ParentModule != nil { cmdObj.SetWd(submodule.ParentModule.FullPath())