Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Clean-machine trace leg: let git fetch the pinned git+ requirements, nothing else (#11751)
Daniel Hane658273c7fa9
diff --git a/.github/scripts/clean-machine-assert.sh b/.github/scripts/clean-machine-assert.shindex 9bfb2484fbc..5626250e0d6 100755--- a/.github/scripts/clean-machine-assert.sh+++ b/.github/scripts/clean-machine-assert.sh@@ -6,7 +6,8 @@# "passed" because masking silently failed, or because the installer# quietly installed Xcode CLT behind our back.# notools The trace recorded no compiler/git/brew invocation (trace mode),-# except uv's exact optional libpython self-ID operation.+# except uv's exact optional libpython self-ID operation, and git+# fetching only the git+ remotes of $UNSLOTH_ALLOW_GIT_FROM.# nodylibtool No install_name_tool invocation escaped the CLT-absent guard.# dylibpatch A CLT-present control observed only exact libpython self-ID patches.# nobuild Wheels-only: no "Building wheel" from pip, no "Building <pkg>==<ver>"@@ -41,6 +42,156 @@ _decode_trace_arg() { # encoded, destination variableprintf -v "$2" '%s' "$_decoded"}+# The git+ remotes named by the requirement files in $UNSLOTH_ALLOW_GIT_FROM, one per line,+# without a trailing .git. The files are the source of truth, so a re-pinned remote follows.+_allowed_git_remotes() {+ for _req in ${UNSLOTH_ALLOW_GIT_FROM:-}; do+ [ -f "$_req" ] || { echo "::error::UNSLOTH_ALLOW_GIT_FROM names a missing file: $_req" >&2; continue; }+ # The revision is what follows the LAST @, so ssh://git@host/repo.git@SHA keeps its user.+ sed -n \+ -e 's/^[^#]*git+\([a-z][a-z0-9+.-]*:\/\/[^#[:space:]]*\)@[^@\/#[:space:]]*\([#[:space:]].*\)\{0,1\}$/\1/p' \+ -e 't' \+ -e 's/^[^#]*git+\([a-z][a-z0-9+.-]*:\/\/[^#[:space:]]*\).*/\1/p' "$_req"+ done | sed 's/\.git$//' | sort -u+}++# The commits those requirement files pin (the 40-hex revision after the last @).+_allowed_git_pins() {+ for _req in ${UNSLOTH_ALLOW_GIT_FROM:-}; do+ [ -f "$_req" ] || continue+ sed -n 's/^[^#]*git+[a-z][a-z0-9+.-]*:\/\/[^#[:space:]]*@\([0-9a-f]\{40\}\)\([#[:space:]].*\)\{0,1\}$/\1/p' "$_req"+ done | sort -u+}++# Every remote a traced git command line names: URLs, including `-c remote.origin.url=URL`.+_git_line_remotes() {+ printf '%s\n' "$1" | grep -oE '[a-z][a-z0-9+.-]*://[^[:space:]]+|[[:alnum:]_.-]+@[[:alnum:].-]+:[^[:space:]]+' \+ | sed 's/\.git$//'+}++# Every `submodule update` with these arguments ran inside one of uv's checkouts, read from+# the working directories the git wrapper records beside the trace. It fetches what that+# checkout's .gitmodules names, which is the pinned requirement's own content only there.+# No record, or any run elsewhere, is a no.+_ran_in_uv_checkout() { # the traced argument string+ _ran_under "$1" "${UV_CACHE_DIR%/}/git-v0/checkouts/"+}++# Every run of these arguments (at least one) had its working directory under $2.+_ran_under() { # the traced argument string, a directory prefix ending in /+ [ -n "${UV_CACHE_DIR:-}" ] && [ -f "$TRACE.git-cwd" ] || return 1+ _seen=false+ while IFS=$'\t' read -r _cwd _args; do+ [ "$_args" = "$1" ] || continue+ _seen=true+ case "$_cwd" in "$2"?*) ;; *) return 1 ;; esac+ case "$_cwd" in *..*) return 1 ;; esac+ done < "$TRACE.git-cwd"+ [ "$_seen" = true ]+}++# Every run of these arguments was in a uv checkout named after a prefix of $2.+_in_checkout_of() { # the traced argument string, a full commit+ _ran_in_uv_checkout "$1" || return 1+ while IFS=$'\t' read -r _cwd _args; do+ [ "$_args" = "$1" ] || continue+ _short=${_cwd##*/}+ [ ${#_short} -ge 7 ] || return 1+ case "$_short" in *[!0-9a-f]*) return 1 ;; esac+ case "$2" in "$_short"*) ;; *) return 1 ;; esac+ done < "$TRACE.git-cwd"+}++# A git line naming no remote is allowed only in the exact shapes uv's git source uses to+# check out a pinned commit from its own cache: nothing that can reach the network (a bare+# `fetch origin` reads its URL from config) and nothing outside $UV_CACHE_DIR.+_is_uv_git_cache_op() { # the traced argument string+ _cache="${UV_CACHE_DIR%/}/git-v0"+ case "$1" in+ # uv initialises its database and resolves the pin in its own cache; the same commands+ # anywhere else (the project directory, say) are not uv's.+ init|rev-parse|"rev-parse "*) _ran_under "$1" "$_cache/" ; return ;;+ "submodule update --recursive --init") _ran_in_uv_checkout "$1"; return ;;+ "reset --hard "*)+ # The commit the requirement files pin (the workflow passes the INSTALLED package's,+ # which on an overlay-free leg can trail this checkout's), run in the uv checkout+ # named after it.+ _commit=${1#reset --hard }+ case "$_commit" in *[!0-9a-f]*|"") return 1 ;; esac+ [ ${#_commit} -eq 40 ] || return 1+ printf '%s\n' "$(_allowed_git_pins)" | grep -qxF -- "$_commit" || return 1+ _in_checkout_of "$1" "$_commit"+ return ;;+ "clone --local "*)+ [ -n "${UV_CACHE_DIR:-}" ] || return 1+ set -f; set -- $1; set +f+ [ $# -eq 4 ] || return 1+ case "$3" in "$_cache"/db/*) ;; *) return 1 ;; esac+ case "$4" in "$_cache"/checkouts/*) ;; *) return 1 ;; esac+ case "$3$4" in *..*) return 1 ;; esac+ return 0 ;;+ esac+ return 1+}++# Whether $1 is one of the allowed remotes in $2, ignoring a trailing .git.+_is_allowed_git_remote() {+ [ -n "$1" ] && printf '%s\n' "$2" | grep -qxF -- "${1%.git}"+}++# A git line that names a remote must be one of the two argv shapes uv's git source emits,+# parsed as git would read them rather than by URL-looking substrings (an option VALUE such+# as --server-option=URL is not the repository):+# fetch [--tags|--force|--update-head-ok|--no-tags|--quiet|--depth=N]... URL REFSPEC...+# -c remote.origin.url=URL submodule update [--init|--recursive]...+# The repository must be an allowed remote and every refspec a `src:refs/...` mapping, so no+# other option (--all, --upload-pack, a second -c) and no other subcommand (push) passes.+_is_allowed_remote_git_line() { # the traced argument string, the allowed remotes+ _line=$1+ _allowed=$2+ set -f+ set -- $1+ set +f+ _origin=""+ if [ "${1:-}" = "-c" ]; then+ case "${2:-}" in remote.origin.url=*) _origin=${2#remote.origin.url=}; shift 2 ;; *) return 1 ;; esac+ fi+ case "${1:-}" in+ fetch)+ [ -z "$_origin" ] || return 1+ shift+ _repo=""+ for _word in "$@"; do+ if [ -z "$_repo" ]; then+ case "$_word" in+ --tags|--force|--update-head-ok|--no-tags|--quiet) continue ;;+ --depth=[0-9]*) case "${_word#--depth=}" in *[!0-9]*) return 1 ;; esac; continue ;;+ -*) return 1 ;;+ esac+ _repo=$_word+ continue+ fi+ case "$_word" in+ -*|*://*|*@*:*) return 1 ;;+ ?*:refs/*) ;;+ *) return 1 ;;+ esac+ done+ _is_allowed_git_remote "$_repo" "$_allowed"+ return ;;+ submodule)+ _is_allowed_git_remote "$_origin" "$_allowed" || return 1+ [ "${2:-}" = "update" ] || return 1+ shift 2+ for _word in "$@"; do+ case "$_word" in --init|--recursive) ;; *) return 1 ;; esac+ done+ _ran_in_uv_checkout "$_line"+ return ;;+ esac+ return 1+}+_is_uv_libpython_self_id_patch() { # argc, operation, source, destination, extra[ "$1" = "3" ] && [ "$2" = "-id" ] && [ -n "$3" ] && [ "$3" = "$4" ] \&& [ -z "$5" ] || return 1@@ -160,6 +311,26 @@ for check in "$@"; do# git is legitimate under --local (unsloth-zoo comes from a git URL), so that# leg allow-lists it via UNSLOTH_ALLOW_TOOLS.allow="${UNSLOTH_ALLOW_TOOLS:-}"+ # A default install with a working git fetches its pinned git+ requirements with it+ # (the Diffusers main build: a clone records a ref, the archive fallback does not).+ # That is git, but only for those remotes, so it is allowed structurally: a git line+ # that names a remote must be uv's fetch or submodule shape against one of the+ # requirement files' remotes (_is_allowed_remote_git_line), and one naming none must+ # be one of uv's own cache operations (_is_uv_git_cache_op), counted only when some+ # line did fetch an allowed remote. `--version` is the installer's probe.+ # Any other remote, any other remoteless git, or git that fetched nothing allowed is+ # still a hit.+ allowed_remotes=$(_allowed_git_remotes)+ git_fetched_allowed=false+ if [ -n "$allowed_remotes" ]; then+ while IFS=$'\t' read -r tool rest; do+ [ "$tool" = "git" ] || continue+ case "$rest" in fetch\ *) ;; *) continue ;; esac+ if _is_allowed_remote_git_line "$rest" "$allowed_remotes"; then+ git_fetched_allowed=true+ fi+ done < "$TRACE"+ fihits=""while IFS=$'\t' read -r tool argc_or_rest arg1 arg2 arg3 extra; do[ -n "$tool" ] || continue@@ -177,6 +348,20 @@ for check in "$@"; docontinueficase " $allow " in *" $tool "*) continue ;; esac+ if [ "$tool" = "git" ] && [ -n "$allowed_remotes" ]; then+ git_rest="$argc_or_rest"+ for _field in "$arg1" "$arg2" "$arg3" "$extra"; do+ [ -n "$_field" ] && git_rest="$git_rest $_field"+ done+ if [ "$git_rest" = "--version" ]; then+ continue+ fi+ if [ -n "$(_git_line_remotes "$git_rest")" ]; then+ _is_allowed_remote_git_line "$git_rest" "$allowed_remotes" && continue+ elif [ "$git_fetched_allowed" = true ] && _is_uv_git_cache_op "$git_rest"; then+ continue+ fi+ fi# `xcode-select -p` only ASKS whether a toolchain is selected and the fix is# carrying on without one, so it is not USE. `--install` stays a hit.if [ "$tool" = "xcode-select" ]; thendiff --git a/.github/scripts/clean-machine-env.sh b/.github/scripts/clean-machine-env.shindex 75131d85326..a33d4c64ec9 100755--- a/.github/scripts/clean-machine-env.sh+++ b/.github/scripts/clean-machine-env.sh@@ -42,6 +42,8 @@ BIN="$WORK/bin"RESTORE="$WORK/restore.sh"mkdir -p "$BIN": > "$TRACE"+# The git wrapper appends where each git ran; a rerun must not inherit an older install's rows.+: > "$TRACE.git-cwd": > "$ENV_FILE"printf '#!/usr/bin/env bash\n# Undo clean-machine-env.sh --remove. Safe to run twice.\nset -uo pipefail\n' > "$RESTORE"chmod +x "$RESTORE"@@ -231,9 +233,14 @@ if [ "$MODE" = "trace" ]; thenif [ "$tool" = "install_name_tool" ]; thenbash "$INSTALL_NAME_TOOL_HELPER" write passthrough "$BIN/$tool" "$real"else+ # git also records where it ran: `submodule update` fetches whatever the CURRENT+ # checkout's .gitmodules names, so notools has to see that it ran inside uv's checkout.+ cwd_line=""+ [ "$tool" = "git" ] && cwd_line="printf '%s\t%s\n' \"\$PWD\" \"\$*\" >> '$TRACE.git-cwd'"cat > "$BIN/$tool" <<WRAP#!/bin/shprintf '%s\t%s\n' "$tool" "\$*" >> "$TRACE"+$cwd_lineexec "$real" "\$@"WRAPfidiff --git a/.github/workflows/clean-machine-install-ci.yml b/.github/workflows/clean-machine-install-ci.ymlindex 6784e292848..d7d7ec0c2b4 100644--- a/.github/workflows/clean-machine-install-ci.yml+++ b/.github/workflows/clean-machine-install-ci.yml@@ -248,8 +248,8 @@ jobs:run: |# `notools` reads an absence, so a shim dir that never reached PATH looks exactly# like an installer that touched nothing: prove the wrapper records before- # trusting an empty file. macOS never probes git off the --local path, so the- # call has to be explicit.+ # trusting an empty file. The installer's own git use depends on what it installs,+ # so the call has to be explicit.set -a; . ./clean-machine.env; set +a[ -n "$UNSLOTH_TOOL_TRACE" ] || { echo "::error::trace mode set no UNSLOTH_TOOL_TRACE"; exit 1; }git --version >/dev/null 2>&1 || true@@ -258,8 +258,15 @@ jobs:echo "PATH=$PATH"; command -v git; cat "$UNSLOTH_TOOL_TRACE" || trueexit 1fi+ # notools reads where git ran from this record; without it every uv submodule+ # update is a hit, so say so here rather than as a toolchain use.+ grep -q "$(printf '\t')--version$" "$UNSLOTH_TOOL_TRACE.git-cwd" 2>/dev/null || {+ echo "::error::the git wrapper did not record its working directory"+ exit 1+ }echo "trace wrapper records; clearing the self-test entry": > "$UNSLOTH_TOOL_TRACE"+ : > "$UNSLOTH_TOOL_TRACE.git-cwd"- name: Installid: install@@ -358,6 +365,20 @@ jobs:# CLT or installed a compiler left the leg green. Re-run it after.[ "${{ matrix.mode }}" = "mask" ] && checks="$checks absent nodylibtool"[ "${{ matrix.mode }}" = "trace" ] && checks="$checks notools dylibpatch"+ # With a working git the default install clones its pinned git+ requirements, so+ # `notools` lets git fetch exactly those remotes and nothing else. The pins are read+ # from the package under test: an overlay-free leg installs the released wheel, whose+ # pin can differ from this checkout's, so the installed copy replaces the checkout's.+ allow_git_from=""+ for installed in "$UNSLOTH_STUDIO_HOME"/unsloth_studio/lib/python*/site-packages/studio/backend/requirements/diffusers-main.txt; do+ if [ -f "$installed" ]; then allow_git_from="$allow_git_from $installed"; fi+ done+ if [ -z "$allow_git_from" ]; then+ echo "::warning::no installed diffusers-main.txt under the managed venv; reading this checkout's pin"+ allow_git_from='studio/backend/requirements/diffusers-main.txt'+ fi+ echo "git+ allowance read from: $allow_git_from"+ UNSLOTH_ALLOW_GIT_FROM="$allow_git_from" \UNSLOTH_CLEAN_ALLOW_WORKING='${{ matrix.allow_working }}' \bash .github/scripts/clean-machine-assert.sh $checksdiff --git a/tests/sh/test_clean_machine_notools_pinned_git.sh b/tests/sh/test_clean_machine_notools_pinned_git.shnew file mode 100755index 00000000000..aee80858671--- /dev/null+++ b/tests/sh/test_clean_machine_notools_pinned_git.sh@@ -0,0 +1,191 @@+#!/bin/bash+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0+# The macOS trace leg's `notools` lets git fetch the pinned git+ requirements and nothing else.+#+# A default install with a working git clones the pinned Diffusers main build through uv, so the+# trace records git. `notools` rejected every git line, and the leg went red on the first+# installer PR after the build became the default. The allowance is structural: each git line+# may name only a remote from the requirement files in UNSLOTH_ALLOW_GIT_FROM, and a remoteless+# line must be one of uv's own cache operations, counted only when an allowed remote was+# fetched. The first trace below is the one that leg recorded.+set -e++SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"+REPO_ROOT="$SCRIPT_DIR/../.."+ASSERT_SH="$REPO_ROOT/.github/scripts/clean-machine-assert.sh"+PIN="$REPO_ROOT/studio/backend/requirements/diffusers-main.txt"+ROOT=$(mktemp -d)+trap 'rm -rf "$ROOT"' EXIT+PASS=0+FAIL=0++expect_rc() {+ _label="$1"; _expected="$2"; _allow="$3"; _trace_content="$4"+ # Where every git line ran, as the wrapper records it: uv's checkout unless the row says+ # otherwise, or "none" for a trace with no record at all.+ _cwd="${5:-$CACHE/checkouts/76e25d04238765dd/${SHA:0:9}}"+ printf '%b' "$_trace_content" > "$ROOT/trace.log"+ rm -f "$ROOT/trace.log.git-cwd"+ if [ "$_cwd" != none ]; then+ awk -F '\t' -v cwd="$_cwd" '$1 == "git" { print cwd "\t" $2 }' "$ROOT/trace.log" \+ > "$ROOT/trace.log.git-cwd"+ fi+ set +e+ UV_CACHE_DIR="$UV_CACHE" UNSLOTH_ALLOW_GIT_FROM="$_allow" UNSLOTH_TOOL_TRACE="$ROOT/trace.log" \+ INSTALL_LOG="$ROOT/install.log" bash "$ASSERT_SH" notools \+ > "$ROOT/out.log" 2>&1+ _actual=$?+ set -e+ if [ "$_actual" -eq "$_expected" ]; then+ echo " PASS: $_label"+ PASS=$((PASS + 1))+ else+ echo " FAIL: $_label (expected rc $_expected, got $_actual)"+ cat "$ROOT/out.log"+ FAIL=$((FAIL + 1))+ fi+}++: > "$ROOT/install.log"+REMOTE=$(sed -n 's/^[^#]*git+\(https:\/\/[^@]*\)@.*/\1/p' "$PIN")+SHA=$(sed -n 's/^[^#]*git+https:\/\/[^@]*@\([0-9a-f]*\).*/\1/p' "$PIN")+[ -n "$REMOTE" ] && [ -n "$SHA" ] || { echo "no git+ pin in $PIN"; exit 1; }+UV_CACHE=/Users/runner/work/unsloth/unsloth/.clean-machine/uv-cache+CACHE=$UV_CACHE/git-v0++# The macOS trace / file leg's record, with the pin read from the file it came from.+UV_CLONE="git\t--version+git\t-c remote.origin.url=$REMOTE submodule update --init+git\tclone --local $CACHE/db/76e25d04238765dd $CACHE/checkouts/76e25d04238765dd/${SHA:0:9}+git\tfetch --tags --force --update-head-ok $REMOTE +refs/heads/*:refs/remotes/origin/* +HEAD:refs/remotes/origin/HEAD+git\tinit+git\treset --hard $SHA+git\trev-parse+git\trev-parse --short $SHA+git\trev-parse $SHA^0+git\trev-parse HEAD+git\tsubmodule update --recursive --init+xcode-select\t-p+"++echo "=== pinned git+ remotes ==="+expect_rc "uv cloning the pinned Diffusers build passes" 0 "$PIN" "$UV_CLONE"+expect_rc "the same trace fails with no allowance, as before" 1 "" "$UV_CLONE"+expect_rc "an allowance file that does not exist allows nothing" 1 "$ROOT/missing.txt" "$UV_CLONE"+expect_rc "the installer's git --version probe alone passes" 0 "$PIN" "git\t--version\n"+# An overlay-free leg installs the released wheel, which can pin an older commit than this+# checkout's file; uv's checkout is named after the commit it installs.+OLDER=1111111111111111111111111111111111111111+FETCH="git\tfetch --tags --force --update-head-ok $REMOTE +HEAD:refs/remotes/origin/HEAD\n"+OLDER_PIN="$ROOT/older-diffusers-main.txt"+printf 'diffusers @ git+%s@%s\n' "$REMOTE" "$OLDER" > "$OLDER_PIN"+expect_rc "a released package pinning another commit passes in its own checkout" 0 "$OLDER_PIN" \+ "${FETCH}git\treset --hard $OLDER\n" "$CACHE/checkouts/76e25d04238765dd/${OLDER:0:9}"+expect_rc "a reset to a commit the passed file does not pin fails, even in its checkout" 1 "$PIN" \+ "${FETCH}git\treset --hard $OLDER\n" "$CACHE/checkouts/76e25d04238765dd/${OLDER:0:9}"+expect_rc "a reset outside uv's checkouts fails" 1 "$OLDER_PIN" \+ "${FETCH}git\treset --hard $OLDER\n" "/home/someone/${OLDER:0:9}"+expect_rc "a short or abbreviated reset target fails" 1 "$OLDER_PIN" \+ "${FETCH}git\treset --hard ${OLDER:0:9}\n" "$CACHE/checkouts/76e25d04238765dd/${OLDER:0:9}"+expect_rc "git init outside uv's cache fails" 1 "$PIN" \+ "${FETCH}git\tinit\n" /Users/runner/work/unsloth/unsloth+expect_rc "rev-parse outside uv's cache fails" 1 "$PIN" \+ "${FETCH}git\trev-parse HEAD\n" /Users/runner/work/unsloth/unsloth+expect_rc "git init in uv's database passes" 0 "$PIN" \+ "${FETCH}git\tinit\n" "$CACHE/db/76e25d04238765dd"+SSH_PIN="$ROOT/ssh-pin.txt"+printf 'pkg @ git+ssh://[email protected]/org/repo.git@%s\n' "$SHA" > "$SSH_PIN"+expect_rc "an ssh requirement keeps its user in the allowed remote" 0 "$SSH_PIN" \+ "git\tfetch --force ssh://[email protected]/org/repo.git +HEAD:refs/remotes/origin/HEAD\n"+expect_rc "an ssh requirement does not allow its bare scheme and user" 1 "$SSH_PIN" \+ "git\tfetch --force ssh://git +HEAD:refs/remotes/origin/HEAD\n"+# The workflow passes the installed package's copy, which can pin another repository than+# this checkout; only the file passed counts.+INSTALLED_PIN="$ROOT/installed-diffusers-main.txt"+printf 'diffusers @ git+https://github.com/example/diffusers-fork.git@%s\n' "$SHA" > "$INSTALLED_PIN"+expect_rc "the installed package's remote is allowed" 0 "$INSTALLED_PIN" \+ "git\tfetch --force https://github.com/example/diffusers-fork.git +HEAD:refs/remotes/origin/HEAD\n"+expect_rc "this checkout's remote is then a hit" 1 "$INSTALLED_PIN" \+ "git\tfetch --force $REMOTE +HEAD:refs/remotes/origin/HEAD\n"+expect_rc "a remote with the .git suffix dropped still matches" 0 "$PIN" \+ "git\tfetch ${REMOTE%.git} +HEAD:refs/remotes/origin/HEAD\n"++echo "=== everything else is still a hit ==="+expect_rc "cloning any other remote fails" 1 "$PIN" \+ "${UV_CLONE}git\tclone https://github.com/someone/else.git /tmp/else\n"+expect_rc "an scp-style remote that is not pinned fails" 1 "$PIN" \+ "${UV_CLONE}git\tfetch [email protected]:someone/else.git\n"+expect_rc "a config-injected remote that is not pinned fails" 1 "$PIN" \+ "${UV_CLONE}git\t-c remote.origin.url=https://example.com/x.git submodule update\n"+expect_rc "a lookalike host that only starts with the pin fails" 1 "$PIN" \+ "git\tfetch ${REMOTE%.git}-fork.git +HEAD:refs/remotes/origin/HEAD\n"+expect_rc "remoteless git with no allowed fetch fails" 1 "$PIN" \+ "git\tinit\ngit\trev-parse HEAD\n"+expect_rc "a remoteless fetch beside the allowed one fails (its URL is in config)" 1 "$PIN" \+ "${UV_CLONE}git\tfetch origin\n"+expect_rc "a local clone outside uv's cache fails" 1 "$PIN" \+ "${UV_CLONE}git\tclone /tmp/unrelated /tmp/out\n"+expect_rc "a local clone that climbs out of uv's cache fails" 1 "$PIN" \+ "${UV_CLONE}git\tclone --local $CACHE/db/x/../../../x $CACHE/checkouts/x/y\n"+expect_rc "a reset to a commit nothing pins fails" 1 "$PIN" \+ "${UV_CLONE}git\treset --hard 0000000000000000000000000000000000000000\n"+expect_rc "any other remoteless subcommand fails" 1 "$PIN" \+ "${UV_CLONE}git\tpull\n"+expect_rc "an allowed remote with an extra -c option fails" 1 "$PIN" \+ "${UV_CLONE}git\t-c core.sshCommand=evil fetch $REMOTE\n"+expect_rc "pushing to the allowed remote fails" 1 "$PIN" \+ "${UV_CLONE}git\tpush $REMOTE HEAD:refs/heads/oops\n"+expect_rc "cloning the allowed remote outside uv's fetch fails" 1 "$PIN" \+ "${UV_CLONE}git\tclone $REMOTE /tmp/out\n"+expect_rc "a -c after the subcommand fails too" 1 "$PIN" \+ "${UV_CLONE}git\tfetch -c core.sshCommand=evil $REMOTE\n"+expect_rc "a remote URL as an option value is not the repository" 1 "$PIN" \+ "${UV_CLONE}git\tfetch --all --server-option=$REMOTE\n"+expect_rc "an option value alone does not count as the allowed fetch" 1 "$PIN" \+ "git\tfetch --all --server-option=$REMOTE\ngit\tinit\n"+expect_rc "an unknown fetch option before the repository fails" 1 "$PIN" \+ "${UV_CLONE}git\tfetch --upload-pack=evil $REMOTE +HEAD:refs/remotes/origin/HEAD\n"+expect_rc "an option after the repository fails" 1 "$PIN" \+ "${UV_CLONE}git\tfetch $REMOTE --upload-pack=evil\n"+expect_rc "a second repository in the refspec slot fails" 1 "$PIN" \+ "${UV_CLONE}git\tfetch $REMOTE https://github.com/someone/else.git\n"+expect_rc "submodule update run outside uv's checkout fails" 1 "$PIN" \+ "$UV_CLONE" /home/someone/other-repo+expect_rc "submodule update run in a path that climbs out of uv's checkouts fails" 1 "$PIN" \+ "$UV_CLONE" "$CACHE/checkouts/../../elsewhere"+expect_rc "a trace with no record of where git ran fails" 1 "$PIN" "$UV_CLONE" none+expect_rc "submodule update with any other option fails" 1 "$PIN" \+ "${UV_CLONE}git\t-c remote.origin.url=$REMOTE submodule update --remote\n"+expect_rc "a compiler next to the allowed clone still fails" 1 "$PIN" \+ "${UV_CLONE}clang\t-c foo.c\n"+expect_rc "brew next to the allowed clone still fails" 1 "$PIN" \+ "${UV_CLONE}brew\tinstall cmake\n"++echo "=== the trace wrapper's working-directory record ==="+# Trace mode only writes wrappers, so it runs as-is on Linux. The git wrapper must record+# where it ran, and a fresh trace must start that record empty, or a rerun judges the new+# install by an older one's rows.+ENV_SH="$REPO_ROOT/.github/scripts/clean-machine-env.sh"+if command -v git >/dev/null 2>&1; then+ CM="$ROOT/cm"+ CLEAN_MACHINE_DIR="$CM" CLEAN_ENV_FILE="$ROOT/cm.env" bash "$ENV_SH" trace > "$ROOT/cm1.log" 2>&1+ mkdir -p "$ROOT/elsewhere"+ ( cd "$ROOT/elsewhere" && "$CM/bin/git" --version > /dev/null )+ _record=$(cat "$CM/tool-invocations.log.git-cwd" 2>/dev/null || true)+ if [ "$_record" = "$(cd "$ROOT/elsewhere" && pwd) --version" ]; then+ echo " PASS: the git wrapper records its working directory"; PASS=$((PASS + 1))+ else+ echo " FAIL: the git wrapper records its working directory (got: $_record)"; FAIL=$((FAIL + 1))+ fi+ CLEAN_MACHINE_DIR="$CM" CLEAN_ENV_FILE="$ROOT/cm.env" bash "$ENV_SH" trace > "$ROOT/cm2.log" 2>&1+ if [ ! -s "$CM/tool-invocations.log.git-cwd" ]; then+ echo " PASS: a new trace starts the record empty"; PASS=$((PASS + 1))+ else+ echo " FAIL: a new trace starts the record empty"; FAIL=$((FAIL + 1))+ fi+fi++echo ""+echo "Passed: $PASS, Failed: $FAIL"+[ "$FAIL" -eq 0 ]