mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.63k stars 1.64k forks source link

Subprojects update fails for all Git wraps with revision = 'head' #12730

Closed amyspark closed 1 week ago

amyspark commented 10 months ago

Describe the bug

As per https://mesonbuild.com/Wrap-dependency-system-manual.html#specific-to-vcsbased-wraps, we can use head to tell Meson to always use the latest commit when checking a subproject out:

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.

However, if one issues a meson subprojects update after a build,

https://github.com/mesonbuild/meson/blob/ae857e841b0a6b9b595583e74f5e21676bb83f9d/mesonbuild/msubprojects.py#L375-L377

this block will instead cause all updates to fail with the following error:

Updating faac...
  -> Could not fetch revision head in deps/faac
fatal: couldn't find remote ref head
Git command failed: ['C:\\Program Files\\Git\\cmd\\git.EXE', 'fetch', '--refmap', '+refs/heads/*:refs/remotes/origin/*', '--refmap', '+refs/tags/*:refs/tags/*', 'origin', 'head']
(repeats for all the below deps...)
WARNING: Please check logs above as command failed in some subprojects which could have been left in conflict state: faac, faad2, flac, lame, libid3tag, libmad, libmpc, libopusenc, mp4v2, ogg, optimfrog-win-x64, opus, substrate, vorbis, wavpack, zlib

This is really simple to fix: just uppercase revision if head prior to issuing the Git call above:

                heads_refmap = '+refs/heads/*:refs/remotes/origin/*'
                tags_refmap = '+refs/tags/*:refs/tags/*'
                if revision == 'head':
                    revision = revision.upper()
                self.git_output(['fetch', '--refmap', heads_refmap, '--refmap', tags_refmap, 'origin', revision])

To Reproduce

Clone and initialise https://github.com/dragonCodecs/libAudio, then manually switch any of the above deps to an older commit.

Expected behavior

Meson should be able to update these wraps.

system parameters

bruchar1 commented 10 months ago

Isn't it rather a documentation issue? Shouldn't revision in the wrap file be HEAD instead?

amyspark commented 10 months ago

@bruchar1 Tests also use the same convention (Git revision value in lowercase), they don't show up as broken because updating is not tested:

https://github.com/mesonbuild/meson/blob/ae857e841b0a6b9b595583e74f5e21676bb83f9d/manual%20tests/3%20git%20wrap/subprojects/samplesubproject.wrap#L4

bruchar1 commented 10 months ago

That's a good point. I have no strong opinion about which approach is the best. I will let meson developers decide of this.

andy5995 commented 2 weeks ago

I've opened https://github.com/mesonbuild/meson/pull/13840 to fix this.

Because git is case-sensitive about HEAD, my opinion is that the meson code should not convert the case, and the docs and wraps should use "HEAD" not "head".