Skip to content

Commit

Permalink
Check for uppercase 'head' when updating subprojects
Browse files Browse the repository at this point in the history
  • Loading branch information
andy5995 committed Nov 3, 2024
1 parent 1840bb0 commit 9690dd2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/markdown/Wrap-dependency-system-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions mesonbuild/msubprojects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 9690dd2

Please sign in to comment.