Each worktree's check compiled everything again with full debuginfo and
incremental caches no rebuild used. The dev profile keeps line tables for
the workspace and none for its dependencies, the check builds without
incremental caches, and builds go through kache where it is installed, so
a worktree's first build reuses what another tree built, build scripts
included. Tests read the tree's paths at run time, so a build is the same
in every tree.
scripts/new-worktree.sh makes a worktree from clones of the main checkout's
suite files, and AGENTS.md says a profiling run removes its traces.
Source: 53a4a8edd b568f382e 0c7a0eabc 72c24f74b 10051ba78 8f415697a 73d557f71
bde4220b6 46c7c6b23
38 lines
1.9 KiB
Bash
Executable File
38 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# A new worktree whose large tracked files are APFS clones of the main checkout's, so git writes
|
|
# only the files that differ. Its builds run with its own CARGO_TARGET_DIR and the environment of
|
|
# scripts/dev-env.sh, which builds through kache where it is installed (docs/development.md).
|
|
#
|
|
# scripts/new-worktree.sh PATH BRANCH [START]
|
|
#
|
|
# BRANCH is a new branch at START (default: the main checkout's HEAD). tests/suite holds 257 of
|
|
# the tree's 278 MiB (its expected and generated files), and a plain `git worktree add` writes
|
|
# every byte of it again. Here the main checkout's tests/suite is cloned into PATH first (on
|
|
# macOS cp -c, which writes nothing until a file changes; on Linux cp --reflink=auto, a copy
|
|
# where the filesystem has no reflinks). git then takes each clone that matches START's blob as
|
|
# clean and writes the rest, and the clone's files START does not track are removed, so the
|
|
# worktree holds START's tree exactly, whatever the main checkout's files are.
|
|
#
|
|
# The worktree is added from the main checkout: a new worktree takes the sparse-checkout
|
|
# settings of the one it is added from.
|
|
set -euo pipefail
|
|
[[ $# -ge 2 ]] || { echo "usage: scripts/new-worktree.sh PATH BRANCH [START]" >&2; exit 2; }
|
|
path=$1 branch=$2
|
|
main=$(git worktree list --porcelain | sed -n '1s/^worktree //p')
|
|
start=${3:-$(git -C "$main" rev-parse HEAD)}
|
|
big=tests/suite
|
|
[[ ! -e $path ]] || { echo "new-worktree: $path exists" >&2; exit 1; }
|
|
git -C "$main" worktree add -q --no-checkout -b "$branch" "$path" "$start"
|
|
path=$(cd "$path" && pwd)
|
|
mkdir -p "$path/$(dirname "$big")"
|
|
if [[ $(uname) == Darwin ]]; then
|
|
cp -c -p -R "$main/$big" "$path/$big"
|
|
else
|
|
cp -a --reflink=auto "$main/$big" "$path/$big"
|
|
fi
|
|
git -C "$path" reset -q
|
|
git -C "$path" update-index -q --refresh || true
|
|
git -C "$path" checkout -q -- .
|
|
git -C "$path" clean -q -f -d -x -- "$big"
|
|
echo "new-worktree: $path on $branch at $(git -C "$path" rev-parse --short HEAD)"
|