jj_prek: snapshot the working copy (#7770)

Instead of running on the "current" `@` (the state at which the previous
`jj` command happened to be run), intentionally trigger a working copy
snapshot from `jj_prek`.

Assisted-by: Claude Opus 5 via Antigravity
This commit is contained in:
Richard Smith
2026-09-11 06:14:28 +00:00
committed by GitHub
parent 49345352d6
commit 455f1af2b2
+8 -2
View File
@@ -9,9 +9,15 @@
set -eu
# Find the .git directory, and map `@` to a git commit.
# Map `@` to a git commit. This deliberately doesn't pass
# `--ignore-working-copy`, so that jj first snapshots the files on disk into `@`;
# otherwise the index built below can describe stale file contents, and hooks
# both check the wrong thing and fail to write back their fixes.
HEAD="$(jj show --no-patch -r @ --template 'commit_id')"
# Find the .git directory. The working copy was snapshotted above, so this
# doesn't need to do so again.
export GIT_DIR="$(jj git root --ignore-working-copy)"
HEAD="$(jj show --no-patch --ignore-working-copy -r @ --template 'commit_id')"
# Create a git index file describing `@`.
export GIT_INDEX_FILE="$(mktemp)"