2929is_win ,
3030)
3131from git .exc import CommandError
32- from git .util import is_cygwin_git ,cygpath ,expand_path
32+ from git .util import is_cygwin_git ,cygpath ,expand_path , remove_password_if_present
3333
3434from .exc import (
3535GitCommandError ,
@@ -83,8 +83,8 @@ def pump_stream(cmdline, name, stream, is_decode, handler):
8383line = line .decode (defenc )
8484handler (line )
8585except Exception as ex :
86- log .error ("Pumping %r of cmd(%s) failed due to: %r" ,name ,cmdline ,ex )
87- raise CommandError (['<%s-pump>' % name ]+ cmdline ,ex )from ex
86+ log .error ("Pumping %r of cmd(%s) failed due to: %r" ,name ,remove_password_if_present ( cmdline ) ,ex )
87+ raise CommandError (['<%s-pump>' % name ]+ remove_password_if_present ( cmdline ) ,ex )from ex
8888finally :
8989stream .close ()
9090
@@ -406,7 +406,7 @@ def read_all_from_possibly_closed_stream(stream):
406406if status != 0 :
407407errstr = read_all_from_possibly_closed_stream (self .proc .stderr )
408408log .debug ('AutoInterrupt wait stderr: %r' % (errstr ,))
409- raise GitCommandError (self .args ,status ,errstr )
409+ raise GitCommandError (remove_password_if_present ( self .args ) ,status ,errstr )
410410# END status handling
411411return status
412412# END auto interrupt
@@ -683,8 +683,10 @@ def execute(self, command,
683683 :note:
684684 If you add additional keyword arguments to the signature of this method,
685685 you must update the execute_kwargs tuple housed in this module."""
686+ # Remove password for the command if present
687+ redacted_command = remove_password_if_present (command )
686688if self .GIT_PYTHON_TRACE and (self .GIT_PYTHON_TRACE != 'full' or as_process ):
687- log .info (' ' .join (command ))
689+ log .info (' ' .join (redacted_command ))
688690
689691# Allow the user to have the command executed in their working dir.
690692cwd = self ._working_dir or os .getcwd ()
@@ -705,7 +707,7 @@ def execute(self, command,
705707if is_win :
706708cmd_not_found_exception = OSError
707709if kill_after_timeout :
708- raise GitCommandError (command ,'"kill_after_timeout" feature is not supported on Windows.' )
710+ raise GitCommandError (redacted_command ,'"kill_after_timeout" feature is not supported on Windows.' )
709711else :
710712if sys .version_info [0 ]> 2 :
711713cmd_not_found_exception = FileNotFoundError # NOQA # exists, flake8 unknown @UndefinedVariable
@@ -720,7 +722,7 @@ def execute(self, command,
720722if istream :
721723istream_ok = "<valid stream>"
722724log .debug ("Popen(%s, cwd=%s, universal_newlines=%s, shell=%s, istream=%s)" ,
723- command ,cwd ,universal_newlines ,shell ,istream_ok )
725+ redacted_command ,cwd ,universal_newlines ,shell ,istream_ok )
724726try :
725727proc = Popen (command ,
726728env = env ,
@@ -736,7 +738,7 @@ def execute(self, command,
736738** subprocess_kwargs
737739 )
738740except cmd_not_found_exception as err :
739- raise GitCommandNotFound (command ,err )from err
741+ raise GitCommandNotFound (redacted_command ,err )from err
740742
741743if as_process :
742744return self .AutoInterrupt (proc ,command )
@@ -786,7 +788,7 @@ def _kill_process(pid):
786788watchdog .cancel ()
787789if kill_check .isSet ():
788790stderr_value = ('Timeout: the command "%s" did not complete in %d '
789- 'secs.' % (" " .join (command ),kill_after_timeout ))
791+ 'secs.' % (" " .join (redacted_command ),kill_after_timeout ))
790792if not universal_newlines :
791793stderr_value = stderr_value .encode (defenc )
792794# strip trailing "\n"
@@ -810,7 +812,7 @@ def _kill_process(pid):
810812proc .stderr .close ()
811813
812814if self .GIT_PYTHON_TRACE == 'full' :
813- cmdstr = " " .join (command )
815+ cmdstr = " " .join (redacted_command )
814816
815817def as_text (stdout_value ):
816818return not output_stream and safe_decode (stdout_value )or '<OUTPUT_STREAM>'
@@ -826,7 +828,7 @@ def as_text(stdout_value):
826828# END handle debug printing
827829
828830if with_exceptions and status != 0 :
829- raise GitCommandError (command ,status ,stderr_value ,stdout_value )
831+ raise GitCommandError (redacted_command ,status ,stderr_value ,stdout_value )
830832
831833if isinstance (stdout_value ,bytes )and stdout_as_string :# could also be output_stream
832834stdout_value = safe_decode (stdout_value )