support/download/git: fix cache update with stale submodule commits
PATCH 1/1 support/download/git: fix cache update with stale submodule commits
When the git cache already has the submodules of a previous download initialized, "git fetch origin" defaults to --recurse-submodules=on-demand and also fetches every submodule commit referenced by the newly fetched superproject history, not just the one of the cset we need.
open62541's 1.3 branch now contains commit 935588a18b ("fix(deps):
update mqtt-c topic bounds validation"), which points deps/mqtt-c to a commit that was never pushed to the MQTT-C repository (it was fixed by the next commit). Updating a cache that holds an earlier open62541 version therefore fails, although v1.5.10 itself does not use it:
Fetching submodule deps/mqtt-c
fatal: remote error: upload-pack: not our ref 3cac1238c29627f0a1e80fec7e9f2629bdb8c4d2 Errors during submodule fetch:
deps/mqtt-c
Detected a corrupted git cache.
Removing it and starting afresh.
At best the whole cache is then thrown away and cloned again; on the autobuilder, removing it failed as well and the download aborted.
Pass --recurse-submodules=no to the fetches of the cache update. The submodules of the requested cset are still fetched afterwards by "git submodule update --init --recursive".
This issue has been present since commit 6d938bcb5249 ("download: git:
introduce cache feature"), which started updating a persistent git cache with "git fetch", and only shows up when some upstream history references unavailable submodule commits. It therefore affects 2018.05 and later, including all maintained branches.
Fixes:
https://autobuild.buildroot.org/results/f0043de3bba1b4acfbd4289c4f48927e40a32e4e
--- support/download/git | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
support/download/git +6 -3
@@ -132,9 +132,12 @@ fi _git remote set-url origin "'${uri}'" +# Do not let git fetch the submodules of all the fetched commits: they +# may point to commits that no longer exist in the submodule upstream. +# The submodules of the requested cset are fetched below anyway. printf "Fetching all references\n" -_git fetch "${@}" origin -_git fetch "${@}" origin -t -f +_git fetch --recurse-submodules=no "${@}" origin +_git fetch --recurse-submodules=no "${@}" origin -t -f # Try to get the special refs exposed by some forges (pull-requests for # github, changes for gerrit...). There is no easy way to know whether
@@ -143,7 +146,7 @@ _git fetch "${@}" origin -t -f # below, if there is an issue anyway. Since most of the cset we're gonna # have to clone are not such special refs, consign the output to oblivion # so as not to alarm unsuspecting users, but still trace it as a warning. -if ! _git fetch "${@}" origin "'${cset}:${cset}'" >/dev/null 2>&1; then +if ! _git fetch --recurse-submodules=no "${@}" origin "'${cset}:${cset}'" >/dev/null 2>&1; then printf "Could not fetch special ref '%s'; assuming it is not special.\n" "${cset}" fi
Signature · 6 lines
2.34.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot