From 06dddf2ef0e43755cf23ec2d826f3692e42639be Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 22 Jan 2020 20:04:41 +0530 Subject: wrap: Re-set the console mode after calling git `git submodule update --recursive` calls git clone recursively, and on Windows it will undo the console mode we set in mlog and cause ANSI colors to stop working. We could set it again only when we call that, but we will definitely miss other instances where this could happen in the future and regress. --- mesonbuild/wrap/wrap.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 64bc88e..92e37de 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -18,6 +18,7 @@ import urllib.request import urllib.error import urllib.parse import os +import platform import hashlib import shutil import tempfile @@ -53,6 +54,11 @@ def git(cmd: T.List[str], workingdir: str, **kwargs) -> subprocess.CompletedProc # Redirect stdin to DEVNULL otherwise git messes up the # console and ANSI colors stop working on Windows. stdin=subprocess.DEVNULL, **kwargs) + # Sometimes git calls git recursively, such as `git submodule update + # --recursive` which will be without the above workaround, so set the + # console mode again just in case. + if platform.system().lower() == 'windows': + mlog._windows_ansi() return pc def quiet_git(cmd: T.List[str], workingdir: str) -> T.Tuple[bool, str]: -- cgit v1.1