fix(cli): GIT_CONFIG* envvars leaking child processes

When launching Doom via 'doom run', the child process inherits
bin/doom's environment. This change restricts this sub-environment to
the intended target: straight and its use of git.

Fix: #6320
This commit is contained in:
Henrik Lissner 2022-04-21 20:00:50 +02:00
parent 8c03fa0e3d
commit fbfc635300
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
2 changed files with 9 additions and 3 deletions

View file

@ -118,3 +118,12 @@ However, in batch mode, print to stdout instead of stderr."
(and (string-match-p "^\\(Cloning\\|\\(Reb\\|B\\)uilding\\) " msg)
(not (string-suffix-p "...done" msg))
(doom--print (doom--format (concat "> " msg))))))
(defadvice! doom--straight-ignore-gitconfig-a (fn &rest args)
"Prevent user and system git configuration from interfering with git calls."
:around #'straight--process-call
(letenv! (("GIT_CONFIG" nil)
("GIT_CONFIG_NOSYSTEM" "1")
("GIT_CONFIG_GLOBAL" (or (getenv "DOOMGITCONFIG")
"/dev/null")))
(apply fn args)))