Skip to content

Commit 0d93908

Browse files
committed
Prevent CMD windows being shown when starting git in a subprocess.
This fixes a UI problem with using GitPython from a GUI python probgram. Each repo that is opened creates a git cat-file processs and that provess will create a console window with out this change.
1 parent 1116ef7 commit 0d93908

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

git/cmd.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,12 @@ def execute(self, command,
609609
# end handle
610610

611611
try:
612+
if sys.platform == 'win32':
613+
CREATE_NO_WINDOW = 0x08000000
614+
creationflags = CREATE_NO_WINDOW
615+
else:
616+
creationflags = None
617+
612618
proc = Popen(command,
613619
env=env,
614620
cwd=cwd,
@@ -619,6 +625,7 @@ def execute(self, command,
619625
shell=self.USE_SHELL,
620626
close_fds=(os.name == 'posix'), # unsupported on windows
621627
universal_newlines=universal_newlines,
628+
creationflags=creationflags,
622629
**subprocess_kwargs
623630
)
624631
except cmd_not_found_exception as err:
@@ -629,7 +636,13 @@ def execute(self, command,
629636

630637
def _kill_process(pid):
631638
""" Callback method to kill a process. """
632-
p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE)
639+
if sys.platform == 'win32':
640+
CREATE_NO_WINDOW = 0x08000000
641+
creationflags = CREATE_NO_WINDOW
642+
else:
643+
creationflags = None
644+
645+
p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE, creationflags)
633646
child_pids = []
634647
for line in p.stdout:
635648
if len(line.split()) > 0:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy