From 9690dd23b9002d7bf6bd6e34aca2dd41a0fc7a6a Mon Sep 17 00:00:00 2001 From: andy5995 Date: Wed, 30 Oct 2024 00:44:02 -0500 Subject: [PATCH] Check for uppercase 'head' when updating subprojects --- docs/markdown/Wrap-dependency-system-manual.md | 4 ++-- mesonbuild/msubprojects.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/markdown/Wrap-dependency-system-manual.md b/docs/markdown/Wrap-dependency-system-manual.md index c1652c1c3b74..73358e7cfc2f 100644 --- a/docs/markdown/Wrap-dependency-system-manual.md +++ b/docs/markdown/Wrap-dependency-system-manual.md @@ -66,7 +66,7 @@ An example wrap-git will look like this: ```ini [wrap-git] url = https://github.com/libfoobar/libfoobar.git -revision = head +revision = HEAD depth = 1 ``` @@ -124,7 +124,7 @@ case, the directory will be copied into `subprojects/` before applying patches. - `url` - name of the wrap-git repository to clone. Required. - `revision` - name of the revision to checkout. Must be either: a valid value (such as a git tag) for the VCS's `checkout` command, or - (for git) `head` to track upstream's default branch. Required. + (for git) `HEAD` to track upstream's default branch. Required. ### Specific to wrap-git - `depth` - shallowly clone the repository to X number of commits. This saves bandwidth and disk diff --git a/mesonbuild/msubprojects.py b/mesonbuild/msubprojects.py index c15415485217..f38f13ef1f96 100755 --- a/mesonbuild/msubprojects.py +++ b/mesonbuild/msubprojects.py @@ -265,7 +265,8 @@ def git_checkout(self, revision: str, create: bool = False) -> bool: cmd = ['checkout', '--ignore-other-worktrees'] if create: cmd.append('-b') - cmd += [revision, '--'] + revision_val = revision if revision.upper() != 'HEAD' else 'HEAD' + cmd += [revision_val, '--'] try: # Stash local changes, commits can always be found back in reflog, to # avoid any data lost by mistake. @@ -376,7 +377,8 @@ def update_git(self) -> bool: # https://github.com/mesonbuild/meson/pull/7723#discussion_r488816189. heads_refmap = '+refs/heads/*:refs/remotes/origin/*' tags_refmap = '+refs/tags/*:refs/tags/*' - self.git_output(['fetch', '--refmap', heads_refmap, '--refmap', tags_refmap, 'origin', revision]) + revision_val = revision if revision.upper() != 'HEAD' else 'HEAD' + self.git_output(['fetch', '--refmap', heads_refmap, '--refmap', tags_refmap, 'origin', revision_val]) except GitException as e: self.log(' -> Could not fetch revision', mlog.bold(revision), 'in', mlog.bold(self.repo_dir)) self.log(mlog.red(e.output))