diff options
author | Ernestas Kulik <ernestas.kulik@gmail.com> | 2017-04-25 19:33:29 +0300 |
---|---|---|
committer | Ernestas Kulik <ernestas.kulik@gmail.com> | 2017-04-25 19:40:23 +0300 |
commit | 8d720527b7ec3ab4285da49843bf15585cf83238 (patch) | |
tree | 9a31a04f694457c2574ebac25692b04e266209f7 | |
parent | a13bde821f53919fe6eb0ca14c4463afc08e5a27 (diff) | |
download | meson-8d720527b7ec3ab4285da49843bf15585cf83238.zip meson-8d720527b7ec3ab4285da49843bf15585cf83238.tar.gz meson-8d720527b7ec3ab4285da49843bf15585cf83238.tar.bz2 |
wrap: pass -C to git when resolving submodules
Using Meson from outside a git repo results in an error when trying to
resolve submodule subprojects. Running git from inside subproject root
should be enough to fix it.
Partially fixes #1679
Signed-off-by: Ernestas Kulik <ernestas.kulik@gmail.com>
-rw-r--r-- | mesonbuild/wrap/wrap.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 9e5910b..713d685 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -38,8 +38,9 @@ def build_ssl_context(): ctx.load_default_certs() return ctx -def quiet_git(cmd): - pc = subprocess.Popen(['git'] + cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) +def quiet_git(cmd, workingdir): + pc = subprocess.Popen(['git', '-C', workingdir] + cmd, + stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = pc.communicate() if pc.returncode != 0: return False, err @@ -150,16 +151,16 @@ class Resolver: def resolve_git_submodule(self, dirname): # Are we in a git repository? - ret, out = quiet_git(['rev-parse']) + ret, out = quiet_git(['rev-parse'], self.subdir_root) if not ret: return False # Is `dirname` a submodule? - ret, out = quiet_git(['submodule', 'status', dirname]) + ret, out = quiet_git(['submodule', 'status', dirname], self.subdir_root) if not ret: return False # Submodule has not been added, add it if out.startswith(b'-'): - if subprocess.call(['git', 'submodule', 'update', '--init', dirname]) != 0: + if subprocess.call(['git', '-C', self.subdir_root, 'submodule', 'update', '--init', dirname]) != 0: return False # Submodule was added already, but it wasn't populated. Do a checkout. elif out.startswith(b' '): |