Skip to content

Commit baf3457

Browse files
committed
Fix Git.execute shell use and reporting bugs
This updates the shell variable itself, only when it is None, from self.USE_SHELL. (That attribute is usually Git.USE_SHELL rather than an instance attribute. But although people probably shouldn't set it on instances, people will expect that this is permitted.) Now: - USE_SHELL is used as a fallback only. When shell=False is passed, USE_SHELL is no longer consuled. Thus shell=False always keeps a shell from being used, even in the non-default case where the USE_SHELL attribue has been set to True. - The debug message printed to the log shows the actual value that is being passed to Popen, because the updated shell variable is used both to produce that message and in the Popen call.
1 parent 41294d5 commit baf3457

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

git/cmd.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,8 @@ def execute(
974974
istream_ok = "None"
975975
if istream:
976976
istream_ok = "<valid stream>"
977+
if shell is None:
978+
shell = self.USE_SHELL
977979
log.debug(
978980
"Popen(%s, cwd=%s, universal_newlines=%s, shell=%s, istream=%s)",
979981
redacted_command,
@@ -992,7 +994,7 @@ def execute(
992994
stdin=istream or DEVNULL,
993995
stderr=PIPE,
994996
stdout=stdout_sink,
995-
shell=shell is not None and shell or self.USE_SHELL,
997+
shell=shell,
996998
close_fds=is_posix, # unsupported on windows
997999
universal_newlines=universal_newlines,
9981000
creationflags=PROC_CREATIONFLAGS,

0 commit comments

Comments
 (0)