Switch from git checkout-index to git archive with a temp directory,
fixing unquoted variables, TMPDIR name collision, missing set -e,
missing existence check for destination, and mktemp running
unconditionally. Fix typo in error message.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>