download/git: more resilient in case of kill
PATCH v2 1/1 download/git: more resilient in case of kill
In case the git backend gets killed right in-between it finished initialising the repository, but before it could add the remote, we'd end up with a repository without the 'origin' remote, so we would not be able to change its URL.
Another case that may happen (like in the build failure, below), is that the repository was initialised with a previous version of Buildroot, before the commit e17719264b (download/git: don't require too-recent git) was applied, and that trepository was still lying around...
Fixes:
http://autobuild.buildroot.org/results/25a/25aae054634368fadb265b97ebe4dda809deff6f/
---
Changes v1 -> v2:
- remove extraneous pushd/popd (Thomas)
- fix if-block condition
--- support/download/git | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
support/download/git +5 -3
@@ -47,13 +47,15 @@ git_cache="${dl_dir}/git" # fetch'ed later. if [ ! -d "${git_cache}" ]; then _git init "'${git_cache}'" - pushd "${git_cache}" >/dev/null - _git remote add origin "'${uri}'" - popd >/dev/null fi pushd "${git_cache}" >/dev/null +# Ensure the repo has an origin (in case a previous run was killed). +if ! git remote |grep -q -E '^origin$'; then + _git remote add origin "'${uri}'" +fi + _git remote set-url origin "'${uri}'" # Try to fetch with limited depth, since it is faster than a full clone - but
Signature · 1 line
2.14.1
Thomas Petazzoni
AppliedPATCH v2 1/1 download/git: more resilient in case of kill
Hello,
Quoted 19 lines · Yann E. MORIN
In case the git backend gets killed right in-between it finished initialising the repository, but before it could add the remote, we'd end up with a repository without the 'origin' remote, so we would not be able to change its URL.
Another case that may happen (like in the build failure, below), is that the repository was initialised with a previous version of Buildroot, before the commit
e17719264b(download/git: don't require too-recent git) was applied, and that trepository was still lying around...Fixes:
http://autobuild.buildroot.org/results/25a/25aae054634368fadb265b97ebe4dda809deff6f/Signed-off-by "Yann E. MORIN" <[email protected]>Cc Maxime Hadjinlian <[email protected]>Cc Thomas Petazzoni <[email protected]>Cc Peter Korsgaard <[email protected]>
Quoted 7 lines
---
Changes v1 -> v2:
- remove extraneous pushd/popd (Thomas)
- fix if-block condition--- support/download/git | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Applied to master, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com