#!/usr/bin/env bash# What crates/ holds right now, as one git tree hash: the committed tree when# nothing under crates/ is edited, and the tree a commit of every edit would# make when something is. Two checkouts answer the same hash exactly when their# crates/ match, whatever commit either sits on.## One definition, two callers: crates/cotton-ffi/build.rs stamps it into the# core it builds, and scripts/core-fresh.sh compares that stamp with this# checkout's. The real index is never touched; a copy takes the edits.## bash scripts/lib/crates-tree.sh <checkout root>set -euo pipefailroot="${1:?usage: crates-tree.sh <checkout root>}"index="$(git -C "$root" rev-parse --path-format=absolute --git-path index)"scratch="$(mktemp -d)"trap'rm -rf "$scratch"' EXITif [ -f "$index" ]; then cp "$index""$scratch/index"; fiGIT_INDEX_FILE="$scratch/index" git -C "$root" add -A -- crates >/dev/null 2>&1GIT_INDEX_FILE="$scratch/index" git -C "$root" write-tree --prefix=crates/