From 93d4eca04ae9b7eabb4fa72d96784b9ba714d384 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 8 May 2025 21:33:17 +0100 Subject: 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 --- include/git.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include/git.sh') diff --git a/include/git.sh b/include/git.sh index 81c75806..3e885c1b 100644 --- a/include/git.sh +++ b/include/git.sh @@ -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"; : } -- cgit v1.2.1 From 6bdb15fd329e1ffb22ff37c7e9a296cca633f836 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 8 May 2025 21:36:37 +0100 Subject: git.sh: hard fail if git am fails similar to the last patch, we must ensure that the inability to patch will cause a hard exit, regardless of any redundancy we have for cloning. Signed-off-by: Leah Rowe --- include/git.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/git.sh') diff --git a/include/git.sh b/include/git.sh index 3e885c1b..afcfee93 100644 --- a/include/git.sh +++ b/include/git.sh @@ -94,6 +94,7 @@ tmpclone() resetfail="n" repofail="n" + amfail="n" [ $# -lt 6 ] || rm -Rf "$3" || err "git retry: !rm $3 ($1)" repodir="$XBMK_CACHE/repo/${1##*/}" && [ $# -gt 5 ] && repodir="$3" @@ -109,11 +110,12 @@ tmpclone() ( [ $# -gt 5 ] || git clone "$repodir" "$3" || err "!clone $repodir $3" 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 + [ "$resetfail" = "y" ] || ( fx_ "eval x_ git -C \"$3\" am" find "$5" \ + -type f ) || amfail="y" ) || repofail="y" [ "$resetfail" = "y" ] && err "Cannot reset revisions" + [ "$amfail" = "y" ] && err "Cannot apply patches" [ "$repofail" = "y" ] && [ $# -lt 6 ] && tmpclone "$@" retry [ "$repofail" = "y" ] && err "!clone $1 $2 $3 $4 $5"; : -- cgit v1.2.1 From 454f11bdd7bf7409276b2e0fc301a061b258e8d9 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 8 May 2025 21:38:07 +0100 Subject: git.sh: use setvars for fail variables Signed-off-by: Leah Rowe --- include/git.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'include/git.sh') diff --git a/include/git.sh b/include/git.sh index afcfee93..14def209 100644 --- a/include/git.sh +++ b/include/git.sh @@ -92,9 +92,7 @@ tmpclone() livepull="n" && [ "$repofail" = "y" ] && \ printf "Cached clone failed; trying online.\n" 1>&2 && livepull="y" - resetfail="n" - repofail="n" - amfail="n" + eval "`setvars "n" resetfail repofail amfail`" [ $# -lt 6 ] || rm -Rf "$3" || err "git retry: !rm $3 ($1)" repodir="$XBMK_CACHE/repo/${1##*/}" && [ $# -gt 5 ] && repodir="$3" -- cgit v1.2.1 From 0d876622fcb715eb8cfc03a1bf9bb138fd845731 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 8 May 2025 22:05:28 +0100 Subject: git.sh: re-write tmpclone without caching remove caching for now. it's buggy as hell. will re-write the caching feature next. Signed-off-by: Leah Rowe --- include/git.sh | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) (limited to 'include/git.sh') diff --git a/include/git.sh b/include/git.sh index 14def209..9440b1af 100644 --- a/include/git.sh +++ b/include/git.sh @@ -89,34 +89,12 @@ fetch_submodule() tmpclone() { - livepull="n" && [ "$repofail" = "y" ] && \ - printf "Cached clone failed; trying online.\n" 1>&2 && livepull="y" - - eval "`setvars "n" resetfail repofail amfail`" - - [ $# -lt 6 ] || rm -Rf "$3" || err "git retry: !rm $3 ($1)" - repodir="$XBMK_CACHE/repo/${1##*/}" && [ $# -gt 5 ] && repodir="$3" - mkdir -p "$XBMK_CACHE/repo" || err "!rmdir $XBMK_CACHE/repo" - - if [ "$livepull" = "y" ] && [ ! -d "$repodir" ]; then - git clone "$1" "$repodir" || git clone $2 "$repodir" || \ - err "!clone $1 $2 $repodir $4 $5" # - elif [ -d "$repodir" ] && [ $# -lt 6 ]; then - git -C "$repodir" pull || sleep 3 || git -C "$repodir" pull \ - || sleep 3 || git -C "$repodir" pull || : - fi - ( - [ $# -gt 5 ] || git clone "$repodir" "$3" || err "!clone $repodir $3" - git -C "$3" reset --hard "$4" || resetfail="y" - [ "$resetfail" = "y" ] || ( fx_ "eval x_ git -C \"$3\" am" find "$5" \ - -type f ) || amfail="y" - ) || repofail="y" - - [ "$resetfail" = "y" ] && err "Cannot reset revisions" - [ "$amfail" = "y" ] && err "Cannot apply patches" - - [ "$repofail" = "y" ] && [ $# -lt 6 ] && tmpclone "$@" retry - [ "$repofail" = "y" ] && err "!clone $1 $2 $3 $4 $5"; : + [ -d "$3" ] && return 0 + printf "Creating git clone '%s' from '%s', '%s'\n" "$3" "$1" "$2" + git clone "$1" "$3" || x_ rm -Rf "$3" + [ -d "$3" ] || x_ git clone "$2" "$3" + x_ git -C "$3" reset --hard "$4" + fx_ "eval x_ git -C \"$3\" am" find "$5" -type f } nuke() -- cgit v1.2.1