diff options
author | Leah Rowe <leah@libreboot.org> | 2025-05-13 21:57:34 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2025-05-13 21:57:34 +0100 |
commit | 3c23ff4fa1873e9170326141e31eb588d71a7d3a (patch) | |
tree | eef57d7cd4edadcc5a4bb0f763eb2cb9ce2de601 /include | |
parent | ed8a33d6fb1c380e70fec881e6a0308cea99333e (diff) |
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>
Diffstat (limited to 'include')
-rw-r--r-- | include/git.sh | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/include/git.sh b/include/git.sh index cc9c2f2a..9405828e 100644 --- a/include/git.sh +++ b/include/git.sh @@ -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() |