git.sh: Hard fail if reset fails

We allow a re-try when cloning fails, to account
for redundancy, but resetfail currently doesn't
cause any error exit at all.

This patch mitigates that bug.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2025-05-08 21:33:17 +01:00
parent a3ba8acfac
commit 93d4eca04a

View File

@@ -92,6 +92,7 @@ tmpclone()
livepull="n" && [ "$repofail" = "y" ] && \
printf "Cached clone failed; trying online.\n" 1>&2 && livepull="y"
resetfail="n"
repofail="n"
[ $# -lt 6 ] || rm -Rf "$3" || err "git retry: !rm $3 ($1)"
@@ -107,10 +108,13 @@ tmpclone()
fi
(
[ $# -gt 5 ] || git clone "$repodir" "$3" || err "!clone $repodir $3"
git -C "$3" reset --hard "$4" || err "!reset $1 $2 $3 $4 $5"
git -C "$3" reset --hard "$4" || resetfail="y"
[ "$resetfail" = "y" ] && err "'$3': Cannot reset to rev '$4'"
fx_ "eval x_ git -C \"$3\" am" find "$5" -type f
) || repofail="y"
[ "$resetfail" = "y" ] && err "Cannot reset revisions"
[ "$repofail" = "y" ] && [ $# -lt 6 ] && tmpclone "$@" retry
[ "$repofail" = "y" ] && err "!clone $1 $2 $3 $4 $5"; :
}