aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/wrap
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2021-10-03 20:58:51 -0400
committerEli Schwartz <eschwartz@archlinux.org>2021-10-04 22:48:09 -0400
commitb57b1050a6c6d38b3adf4b8f5e40e25892c878a6 (patch)
treef4a34f4ef888debd38a0e1340d0e8bf3bdabd4ea /mesonbuild/wrap
parent6b8f10cf6b1ee603ad7f584f7be8340e6974fb4f (diff)
downloadmeson-b57b1050a6c6d38b3adf4b8f5e40e25892c878a6.zip
meson-b57b1050a6c6d38b3adf4b8f5e40e25892c878a6.tar.gz
meson-b57b1050a6c6d38b3adf4b8f5e40e25892c878a6.tar.bz2
wrap clone: be less noisy when doing automated code checkouts
There are two possible issues, both of which emit very long messages from git: - when shallow cloning via depth + a pinned commit we locally init rather than cloning; use an almost-certainly not conflicting dummy branch name - any time a checkout of a revision is performed, it might not be a branch name, in which case it will be a detached HEAD. By default git is very noisy about this -- it wants you to know what happened and how not to mess up. But wraps aren't per default intended for user editing and development, it's just part of the internal transport which meson uses. So, temporarily squelch this advice. Do not permanently configure the repo like this though, because the user *might* cd in and start developing on the subproject; in this case, any additional git advice they trigger is their responsibility (and they probably do want it). Fixes #9318
Diffstat (limited to 'mesonbuild/wrap')
-rw-r--r--mesonbuild/wrap/wrap.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py
index e061c9e..f941198 100644
--- a/mesonbuild/wrap/wrap.py
+++ b/mesonbuild/wrap/wrap.py
@@ -401,6 +401,7 @@ class Resolver:
if not GIT:
raise WrapException(f'Git program not found, cannot download {self.packagename}.wrap via git.')
revno = self.wrap.get('revision')
+ checkout_cmd = ['-c', 'advice.detachedHead=false', 'checkout', revno, '--']
is_shallow = False
depth_option = [] # type: T.List[str]
if self.wrap.values.get('depth', '') != '':
@@ -410,11 +411,11 @@ class Resolver:
if is_shallow and self.is_git_full_commit_id(revno):
# git doesn't support directly cloning shallowly for commits,
# so we follow https://stackoverflow.com/a/43136160
- verbose_git(['init', self.directory], self.subdir_root, check=True)
+ verbose_git(['init', '-b', 'meson-dummy-branch', self.directory], self.subdir_root, check=True)
verbose_git(['remote', 'add', 'origin', self.wrap.get('url')], self.dirname, check=True)
revno = self.wrap.get('revision')
verbose_git(['fetch', *depth_option, 'origin', revno], self.dirname, check=True)
- verbose_git(['checkout', revno, '--'], self.dirname, check=True)
+ verbose_git(checkout_cmd, self.dirname, check=True)
if self.wrap.values.get('clone-recursive', '').lower() == 'true':
verbose_git(['submodule', 'update', '--init', '--checkout',
'--recursive', *depth_option], self.dirname, check=True)
@@ -425,9 +426,9 @@ class Resolver:
if not is_shallow:
verbose_git(['clone', self.wrap.get('url'), self.directory], self.subdir_root, check=True)
if revno.lower() != 'head':
- if not verbose_git(['checkout', revno, '--'], self.dirname):
+ if not verbose_git(checkout_cmd, self.dirname):
verbose_git(['fetch', self.wrap.get('url'), revno], self.dirname, check=True)
- verbose_git(['checkout', revno, '--'], self.dirname, check=True)
+ verbose_git(checkout_cmd, self.dirname, check=True)
else:
verbose_git(['clone', *depth_option, '--branch', revno, self.wrap.get('url'),
self.directory], self.subdir_root, check=True)