git.sh: Only create destination repo on success

Don't leave a broken cache laying around, which would
otherwise break lbmk for the user.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2025-05-13 21:57:34 +01:00
parent ed8a33d6fb
commit 3c23ff4fa1
+12 -5
View File
@@ -6,6 +6,7 @@ eval "`setvars "" loc url bkup_url subfile subhash subrepo subrepo_bkup \
depend subfile_bkup repofail`"
tmpgit="$xbmklocal/gitclone"
tmpgitcache="$XBMK_CACHE/tmpgit"
fetch_targets()
{
@@ -138,11 +139,17 @@ try_copy()
try_git()
{
[ -d "$1" ] || git clone "$2" "$1" || return 1
git -C "$1" remote add main "$4" 2>/dev/null || :
git -C "$1" remote add backup "$5" 2>/dev/null || :
git -C "$1" fetch --all || :
git -C "$1" pull --all || :
gitdest="`findpath "$1"`" || err "Can't get readpath for '$1'"
x_ rm -Rf "$tmpgitcache"
[ -d "$gitdest" ] || git clone "$2" "$tmpgitcache" || return 1
[ -d "$gitdest" ] || x_ mkdir -p "${gitdest##*/}"
[ -d "$gitdest" ] || x_ mv "$tmpgitcache" "$gitdest"
git -C "$gitdest" remote add main "$4" 2>/dev/null || :
git -C "$gitdest" remote add backup "$5" 2>/dev/null || :
git -C "$gitdest" fetch --all || :
git -C "$gitdest" pull --all || :
}
bad_checksum()