Loading
git: fix fetching annotated git tags
Fetching annotated git tags fails with:
error: trying to write non-commit object to branch 'refs/heads/gluetool/refs/tags/...' (unable to update local ref)_fetch_ref maps the fetch destination to gluetool/<ref>. Git implicitly places refs without a refs/ prefix under refs/heads/ (branches), and branches can only point to commits. Annotated tags point to tag objects, so git rejects the fetch. Lightweight tags are unaffected
because they point directly to commits.
The fix changes the prefix from gluetool/ to refs/gluetool/, placing the ref in a custom namespace that accepts any object type.
Reproducer:
git clone --no-checkout https://github.com/fedora-iot/greenboot-rs .
# fails - annotated tag stored as a branch
git fetch origin 'refs/tags/v0.16.5:gluetool/refs/tags/v0.16.5'
# error: trying to write non-commit object e8320eed6dafa36bc1b2eb7f6e372d8cc290d4aa to branch 'refs/heads/gluetool/refs/tags/v0.16.5'
# From https://github.com/fedora-iot/greenboot-rs
# ! [new tag] v0.16.5 -> gluetool/refs/tags/v0.16.5 (unable to update local ref)
# works - stored under refs/gluetool/
git fetch origin 'refs/tags/v0.16.5:refs/gluetool/refs/tags/v0.16.5'
# From https://github.com/fedora-iot/greenboot-rs
# * [new tag] v0.16.5 -> refs/gluetool/refs/tags/v0.16.5Solves TFT-5303.
Edited by Jan Havlin