diff --git a/tools/fetch_refs.sh b/tools/fetch_refs.sh index 8c2aee0b..6addaa70 100644 --- a/tools/fetch_refs.sh +++ b/tools/fetch_refs.sh @@ -6,23 +6,33 @@ set -eu cd "$(dirname "$0")/.." mkdir -p refs +# fetch [history]: a shallow checkout of the commit, or with "history" the commit and all its +# ancestors (tools/shader_list.py walks the log of MacNativeGames' shader list). origin/HEAD names the commit either +# way, so tools can read the pinned revision as origin/HEAD. fetch() { - name=$1 url=$2 commit=$3 + name=$1 url=$2 commit=$3 history=${4:-} dir=refs/$name - if [ "$(git -C "$dir" rev-parse HEAD 2>/dev/null)" = "$commit" ]; then + if [ "$(git -C "$dir" rev-parse HEAD 2>/dev/null)" = "$commit" ] && + [ "$(git -C "$dir" rev-parse -q --verify refs/remotes/origin/HEAD 2>/dev/null)" = "$commit" ] && + { [ -z "$history" ] || [ "$(git -C "$dir" rev-parse --is-shallow-repository)" = false ]; }; then echo "$name: up to date" return fi rm -rf "$dir" git init -q "$dir" git -C "$dir" remote add origin "$url" - git -C "$dir" fetch -q --depth 1 origin "$commit" + if [ -n "$history" ]; then + git -C "$dir" fetch -q origin "$commit" + else + git -C "$dir" fetch -q --depth 1 origin "$commit" + fi git -C "$dir" checkout -q FETCH_HEAD + git -C "$dir" update-ref refs/remotes/origin/HEAD "$commit" echo "$name: $commit" } fetch LASRecomp https://github.com/peiikai/LASRecomp.git da35b83a9611d046a9a681aae668d7085954d37f -fetch MacNativeGames https://github.com/ly05010419/MacNativeGames.git b75be8cfa704df3701e86130c8ced268e79d6b11 +fetch MacNativeGames https://github.com/ly05010419/MacNativeGames.git b75be8cfa704df3701e86130c8ced268e79d6b11 history fetch d2r-mobile https://github.com/jhaizhou-ops/d2r-mobile.git 53e7c5bb9ca3ea53e2160005be8fbe920cd9cb53 fetch nxnative https://github.com/seedds/nxnative.git d5b380b3a80495609c2e751bb994911a638935ad fetch SwitchRecomp https://github.com/bgyss/SwitchRecomp.git 0f99e1c5c1e78fdc8e01e58a0f8dc8622e82976b diff --git a/tools/shader_list.py b/tools/shader_list.py index ec3c6310..493f0d00 100644 --- a/tools/shader_list.py +++ b/tools/shader_list.py @@ -8,6 +8,7 @@ our play meets: at 1340bee the list alone has 134 rows of 1.4.3 shaders, its his 25,238. A row no draw asks for costs one translation. No copy of the list goes into the repository. """ import subprocess +import sys PATH = 'games/totk/assets/shader_list.tsv' @@ -18,6 +19,9 @@ def git(repo, *args): def history(repo, rev='origin/HEAD'): """rev's list, then each V row of an older revision that no newer one has, newest first.""" + if git(repo, 'rev-parse', '--is-shallow-repository').strip() == 'true': + # a shallow clone has rev's list only: preparing from it skips most variants and shows only as stutter in play + sys.exit(f'{repo} is a shallow clone without the shader list\'s history; run tools/fetch_refs.sh') lines = git(repo, 'show', f'{rev}:{PATH}').splitlines() seen = set(lines) for h in git(repo, 'log', '--format=%H', rev, '--', PATH).split()[1:]: