]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blobdiff - support/download/git
download/git: more resilient in case of kill
[coffee/buildroot.git] / support / download / git
index 868dfad0dd94cd676bb78f88dbb3e70faf418ce2..381f3ceeb31c256508f833ded8c3e2bb78b5b068 100755 (executable)
@@ -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