Skip to content

Commit 9498542

Browse files
authored
Cache git executable search into a variable. (#1021)
* Cache git executable search into a variable. This helps reduce noise in the verbose debug logging output messages when EMSDK_VERBOSE=1 is enabled. * Flake * Mark cached_git_executable global
1 parent 315e763 commit 9498542

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

emsdk.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,11 +735,17 @@ def run_get_output(cmd, cwd=None):
735735
return (process.returncode, stdout, stderr)
736736

737737

738+
cached_git_executable = None
739+
740+
738741
# must_succeed: If false, the search is performed silently without printing out
739742
# errors if not found. Empty string is returned if git is not found.
740743
# If true, the search is required to succeed, and the execution
741744
# will terminate with sys.exit(1) if not found.
742745
def GIT(must_succeed=True):
746+
global cached_git_executable
747+
if cached_git_executable is not None:
748+
return cached_git_executable
743749
# The order in the following is important, and specifies the preferred order
744750
# of using the git tools. Primarily use git from emsdk if installed. If not,
745751
# use system git.
@@ -748,6 +754,7 @@ def GIT(must_succeed=True):
748754
try:
749755
ret, stdout, stderr = run_get_output([git, '--version'])
750756
if ret == 0:
757+
cached_git_executable = git
751758
return git
752759
except:
753760
pass

0 commit comments

Comments
 (0)