@@ -334,8 +334,9 @@ def _get_default_bash_path(cls):
334
334
# This addresses issues where git hooks are intended to run assuming
335
335
# the "native" Windows environment as seen by git.exe rather than
336
336
# inside the git sandbox of WSL, which is likely configured
337
- # independetly of the Windows Git. A noteworthy example are repos with
338
- # Git LFS, where Git LFS may be installed in Windows but not in WSL.
337
+ # independently of the Windows Git. A noteworthy example are repos
338
+ # with Git LFS, where Git LFS may be installed in Windows but not
339
+ # in WSL.
339
340
if not is_win :
340
341
return 'bash'
341
342
try :
@@ -346,7 +347,7 @@ def _get_default_bash_path(cls):
346
347
gitpath = Path (wheregit .decode (defenc ).splitlines ()[0 ])
347
348
gitroot = gitpath .parent .parent
348
349
gitbash = gitroot / 'bin' / 'bash.exe'
349
- return str (gitbash ) if gitbash .exists else 'bash.exe'
350
+ return str (gitbash ) if gitbash .exists () else 'bash.exe'
350
351
351
352
@classmethod
352
353
def refresh_bash (cls , path : Union [None , PathLike ] = None ) -> bool :
@@ -357,7 +358,7 @@ def refresh_bash(cls, path: Union[None, PathLike] = None) -> bool:
357
358
new_bash = os .path .abspath (new_bash )
358
359
else :
359
360
new_bash = os .environ .get (cls ._bash_exec_env_var )
360
- if new_bash is None :
361
+ if not new_bash :
361
362
new_bash = cls ._get_default_bash_path ()
362
363
363
364
# Keep track of the old and new bash executable path.
@@ -369,7 +370,8 @@ def refresh_bash(cls, path: Union[None, PathLike] = None) -> bool:
369
370
# executed for whatever reason.
370
371
has_bash = False
371
372
try :
372
- run ([cls .GIT_PYTHON_BASH_EXECUTABLE , '--version' ])
373
+ run ([cls .GIT_PYTHON_BASH_EXECUTABLE , '--version' ],
374
+ check = True , stdout = PIPE )
373
375
has_bash = True
374
376
except CalledProcessError :
375
377
pass
0 commit comments