Policy and hooks: staged type changes, pinned exception, executable pre-commit #246

Closed
SkippySteve wants to merge 88 commits from upstream-pr/246 into main
SkippySteve commented 2026-11-24 01:45:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SkippySteve on 2026-11-24T01:45:58Z.


Fixes to the asset-policy and pre-commit tooling, plus an .editorconfig, one commit each. This PR now also carries #252, #253 and #291, which are closed in its favour.

1. The staged check also reads files whose type changed

The pre-commit hook (cargo xtask policy --staged) lists staged paths with git diff --cached --name-only --diff-filter=ACMR. A path whose type changed, such as a committed symlink replaced by a regular file, is staged as T, so it is not listed and none of its content is checked. A binary committed under an allowed name such as data.rs passes the hook.

ln -s elsewhere.rs data.rs && git add data.rs && git commit -m link
rm data.rs && printf 'MZ\0\0binary' > data.rs && git add data.rs
git diff --cached --name-status                            # T  data.rs
git diff --cached --name-only --diff-filter=ACMR           # (nothing)

The fix adds T to the filter. The new test staged_check_reads_type_changes sets up that case in a temporary repository and checks that list_files returns the path and that run(.., staged = true) fails. It is #[cfg(unix)] because creating symlinks on Windows needs extra privileges. tempfile, already a workspace dependency, is added as a dev-dependency of xtask.

2. ensure_outside_repo resolves .. below a directory not yet created (was #252)

ensure_outside_repo resolves a destination that does not exist yet by walking up to its longest existing prefix. The walk took each component with Path::file_name, which is None for a path ending in .., so a destination such as <tmp>/missing/../cache failed with cannot resolve ...: No such file or directory instead of being checked. A cache or data directory configured that way was refused even though it is outside the repository.

The fix takes the last component with components().next_back() and accepts both normal names and ..; the tail is already normalized lexically afterwards. Root and prefix components still end the walk with the same error. The new test resolves_dotdot_after_a_missing_directory checks that <tmp>/missing/../cache is accepted and that <repo>/not-yet-created/../out is reported as InsideRepo (it was an Io error before).

3. Track .githooks/pre-commit as executable (was #253)

.githooks/pre-commit was tracked as 100644. Git outside Windows skips a non-executable hook and only prints a hint, so after cargo xtask install-hooks a commit on Linux or macOS never ran the policy check:

hint: The '.githooks/pre-commit' hook was ignored because it's not set as executable.
  • Mark .githooks/pre-commit as 100755 (mode change only).
  • Add hooks_are_tracked_executable to xtask: it reads git ls-files --stage -- .githooks and fails if a tracked hook is not 100755 (it skips itself outside a git checkout).

Git for Windows runs hooks regardless of the bit, so nothing changes there.

4. An .editorconfig that says what the tree already holds (was #291)

Adds a root .editorconfig that states what the tree already holds: UTF-8, LF (as .gitattributes says), a final newline, no trailing whitespace, spaces; 4-space indent for .rs/.toml, 2 for .yml/.yaml/.json; CRLF for .cmd/.ps1, which .gitattributes already checks out that way. Rust layout stays rustfmt's. It changes no existing file.

5. Names that are not UTF-8, and submodules, no longer pass unread

The check decoded each path with from_utf8_lossy and then read the file back by that decoded name (git show :<name> when staged, fs::read otherwise). For a name that is not UTF-8 the decoded name does not exist, the read failed, and the loop continued, so the file was never checked, whatever it held. A submodule (gitlink) failed the read the same way and was skipped too:

printf 'MZ\0' > "$(printf 'a\xff.bin')"
git update-index --add --cacheinfo 160000,<any id>,vendor
git add -A && cargo xtask policy --staged      # asset policy: ... files ok
  • Staged content is read by object id from git diff --cached --raw -z --no-abbrev --no-renames --diff-filter=ACMT, so no file name can make the read fail. Renames are checked as the additions they are.
  • Paths on disk are read by their exact bytes on Unix.
  • A name that is not UTF-8 is a violation in itself (it can be neither allowlisted nor reported reliably).
  • A submodule is a violation whether staged or only tracked (found through git ls-files --stage, since it may not be checked out).
  • A path the check cannot read now fails instead of passing; a tracked file deleted from the working tree is still skipped.

New hermetic tests in temporary repositories: staged_check_reads_renames, non_utf8_names_are_violations (staged straight into the index, as macOS refuses such names on disk), non_utf8_names_on_disk_are_read (Linux only), submodules_are_violations. docs/asset-policy.md mentions the two new rules.

6. The tests no longer follow GIT_INDEX_FILE out of their temporary repositories

The new tests run git in temporary repositories, but git lets GIT_DIR, GIT_INDEX_FILE and similar variables choose the repository over the working directory. A pre-commit hook runs with GIT_INDEX_FILE set, and git commit -a sets it to an absolute path, so tests run from a hook (or with GIT_DIR exported) all wrote into that one outside index:

GIT_INDEX_FILE=/tmp/x/leak-index cargo test -p xtask
# 5 failed: staged_check_reads_type_changes, staged_check_reads_renames,
# submodules_are_violations, non_utf8_names_are_violations, hooks_are_tracked_executable
# and /tmp/x/leak-index now exists
  • All of xtask's git calls go through git_command(root). Under cfg(test) it drops the variables git rev-parse --local-env-vars lists.
  • The hook itself keeps them, since git commit -a and git commit <path> stage into a temporary index that only GIT_INDEX_FILE names.
  • New test test_git_ignores_the_repository_environment checks that each listed variable is removed and that the list matches the one the installed git prints.

7. Submodules that git is told to ignore are still seen

git diff honours diff.ignoreSubmodules and a submodule's ignore = all in .gitmodules, which it reads from the working tree even when that file is untracked. Either one left a staged submodule out of git diff --cached --raw, so the check from section 5 never saw it:

git update-index --add --cacheinfo 160000,<any id>,vendor
printf '[submodule "v"]\n\tpath = vendor\n\turl = x\n\tignore = all\n' > .gitmodules
cargo xtask policy --staged      # asset policy: 0 files ok
  • The staged listing passes --ignore-submodules=none.
  • New test staged_submodules_are_seen_whatever_git_ignores sets both the config and an untracked .gitmodules, checks that plain git diff --cached hides the submodule, and that the policy lists and refuses it. It fails without the fix.

Git stores a symlink as its target path, and the staged check reads exactly that. The full check (cargo xtask policy, and the repository_passes_policy test) read each path with fs::read, which follows the link, so the two disagreed:

printf 'MZ\0' > /tmp/out/game.bin; ln -s /tmp/out/game.bin binary.rs   # hook: ok; full check: "looks like a PE executable"
ln -s "$(printf 'a%.0s' $(seq 600))/x" dangling.rs                       # hook: refused; full check: skipped as deleted
mkfifo /tmp/out/fifo; ln -s /tmp/out/fifo fifo.rs                       # full check: blocks forever
  • Paths on disk are inspected with symlink_metadata: a symlink is checked as its target path (bytes on Unix, /-separated UTF-8 on Windows, as Git for Windows stores it); a FIFO or device is a violation; only regular files are read.
  • New test symlinks_are_checked_as_git_stores_them covers all three cases and that the staged and full checks agree. Without the fix it fails on the outside link, and hangs on the FIFO link.
  • docs/asset-policy.md says how symlinks are checked.

9. The one exception covers its content, not its name

EXCEPTIONS skipped crates/victory-formats/src/bcpack-tables.bin by path before anything was read, so whatever was later committed under that name (an executable, an archive, a file of any size) passed both the hook and the full check:

printf 'MZ\0' > crates/victory-formats/src/bcpack-tables.bin
git add -A && cargo xtask policy --staged      # asset policy: ... files ok
  • Each entry now carries the BLAKE3 of the content it was granted for (f0f032aa…73c0 for the current tables, unchanged from main). Any other content at that path is a violation that names both hashes.
  • blake3, already a workspace dependency, is added to xtask.
  • New tests exceptions_are_pinned_to_their_content (pure) and exempted_paths_refuse_other_content (temporary repository: other content is refused by the full and staged checks, the real tables pass both).
  • docs/asset-policy.md says exceptions are pinned.

10. The tests' temporary repositories read no global or system git config

The tests in temporary repositories ran git with the developer's own configuration. A global core.excludesFile that matches what a test stages makes git add refuse it, and a global core.hooksPath runs the developer's hooks inside the test repositories:

printf '*.rs\n' > /tmp/x/ignore
printf '[core]\n\texcludesFile = /tmp/x/ignore\n' > /tmp/x/gitconfig
GIT_CONFIG_GLOBAL=/tmp/x/gitconfig cargo test -p xtask
# 4 failed: staged_check_reads_type_changes, staged_check_reads_renames,
# symlinks_are_checked_as_git_stores_them, non_utf8_names_on_disk_are_read
  • Under cfg(test), git_command sets GIT_CONFIG_GLOBAL=/dev/null and GIT_CONFIG_NOSYSTEM=1 for any root other than the checkout (Git for Windows opens /dev/null as NUL).
  • The checkout keeps the developer's configuration, so repository_passes_policy still honours a global excludes file (for .DS_Store and the like), as cargo xtask policy does.
  • New test temporary_repositories_read_only_their_own_config checks that git config --list --show-scope in a temporary repository shows only local entries, and that the checkout's command is left alone.

11. Git LFS pointers are refused

A Git LFS pointer is a few lines of text under an allowed name, so it passed both checks, while the file it stands for went to LFS storage, which nothing checks. With filter=lfs in .gitattributes, the index holds only the pointer, so the staged check never saw the real content, and a checkout without git-lfs sees only the pointer too:

git lfs track '*.txt' && cp game-strings.bin strings.txt
git add .gitattributes strings.txt && cargo xtask policy --staged   # asset policy: ... files ok
  • check refuses content that begins with an LFS pointer's version line (https://git-lfs.github.com/spec/ or the pre-1.0 https://hawser.github.com/spec/). A mention of the URL elsewhere in a file is not affected.
  • New tests rejects_lfs_pointers (pure) and lfs_tracked_files_are_violations (temporary repository with a stand-in filter.lfs.clean, so git-lfs need not be installed; it checks that the index holds the pointer and that the staged and full checks refuse it). Both fail without the fix.
  • docs/asset-policy.md says LFS pointers are refused.

12. The tests' temporary repositories stay out of a TMPDIR inside the checkout

With TMPDIR inside the checkout, each test's temporary repository is an untracked directory there, and repository_passes_policy, running on another thread, sometimes lists it and the files the test stages:

mkdir scratch-tmp && TMPDIR=$PWD/scratch-tmp RUST_TEST_THREADS=8 target/debug/deps/xtask-<hash>   # in a loop
# 2 of 100 runs fail:
# POLICY: scratch-tmp/.tmpVAcWIF/pointer: a Git LFS pointer: ...
  • The tests take their temporary directories from one helper, tempdir(). It uses TMPDIR when the checkout's full check cannot see it (it is outside, or git check-ignore says it is ignored), otherwise the test binary's directory under target/, which is ignored. If neither is, the test fails with a message saying to set TMPDIR outside the checkout, so it does not flake.
  • With TMPDIR inside the checkout: 0 failures in 300 runs, and nothing left behind.

13. An untracked repository nested in the checkout is named as such

git ls-files --others lists an untracked repository inside the checkout as its directory, with a trailing /. The full check already refused it, but said "a directory tracked as a file (a submodule?)", which is wrong on both counts. It now says "a git repository nested in this one: its files bypass this check". New test nested_repositories_are_violations; docs/asset-policy.md mentions it.

14. Temporary repositories read no default ignore or attributes file

GIT_CONFIG_GLOBAL=/dev/null empties the global config, but git still reads $XDG_CONFIG_HOME/git/ignore (else ~/.config/git/ignore), the matching attributes file, and the system gitattributes, with no setting naming them. With *.rs in a developer's ~/.config/git/ignore, four policy tests failed at git add; a filter= there would rewrite what they stage. Temporary repositories now get an XDG_CONFIG_HOME that cannot exist, plus GIT_ATTR_NOSYSTEM. The checkout's own check keeps the developer's files. New test temporary_repositories_read_no_default_ignore_or_attributes runs plain git under a fake HOME as a control. A doc comment that had drifted onto the wrong test is moved back.

15. Temporary repositories take no template or hash from the environment

GIT_TEMPLATE_DIR copied its info/exclude and hooks into every test's git init, and GIT_DEFAULT_HASH=sha256 made repositories that refuse the SHA-1 ids the submodule tests stage. Temporary repositories now get an empty template directory and the default hash. New test temporary_repositories_are_made_without_template_or_hash_choice.

16. Temporary repositories ignore attribute-source, pathspec and identity variables

Each of these, set in the environment, failed tests (Linux, git 2.56):

Variable Failed
GIT_ATTR_SOURCE=HEAD 4 tests: every git add / check-attr in a fresh repository says bad --attr-source or GIT_ATTR_SOURCE (it has no HEAD)
GIT_LITERAL_PATHSPECS, GIT_NOGLOB_PATHSPECS, GIT_ICASE_PATHSPECS check-ignore refuses to run (pathspec magic not supported), so tempdir() misreads whether a TMPDIR inside the checkout is ignored; the control in section 14 failed
empty GIT_AUTHOR_NAME, unparseable GIT_AUTHOR_DATE / GIT_COMMITTER_DATE every test that commits: these win over -c user.*, and git commit exports GIT_AUTHOR_* to its hooks
  • Test git drops the four pathspec variables; temporary repositories also drop GIT_ATTR_SOURCE. The checkout's full check passes no pathspecs and keeps its attribute source.
  • The test helper commits with a fixed author, committer and date (@0 +0000) set as variables instead of user.* config.
  • New test temporary_repositories_ignore_attr_source_identity_and_pathspec_env: each variable makes git fail when handed it, and the test commands drop or pin it.
  • Under each of the variables above, and with TMPDIR inside the checkout plus GIT_LITERAL_PATHSPECS: 22/22 pass (4–5 failed before).

17. A temporary directory outside any repository is walked, not taken for the checkout

When tempdir() falls back to the test binary's directory under target/, a temporary directory that is not itself a repository sits inside the checkout. Git found the checkout above it, where the directory is ignored, so git ls-files there succeeded and listed nothing, and the full check passed a directory it never read.

  • Temporary repositories' git gets GIT_CEILING_DIRECTORIES set to the parent of root (git stops before entering a ceiling), so it looks no further up than root. The checkout keeps git's own discovery.
  • New test directories_outside_any_repository_are_walked: inside an outer repository that ignores it, a plain directory holding an executable is refused by the walk (build output under target/ is skipped), and plain git without the ceiling is shown listing nothing.

18. Hex or base64 wrapped onto many lines is one run

The run check split runs at every non-payload byte, newlines included. base64 wraps at 76 columns, PEM and openssl base64 at 64, xxd -p at 60, so anything encoded by them passed as many short runs:

head -c 300000 game.bin | base64 > strings.txt   # 76-column lines, under 512 KiB
git add strings.txt && cargo xtask policy --staged # asset policy: ... files ok
  • A single line break (LF or CRLF) between two payload characters now continues the run; the break is not counted. A blank line or indentation still ends it, so prose and code are unaffected (cargo xtask policy: 152 files ok).
  • New tests rejects_encoded_data_wrapped_across_lines (76/LF, 64/CRLF, 60-column hex) and line_breaks_join_only_payload_lines; both fail without the fix. docs/asset-policy.md says so.

19. Temporary repositories ignore a hook's quarantine and trust their own owner

Two more variables broke the tests' temporary repositories (Linux, git 2.56):

Set in the environment Failed
GIT_QUARANTINE_PATH (a pre-receive hook runs with it, beside the object directories section 6 already drops) 14 tests: every git init says ref updates forbidden inside quarantine environment
a TMPDIR owned by another user (git's GIT_TEST_ASSUME_DIFFERENT_OWNER=1 stands in) 13 tests: git refuses each repository as dubious, and since they read no global config (section 10), no safe.directory could let them in
  • Test git in temporary repositories drops GIT_QUARANTINE_PATH and passes -c safe.directory=*, command-line config that git honours for that setting. The checkout keeps both checks.
  • New test temporary_repositories_ignore_quarantine_and_ownership: plain git is refused under each, test git drops the quarantine and stages and lists a file in a repository it is told another user owns. It fails without the fix (and 15 tests fail under both variables together; 26/26 pass with it).
  • temporary_repositories_read_only_their_own_config allows that one command-line entry.

20. The staged check reads past git replace refs

Replace refs are local and never pushed, but git follows them by default: a staged blob replaced by harmless text passed cat-file, and a HEAD replaced by a commit whose tree already holds the staged file dropped it from diff --cached. Every policy git command now runs with --no-replace-objects; the test staged_check_ignores_replace_refs covers both cases.

21. base64url counts as an encoded run

The run check took only the standard base64 alphabet (+, /) as payload. base64url (RFC 4648 §5: - and _), which JWTs, basenc --base64url and most web tooling write, broke at every - and _, about one character in 32, so a whole file of it passed as short runs:

head -c 300000 game.bin | basenc --base64url > strings.txt
git add strings.txt && cargo xtask policy --staged   # asset policy: ... files ok
  • Each alphabet is measured on its own and the longer run counts; they are not mixed, so a+b-c is still two short runs.
  • New test rejects_base64url_data (a string literal and 76-column wrapped lines); it fails without the fix. docs/asset-policy.md says so. cargo xtask policy: 152 files ok, so nothing in the tree is affected.

22. victory-core's policy tests keep their temporary directories outside the checkout

Section 12 kept xtask's temporary repositories out of a TMPDIR inside the checkout; victory-core's ensure_outside_repo tests had the same problem the other way round. They need a directory outside every source tree, and took it from tempfile::tempdir(), which follows TMPDIR:

mkdir scratch-tmp && TMPDIR=$PWD/scratch-tmp cargo test -p victory-core policy
# 2 failed: accepts_unrelated_directories, resolves_dotdot_after_a_missing_directory
#   (InsideRepo { path: ".../scratch-tmp/.tmp3CpIBz/does/not/exist", ... })

and rejects_other_clones_via_marker passed whether or not the marker mattered, since its directory was refused already.

  • The tests take their directory from outside_tempdir(): TMPDIR if ensure_outside_repo accepts it, otherwise the nearest writable ancestor of the checkout that it accepts (removed on drop), otherwise a panic saying to set TMPDIR outside the source tree.
  • rejects_other_clones_via_marker now checks that the directory is accepted before the marker is written, and refused as InsideRepo after.
  • With TMPDIR inside the checkout: 5/5 pass (2 failed before), nothing left behind.

23. Numeric arrays and \xHH strings count as embedded data

xxd -i and bin2c write a file as 0x4d, 0x5a, ... and a byte string as "\x4d\x5a...": every token is a few characters, so neither was ever a long hex/base64 run, and an executable pasted into a const [u8; N] passed under the size limit. Lists of numeric literals joined by commas, and back-to-back \xHH escapes, are now capped at 512 elements; the largest table in the tree (XMA's) has 272, and a bracket or comment between rows ends a list.

24. Trace output pointed at stdout is not read as git's output

The check parses git's stdout. With GIT_TRACE=/dev/stdout (or GIT_TRACE_SETUP, GIT_TRACE2_EVENT, any trace variable pointed at stdout) trace lines lead the first NUL-separated field. In the full check that is the first file listed: its name no longer exists, so it is never read and passes whatever it holds. --staged stops at a record it cannot parse. Before the fix:

GIT_TRACE=/dev/stdout cargo test -p xtask
# 3 failed, e.g. nested_repositories_are_violations:
#   left: ["23:54:41.355115 git.c:506  trace: built-in: git ls-files -z ...\ninner/"]
# (GIT_TRACE_SETUP / GIT_TRACE2_EVENT=/dev/stdout: 3 failed as well)
  • Every git the check runs drops GIT_TRACE* and GIT_REDIRECT_* (Git for Windows' GIT_REDIRECT_STDOUT sends output to a file, and the check would see an empty repository), and sets GIT_TRACE2, GIT_TRACE2_EVENT and GIT_TRACE2_PERF to 0, since trace2 can also be turned on from global or system config, which those variables override. This applies to the hook too, not only to tests.
  • New test trace_output_is_not_read_as_git_output: git with the trace variables at /dev/stdout prints more than the names; after unredirect_output it prints exactly a.bin\0; and the full and staged checks both refuse the staged a.bin.
  • The two tests that run plain git as a control drop the same variables.
  • cargo test -p xtask: 31/31 pass (34/34 with sections 25 and 26), and also with each of GIT_TRACE, GIT_TRACE_SETUP, GIT_TRACE_PERFORMANCE, GIT_TRACE2, GIT_TRACE2_EVENT set to /dev/stdout.

25. A tracked file missing from disk is read from the index

Deleted but not git rmed, or left out of a sparse checkout, a file is still in the index and a plain git commit keeps it. The full check skipped it unread, so a binary committed with --no-verify and then deleted from disk passed cargo test. It now reads the indexed blob by object id. New test tracked_files_missing_from_disk_are_read_from_the_index.

26. ascii85, Z85 and uuencoded data count as encoded runs

Their alphabets put punctuation every few characters, so their output never made a long hex/base64 run (sections 18 and 21), and a file of it passed under the size limit:

python3 -c "import base64,os; open('strings.txt','wb').write(base64.a85encode(os.urandom(3000), wrapcol=76))"
head -c 3000 game.bin | basenc --z85 -w0 > z.txt
git add strings.txt z.txt && cargo xtask policy --staged   # asset policy: ... files ok
  • A run of printable ASCII without whitespace (! to ~) over 512 characters is now refused: 3750-character run without whitespace (ascii85, Z85 or uuencoded data?).
  • A single line break continues the run only after a line of at least 40 characters, as encoders wrap (60 to 80 columns), so a list of short entries without spaces, such as .gitignore patterns, does not join into one run.
  • The longest such run in the tree is 89 characters; cargo xtask policy: 152 files ok.
  • New tests rejects_ascii85_z85_and_uuencoded_data (each alphabet unwrapped, wrapped with LF and with CRLF; the hex/base64 check alone sees runs under 32) and printable_runs_join_only_long_lines (whitespace, blank lines, short lines, a 100-line .gitignore and a long URL pass). docs/asset-policy.md says so.

27. A tracked file is read as the index holds it as well as on disk

The full check read only the working copy of a tracked file. A binary committed with --no-verify and then overwritten on disk with text stays in the repository and in every later commit, yet cargo xtask policy and cargo test passed; git update-index --assume-unchanged or --skip-worktree hide it from git status as well.

printf 'MZ\220\0binary' > game.rs && git add game.rs && git commit --no-verify -m x
echo 'fn game() {}' > game.rs && git update-index --assume-unchanged game.rs
cargo xtask policy                                         # asset policy: ... files ok
  • Every tracked file's index blob is read with one git cat-file --batch (not a process per file) and checked as well when it differs from the disk, reported as game.rs (as indexed): .... An object git does not have is a violation.
  • New test tracked_files_are_read_as_indexed_as_well: edited on disk, then each of --assume-unchanged and --skip-worktree, fails; once the text is staged both checks pass. docs/asset-policy.md says so.
  • cargo test -p xtask: 35/35 pass, also with TMPDIR inside the checkout; clippy -D warnings clean; cargo xtask policy: 152 files ok.

28. Binary without NUL bytes, and base65536-style text, are refused

check took a file for binary only if it held a NUL. Byte stuffing such as COBS removes every NUL, and bytes over 0x7F break every run check, so the result passed as text. base32768 and base65536 write 15–16 bits per CJK (or similar) letter with no whitespace, which no ASCII run saw at all:

python3 -c "from cobs import cobs; import sys; sys.stdout.buffer.write(cobs.encode(open('game.bin','rb').read(400000)))" > strings.txt
git add strings.txt && cargo xtask policy --staged   # asset policy: ... files ok
  • Content must be UTF-8 without control characters other than tab, line breaks and form feed (not UTF-8 text (binary content?), control character U+0001 ...). Every file in the tree already is.
  • The printable run from section 26 now counts any character that is neither whitespace nor a control, in characters, so base32768/base65536 runs are refused; prose in any script, with its spaces and line breaks, passes.
  • New tests rejects_binary_without_nul_bytes (COBS of pseudo-random bytes, and a 7-bit variant; ordinary non-ASCII prose passes) and rejects_base65536_like_data (a string literal and 64-column wrapped lines). Both fail without the fix. docs/asset-policy.md says so.
  • cargo test -p xtask: 37/37, also with TMPDIR inside the checkout; clippy -D warnings clean; cargo xtask policy: 152 files ok.

29. Every stage of a conflicted path is read

The full check mapped each indexed path to one blob, so a conflicted path kept only its last stage: game data in stage 1 or 2 passed unread, though git checkout --ours puts it in the next commit.

  • Each index entry of a path is kept, and every stage's blob is checked (<path> (as indexed): ...).
  • New test every_stage_of_a_conflicted_path_is_read.

30. A file over the size limit is not read into memory whole

Every file and blob was read whole before check refused it as over 512 KiB. A game dump or disc image of several gigabytes left untracked in the checkout (not ignored), or staged by mistake, was loaded into memory first and could exhaust it:

truncate -s 8G game.rs && cargo xtask policy    # allocates 8 GiB before refusing it
  • On disk, in git cat-file --batch and in git cat-file blob (now streamed rather than output()), only the first 512 KiB is kept; the rest is copied to a sink to count the size. The violation reports the whole size, and the start is still checked, so a too-big PE still says looks like a PE executable.
  • A file over the limit is never taken for the one exception, whose content is within it.
  • New test files_over_the_limit_are_not_read_whole: an 8 MiB sparse file untracked, staged, and indexed under a small working copy is read to the limit with its full size and refused; a file of exactly 512 KiB is read whole and passes. docs/asset-policy.md says so.
  • cargo test -p xtask: 39/39, also with TMPDIR inside the checkout; cargo test -p victory-core passes; clippy -D warnings clean; cargo xtask policy: 152 files ok.

31. Escape strings split into many literals count as one run

Section 23 capped back-to-back \xHH escapes at 512, but any string boundary ended the count. Split every 64 escapes, a byte string of any length passed:

const DATA: &[u8] = b"\x4d\x5a\x90...(64 escapes)\
    \x00\x03...(64 more)\
    ...";                                   // also "..." "..." (C/HLSL), concat!("...", "..."), [b"...", b"..."]
  • Escapes now join across a boundary made only of quotes, commas, whitespace, b" and \-newline continuations; \u{H..} escapes (1 to 6 digits, what escape_default and {:?} write) count as well. Whitespace or a comma alone inside one string, or any other text between literals, still ends a run.
  • New tests rejects_escape_strings_split_across_literals (five ways of splitting, plus \u{..}) and escape_runs_join_only_across_string_boundaries; both fail without the fix. docs/asset-policy.md says so.
  • cargo test -p xtask: 41/41, also with TMPDIR inside the checkout; cargo test -p victory-core policy passes; clippy -D warnings clean; cargo xtask policy: 152 files ok.

32. The tests pass under any TMPDIR name

Under a TMPDIR holding ' or :, three tests failed on the test, not on the check:

TMPDIR="/tmp/it's a:dir" cargo test -p xtask
# every_way_of_committing_runs_a_tracked_hook, lfs_tracked_files_are_violations: the hook
#   and LFS clean filter they write ('…/it's a:dir/…') are shell syntax errors, so git fails
# directories_outside_any_repository_are_walked: "a repository above was found"
  • Paths embedded in the scripts the tests write are now quoted for sh (sh_quote).
  • Git splits GIT_CEILING_DIRECTORIES at : with no escape, so the ceiling git_command puts on a temporary directory did not hold and git found the repository around it. tempdir now skips a candidate whose path holds :, falling back to the directory beside the test binary as it already does for a TMPDIR inside the checkout.
  • New test temporary_directories_survive_any_tmpdir_name: shows the split ceiling finding the outer repository, that the fallback is taken, and that sh_quote round-trips ', $, backticks, \ and " through sh.
  • cargo test -p xtask: 45/45 with the default TMPDIR, with one inside the checkout, and with it's a:dir, co:lon and q'x; clippy -D warnings and cargo fmt --check clean.

33. Merges and git am run the policy check too

git merge runs pre-merge-commit, not pre-commit, before it records a merge made without conflicts, and git am runs pre-applypatch. So a branch committed with --no-verify, or a mailed patch, brought its files in unchecked:

git checkout -b side && printf 'MZ\220\0' > data.rs && git add data.rs && git commit --no-verify -m data
git checkout main && git merge side            # no hook ran; data.rs is in main
  • New .githooks/pre-merge-commit and .githooks/pre-applypatch, tracked 100755 (so hooks_are_tracked_executable covers them), both exec cargo xtask policy --staged.
  • New test every_way_of_committing_runs_a_tracked_hook: with stand-in hooks under core.hooksPath, a commit, a merge and an am each run at least one tracked hook, and the staged check refuses what the merge brings in. install-hooks and docs/asset-policy.md say so.

34. Hex dumps (xxd, hexdump -C, od) count as embedded data

A dump writes a file as short hex or octal groups separated by spaces, with an offset in front and sometimes the printable bytes behind: no long hex run, whitespace every few characters, no commas. A dump of an executable in a .txt or .md passed every check under the size limit:

head -c 40000 game.bin | xxd > notes.txt && git add notes.txt && cargo xtask policy --staged   # ... files ok
  • A line counts when at least 4 of its words, and three in four, are hex values (up to 16 digits, optional 0x and :); consecutive counting lines add up against the same 512-value limit as numeric arrays. Prose fond of cafe/dead/beef does not count.
  • New tests rejects_hex_dumps (xxd, hexdump -C and od layouts) and hex_dumps_are_only_lines_of_hex_values. docs/asset-policy.md says so.

35. Octal and \uHHHH / \UHHHHHHHH escapes count as byte escapes

Sections 23 and 31 counted \xHH and \u{..} escapes only. C, HLSL, Python and shell printf write bytes as octal (\115\132\220), and JSON, JavaScript, Java and Python as \uHHHH (json.dumps escapes every non-ASCII character so) or \UHHHHHHHH. Split into strings short enough for the printable-run check, a file of them passed:

static const char data[] =
    "\115\132\220\0\3\0..."     /* 40 escapes a line, any number of lines */
    "...";
["ÍÚĐ...", "...", ...]
  • escape_len also takes \ + 1 to 3 octal digits, \u + exactly 4 hex digits and \U + exactly 8; they join across string boundaries as in section 31, and mix with the other kinds. A lone "\0" terminator or the odd café stays a run of one.
  • New test rejects_octal_and_fixed_width_unicode_escapes (C octal, Python \NNN byte strings, a JSON array of \uHHHH strings, Python \U strings; each string is shown to be under the printable-run limit); it fails without the fix. docs/asset-policy.md lists the new escapes.
  • cargo test -p xtask: 46/46, also with TMPDIR inside the checkout; clippy -D warnings and cargo fmt clean; cargo xtask policy: 154 files ok.

36. cargo xtask checks the worktree it ran in, not the one it was built in

Worktrees that share a CARGO_TARGET_DIR build xtask packages with the same name and version, and cargo treats one worktree's binary as up to date for another. The CARGO_MANIFEST_DIR compiled into the binary then named the other worktree, so this worktree's pre-commit hook checked the other worktree's files. workspace_root now takes the CARGO_MANIFEST_DIR that cargo sets at run time, as long as it names an xtask package directory, and falls back to the compiled-in value otherwise. The new test is workspace_root_is_where_cargo_ran.

37. The hooks find cargo off the PATH that GUI git clients give them

Git clients started from a desktop launcher (IDEs, GUI git tools) often run hooks with a PATH that does not include ~/.cargo/bin, where rustup installs cargo. Every hook then failed with only cargo: not found and refused the commit with no hint why.

  • pre-commit looks for cargo on the PATH first. If it is not there, it tries ${CARGO_HOME:-$HOME/.cargo}/bin/cargo (and cargo.exe, for Git for Windows). If cargo is in none of those places, the hook refuses the commit with asset policy: cargo not found on PATH or in …, and says to add cargo to the PATH git runs hooks with or to set CARGO_HOME.
  • pre-merge-commit and pre-applypatch now exec pre-commit by path instead of repeating the lookup. Git runs hooks by path from the top of the worktree.
  • New test hooks_find_cargo_off_the_path runs every tracked hook with an empty environment and an empty PATH, against a stub cargo that logs its arguments. It covers three cases: the stub found under $HOME/.cargo/bin, found under CARGO_HOME, and cargo nowhere (the hook must fail and print cargo not found). The test fails against the previous hooks.
  • cargo test -p xtask -p victory-core: all pass (xtask 48/48), also with TMPDIR inside the checkout. cargo clippy -p xtask --all-targets -- -D warnings and cargo fmt --check are clean. cargo xtask policy reports 154 files ok. This commit was itself made through the new pre-commit.

38. A TMPDIR whose path is not UTF-8 is passed over, not panicked on

Several tests build hook and filter scripts, and some git arguments, from the temporary directory's path as text. Under a TMPDIR that is not UTF-8 (for example TMPDIR=$'/tmp/bad\xff'), five tests panicked in to_str: lfs_tracked_files_are_violations, every_way_of_committing_runs_a_tracked_hook, hooks_find_cargo_off_the_path, symlinks_are_checked_as_git_stores_them and temporary_directories_survive_any_tmpdir_name.

  • tempdir_in_first now skips a candidate that is not UTF-8, as it already skips one holding :, and falls back to the directory beside the test binary. The panic message names both conditions.
  • New test temporary_directories_skip_a_tmpdir_that_is_not_utf8 offers a non-UTF-8 directory and then a plain one, and checks that the plain one is chosen and that nothing is left in the other. It returns early on filesystems that refuse such names (APFS).
  • TMPDIR=$'…/bad\xff' cargo test -p xtask: 47 passed and 5 failed before, 53/53 after. cargo clippy -p xtask --all-targets -- -D warnings and cargo fmt --check are clean, and cargo xtask policy reports 154 files ok.

39. A build directory inside the checkout no longer fails the full check

.gitignore ignores /target/ only. With CARGO_TARGET_DIR inside the checkout under another name, for example one kept beside a worktree, every object file built there was listed as untracked. CARGO_TARGET_DIR=$PWD/build-out cargo test -p xtask failed repository_passes_policy with 947 violations (build-out/debug/incremental/…/*.o: binary content), and cargo xtask policy failed the same way. With TMPDIR also in the checkout, tempdir() had nowhere unseen left, because its fallback beside the test binary was visible too.

  • New build_dir_in(root, exe) finds the Cargo target directory the running program was built in: the outermost ancestor of the executable, below the checkout and never the checkout itself, that holds a CACHEDIR.TAG with Cargo's signature.
  • The full check skips only the untracked files of that one directory, in a repository and in the walk outside one. Files tracked there are still read. Another build directory, or a sibling whose name only starts the same (build-outer/), is still read. The staged check is unchanged, so what a commit holds is still checked in full.
  • unseen_by_full_check treats that directory as unseen, so the fallback beside the test binary works again.
  • New tests: build_directories_are_found_by_their_cache_tag covers inner and outer tags, a tag without the signature, a tag at the root, and a program built outside the checkout. the_running_build_directory_is_passed_over covers git and walk modes, a tracked file in the build directory, another build directory, and the prefix sibling.
  • CARGO_TARGET_DIR=$PWD/build-out cargo test -p xtask: 1 failure before, 56/56 after, and also 56/56 with TMPDIR inside the checkout. With the target directory in /tmp it is also 56/56. cargo clippy -p xtask --all-targets -- -D warnings and cargo fmt --check are clean, and cargo xtask policy reports 154 files ok.

Testing (Linux)

  • cargo test -p xtask -p victory-core: all pass, including every new test; also with GIT_INDEX_FILE and GIT_DIR pointing elsewhere, and with a hostile GIT_CONFIG_GLOBAL, with TMPDIR inside the checkout, with XDG_CONFIG_HOME/git/ignore holding *.rs, and with GIT_QUARANTINE_PATH and GIT_TEST_ASSUME_DIFFERENT_OWNER set, and with the trace variables pointed at stdout.
  • cargo clippy -p xtask -p victory-core --all-targets -- -D warnings: clean.
  • cargo clippy -p xtask --all-targets --target x86_64-pc-windows-msvc -- -D warnings: clean before section 9; with blake3 added it needs MSVC's lib.exe for blake3's C build, which this Linux machine lacks, so Windows CI covers it.
  • rustfmt --check on the touched files: clean.
  • cargo xtask policy: asset policy: 152 files ok.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6572718669 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/246). Originally posted by [SkippySteve](https://github.com/SkippySteve) on 2026-11-24T01:45:58Z. --- Fixes to the asset-policy and pre-commit tooling, plus an `.editorconfig`, one commit each. This PR now also carries #252, #253 and #291, which are closed in its favour. ## 1. The staged check also reads files whose type changed The pre-commit hook (`cargo xtask policy --staged`) lists staged paths with `git diff --cached --name-only --diff-filter=ACMR`. A path whose type changed, such as a committed symlink replaced by a regular file, is staged as `T`, so it is not listed and none of its content is checked. A binary committed under an allowed name such as `data.rs` passes the hook. ```sh ln -s elsewhere.rs data.rs && git add data.rs && git commit -m link rm data.rs && printf 'MZ\0\0binary' > data.rs && git add data.rs git diff --cached --name-status # T data.rs git diff --cached --name-only --diff-filter=ACMR # (nothing) ``` The fix adds `T` to the filter. The new test `staged_check_reads_type_changes` sets up that case in a temporary repository and checks that `list_files` returns the path and that `run(.., staged = true)` fails. It is `#[cfg(unix)]` because creating symlinks on Windows needs extra privileges. `tempfile`, already a workspace dependency, is added as a dev-dependency of xtask. ## 2. `ensure_outside_repo` resolves `..` below a directory not yet created (was #252) `ensure_outside_repo` resolves a destination that does not exist yet by walking up to its longest existing prefix. The walk took each component with `Path::file_name`, which is `None` for a path ending in `..`, so a destination such as `<tmp>/missing/../cache` failed with `cannot resolve ...: No such file or directory` instead of being checked. A cache or data directory configured that way was refused even though it is outside the repository. The fix takes the last component with `components().next_back()` and accepts both normal names and `..`; the tail is already normalized lexically afterwards. Root and prefix components still end the walk with the same error. The new test `resolves_dotdot_after_a_missing_directory` checks that `<tmp>/missing/../cache` is accepted and that `<repo>/not-yet-created/../out` is reported as `InsideRepo` (it was an `Io` error before). ## 3. Track `.githooks/pre-commit` as executable (was #253) `.githooks/pre-commit` was tracked as `100644`. Git outside Windows skips a non-executable hook and only prints a hint, so after `cargo xtask install-hooks` a commit on Linux or macOS never ran the policy check: ``` hint: The '.githooks/pre-commit' hook was ignored because it's not set as executable. ``` - Mark `.githooks/pre-commit` as `100755` (mode change only). - Add `hooks_are_tracked_executable` to xtask: it reads `git ls-files --stage -- .githooks` and fails if a tracked hook is not `100755` (it skips itself outside a git checkout). Git for Windows runs hooks regardless of the bit, so nothing changes there. ## 4. An `.editorconfig` that says what the tree already holds (was #291) Adds a root `.editorconfig` that states what the tree already holds: UTF-8, LF (as `.gitattributes` says), a final newline, no trailing whitespace, spaces; 4-space indent for `.rs`/`.toml`, 2 for `.yml`/`.yaml`/`.json`; CRLF for `.cmd`/`.ps1`, which `.gitattributes` already checks out that way. Rust layout stays rustfmt's. It changes no existing file. ## 5. Names that are not UTF-8, and submodules, no longer pass unread The check decoded each path with `from_utf8_lossy` and then read the file back by that decoded name (`git show :<name>` when staged, `fs::read` otherwise). For a name that is not UTF-8 the decoded name does not exist, the read failed, and the loop `continue`d, so the file was never checked, whatever it held. A submodule (gitlink) failed the read the same way and was skipped too: ```sh printf 'MZ\0' > "$(printf 'a\xff.bin')" git update-index --add --cacheinfo 160000,<any id>,vendor git add -A && cargo xtask policy --staged # asset policy: ... files ok ``` - Staged content is read by object id from `git diff --cached --raw -z --no-abbrev --no-renames --diff-filter=ACMT`, so no file name can make the read fail. Renames are checked as the additions they are. - Paths on disk are read by their exact bytes on Unix. - A name that is not UTF-8 is a violation in itself (it can be neither allowlisted nor reported reliably). - A submodule is a violation whether staged or only tracked (found through `git ls-files --stage`, since it may not be checked out). - A path the check cannot read now fails instead of passing; a tracked file deleted from the working tree is still skipped. New hermetic tests in temporary repositories: `staged_check_reads_renames`, `non_utf8_names_are_violations` (staged straight into the index, as macOS refuses such names on disk), `non_utf8_names_on_disk_are_read` (Linux only), `submodules_are_violations`. `docs/asset-policy.md` mentions the two new rules. ## 6. The tests no longer follow GIT_INDEX_FILE out of their temporary repositories The new tests run git in temporary repositories, but git lets `GIT_DIR`, `GIT_INDEX_FILE` and similar variables choose the repository over the working directory. A pre-commit hook runs with `GIT_INDEX_FILE` set, and `git commit -a` sets it to an absolute path, so tests run from a hook (or with `GIT_DIR` exported) all wrote into that one outside index: ```sh GIT_INDEX_FILE=/tmp/x/leak-index cargo test -p xtask # 5 failed: staged_check_reads_type_changes, staged_check_reads_renames, # submodules_are_violations, non_utf8_names_are_violations, hooks_are_tracked_executable # and /tmp/x/leak-index now exists ``` - All of xtask's git calls go through `git_command(root)`. Under `cfg(test)` it drops the variables `git rev-parse --local-env-vars` lists. - The hook itself keeps them, since `git commit -a` and `git commit <path>` stage into a temporary index that only `GIT_INDEX_FILE` names. - New test `test_git_ignores_the_repository_environment` checks that each listed variable is removed and that the list matches the one the installed git prints. ## 7. Submodules that git is told to ignore are still seen `git diff` honours `diff.ignoreSubmodules` and a submodule's `ignore = all` in `.gitmodules`, which it reads from the working tree even when that file is untracked. Either one left a staged submodule out of `git diff --cached --raw`, so the check from section 5 never saw it: ```sh git update-index --add --cacheinfo 160000,<any id>,vendor printf '[submodule "v"]\n\tpath = vendor\n\turl = x\n\tignore = all\n' > .gitmodules cargo xtask policy --staged # asset policy: 0 files ok ``` - The staged listing passes `--ignore-submodules=none`. - New test `staged_submodules_are_seen_whatever_git_ignores` sets both the config and an untracked `.gitmodules`, checks that plain `git diff --cached` hides the submodule, and that the policy lists and refuses it. It fails without the fix. ## 8. Symlinks are checked as git stores them, not followed Git stores a symlink as its target path, and the staged check reads exactly that. The full check (`cargo xtask policy`, and the `repository_passes_policy` test) read each path with `fs::read`, which follows the link, so the two disagreed: ```sh printf 'MZ\0' > /tmp/out/game.bin; ln -s /tmp/out/game.bin binary.rs # hook: ok; full check: "looks like a PE executable" ln -s "$(printf 'a%.0s' $(seq 600))/x" dangling.rs # hook: refused; full check: skipped as deleted mkfifo /tmp/out/fifo; ln -s /tmp/out/fifo fifo.rs # full check: blocks forever ``` - Paths on disk are inspected with `symlink_metadata`: a symlink is checked as its target path (bytes on Unix, `/`-separated UTF-8 on Windows, as Git for Windows stores it); a FIFO or device is a violation; only regular files are read. - New test `symlinks_are_checked_as_git_stores_them` covers all three cases and that the staged and full checks agree. Without the fix it fails on the outside link, and hangs on the FIFO link. - `docs/asset-policy.md` says how symlinks are checked. ## 9. The one exception covers its content, not its name `EXCEPTIONS` skipped `crates/victory-formats/src/bcpack-tables.bin` by path before anything was read, so whatever was later committed under that name (an executable, an archive, a file of any size) passed both the hook and the full check: ```sh printf 'MZ\0' > crates/victory-formats/src/bcpack-tables.bin git add -A && cargo xtask policy --staged # asset policy: ... files ok ``` - Each entry now carries the BLAKE3 of the content it was granted for (`f0f032aa…73c0` for the current tables, unchanged from `main`). Any other content at that path is a violation that names both hashes. - `blake3`, already a workspace dependency, is added to xtask. - New tests `exceptions_are_pinned_to_their_content` (pure) and `exempted_paths_refuse_other_content` (temporary repository: other content is refused by the full and staged checks, the real tables pass both). - `docs/asset-policy.md` says exceptions are pinned. ## 10. The tests' temporary repositories read no global or system git config The tests in temporary repositories ran git with the developer's own configuration. A global `core.excludesFile` that matches what a test stages makes `git add` refuse it, and a global `core.hooksPath` runs the developer's hooks inside the test repositories: ```sh printf '*.rs\n' > /tmp/x/ignore printf '[core]\n\texcludesFile = /tmp/x/ignore\n' > /tmp/x/gitconfig GIT_CONFIG_GLOBAL=/tmp/x/gitconfig cargo test -p xtask # 4 failed: staged_check_reads_type_changes, staged_check_reads_renames, # symlinks_are_checked_as_git_stores_them, non_utf8_names_on_disk_are_read ``` - Under `cfg(test)`, `git_command` sets `GIT_CONFIG_GLOBAL=/dev/null` and `GIT_CONFIG_NOSYSTEM=1` for any root other than the checkout (Git for Windows opens `/dev/null` as `NUL`). - The checkout keeps the developer's configuration, so `repository_passes_policy` still honours a global excludes file (for `.DS_Store` and the like), as `cargo xtask policy` does. - New test `temporary_repositories_read_only_their_own_config` checks that `git config --list --show-scope` in a temporary repository shows only `local` entries, and that the checkout's command is left alone. ## 11. Git LFS pointers are refused A Git LFS pointer is a few lines of text under an allowed name, so it passed both checks, while the file it stands for went to LFS storage, which nothing checks. With `filter=lfs` in `.gitattributes`, the index holds only the pointer, so the staged check never saw the real content, and a checkout without git-lfs sees only the pointer too: ```sh git lfs track '*.txt' && cp game-strings.bin strings.txt git add .gitattributes strings.txt && cargo xtask policy --staged # asset policy: ... files ok ``` - `check` refuses content that begins with an LFS pointer's version line (`https://git-lfs.github.com/spec/` or the pre-1.0 `https://hawser.github.com/spec/`). A mention of the URL elsewhere in a file is not affected. - New tests `rejects_lfs_pointers` (pure) and `lfs_tracked_files_are_violations` (temporary repository with a stand-in `filter.lfs.clean`, so git-lfs need not be installed; it checks that the index holds the pointer and that the staged and full checks refuse it). Both fail without the fix. - `docs/asset-policy.md` says LFS pointers are refused. ## 12. The tests' temporary repositories stay out of a TMPDIR inside the checkout With `TMPDIR` inside the checkout, each test's temporary repository is an untracked directory there, and `repository_passes_policy`, running on another thread, sometimes lists it and the files the test stages: ```sh mkdir scratch-tmp && TMPDIR=$PWD/scratch-tmp RUST_TEST_THREADS=8 target/debug/deps/xtask-<hash> # in a loop # 2 of 100 runs fail: # POLICY: scratch-tmp/.tmpVAcWIF/pointer: a Git LFS pointer: ... ``` - The tests take their temporary directories from one helper, `tempdir()`. It uses `TMPDIR` when the checkout's full check cannot see it (it is outside, or `git check-ignore` says it is ignored), otherwise the test binary's directory under `target/`, which is ignored. If neither is, the test fails with a message saying to set `TMPDIR` outside the checkout, so it does not flake. - With `TMPDIR` inside the checkout: 0 failures in 300 runs, and nothing left behind. ## 13. An untracked repository nested in the checkout is named as such `git ls-files --others` lists an untracked repository inside the checkout as its directory, with a trailing `/`. The full check already refused it, but said "a directory tracked as a file (a submodule?)", which is wrong on both counts. It now says "a git repository nested in this one: its files bypass this check". New test `nested_repositories_are_violations`; `docs/asset-policy.md` mentions it. ## 14. Temporary repositories read no default ignore or attributes file `GIT_CONFIG_GLOBAL=/dev/null` empties the global config, but git still reads `$XDG_CONFIG_HOME/git/ignore` (else `~/.config/git/ignore`), the matching `attributes` file, and the system gitattributes, with no setting naming them. With `*.rs` in a developer's `~/.config/git/ignore`, four policy tests failed at `git add`; a `filter=` there would rewrite what they stage. Temporary repositories now get an `XDG_CONFIG_HOME` that cannot exist, plus `GIT_ATTR_NOSYSTEM`. The checkout's own check keeps the developer's files. New test `temporary_repositories_read_no_default_ignore_or_attributes` runs plain git under a fake HOME as a control. A doc comment that had drifted onto the wrong test is moved back. ## 15. Temporary repositories take no template or hash from the environment `GIT_TEMPLATE_DIR` copied its `info/exclude` and hooks into every test's `git init`, and `GIT_DEFAULT_HASH=sha256` made repositories that refuse the SHA-1 ids the submodule tests stage. Temporary repositories now get an empty template directory and the default hash. New test `temporary_repositories_are_made_without_template_or_hash_choice`. ## 16. Temporary repositories ignore attribute-source, pathspec and identity variables Each of these, set in the environment, failed tests (Linux, git 2.56): | Variable | Failed | |---|---| | `GIT_ATTR_SOURCE=HEAD` | 4 tests: every `git add` / `check-attr` in a fresh repository says `bad --attr-source or GIT_ATTR_SOURCE` (it has no HEAD) | | `GIT_LITERAL_PATHSPECS`, `GIT_NOGLOB_PATHSPECS`, `GIT_ICASE_PATHSPECS` | `check-ignore` refuses to run (`pathspec magic not supported`), so `tempdir()` misreads whether a TMPDIR inside the checkout is ignored; the control in section 14 failed | | empty `GIT_AUTHOR_NAME`, unparseable `GIT_AUTHOR_DATE` / `GIT_COMMITTER_DATE` | every test that commits: these win over `-c user.*`, and `git commit` exports `GIT_AUTHOR_*` to its hooks | - Test git drops the four pathspec variables; temporary repositories also drop `GIT_ATTR_SOURCE`. The checkout's full check passes no pathspecs and keeps its attribute source. - The test helper commits with a fixed author, committer and date (`@0 +0000`) set as variables instead of `user.*` config. - New test `temporary_repositories_ignore_attr_source_identity_and_pathspec_env`: each variable makes git fail when handed it, and the test commands drop or pin it. - Under each of the variables above, and with `TMPDIR` inside the checkout plus `GIT_LITERAL_PATHSPECS`: 22/22 pass (4–5 failed before). ## 17. A temporary directory outside any repository is walked, not taken for the checkout When `tempdir()` falls back to the test binary's directory under `target/`, a temporary directory that is not itself a repository sits inside the checkout. Git found the checkout above it, where the directory is ignored, so `git ls-files` there succeeded and listed nothing, and the full check passed a directory it never read. - Temporary repositories' git gets `GIT_CEILING_DIRECTORIES` set to the parent of `root` (git stops before entering a ceiling), so it looks no further up than `root`. The checkout keeps git's own discovery. - New test `directories_outside_any_repository_are_walked`: inside an outer repository that ignores it, a plain directory holding an executable is refused by the walk (build output under `target/` is skipped), and plain git without the ceiling is shown listing nothing. ## 18. Hex or base64 wrapped onto many lines is one run The run check split runs at every non-payload byte, newlines included. `base64` wraps at 76 columns, PEM and `openssl base64` at 64, `xxd -p` at 60, so anything encoded by them passed as many short runs: ```sh head -c 300000 game.bin | base64 > strings.txt # 76-column lines, under 512 KiB git add strings.txt && cargo xtask policy --staged # asset policy: ... files ok ``` - A single line break (LF or CRLF) between two payload characters now continues the run; the break is not counted. A blank line or indentation still ends it, so prose and code are unaffected (`cargo xtask policy`: 152 files ok). - New tests `rejects_encoded_data_wrapped_across_lines` (76/LF, 64/CRLF, 60-column hex) and `line_breaks_join_only_payload_lines`; both fail without the fix. `docs/asset-policy.md` says so. ## 19. Temporary repositories ignore a hook's quarantine and trust their own owner Two more variables broke the tests' temporary repositories (Linux, git 2.56): | Set in the environment | Failed | |---|---| | `GIT_QUARANTINE_PATH` (a `pre-receive` hook runs with it, beside the object directories section 6 already drops) | 14 tests: every `git init` says `ref updates forbidden inside quarantine environment` | | a TMPDIR owned by another user (git's `GIT_TEST_ASSUME_DIFFERENT_OWNER=1` stands in) | 13 tests: git refuses each repository as dubious, and since they read no global config (section 10), no `safe.directory` could let them in | - Test git in temporary repositories drops `GIT_QUARANTINE_PATH` and passes `-c safe.directory=*`, command-line config that git honours for that setting. The checkout keeps both checks. - New test `temporary_repositories_ignore_quarantine_and_ownership`: plain git is refused under each, test git drops the quarantine and stages and lists a file in a repository it is told another user owns. It fails without the fix (and 15 tests fail under both variables together; 26/26 pass with it). - `temporary_repositories_read_only_their_own_config` allows that one command-line entry. ## 20. The staged check reads past `git replace` refs Replace refs are local and never pushed, but git follows them by default: a staged blob replaced by harmless text passed `cat-file`, and a HEAD replaced by a commit whose tree already holds the staged file dropped it from `diff --cached`. Every policy git command now runs with `--no-replace-objects`; the test `staged_check_ignores_replace_refs` covers both cases. ## 21. base64url counts as an encoded run The run check took only the standard base64 alphabet (`+`, `/`) as payload. base64url (RFC 4648 §5: `-` and `_`), which JWTs, `basenc --base64url` and most web tooling write, broke at every `-` and `_`, about one character in 32, so a whole file of it passed as short runs: ```sh head -c 300000 game.bin | basenc --base64url > strings.txt git add strings.txt && cargo xtask policy --staged # asset policy: ... files ok ``` - Each alphabet is measured on its own and the longer run counts; they are not mixed, so `a+b-c` is still two short runs. - New test `rejects_base64url_data` (a string literal and 76-column wrapped lines); it fails without the fix. `docs/asset-policy.md` says so. `cargo xtask policy`: 152 files ok, so nothing in the tree is affected. ## 22. victory-core's policy tests keep their temporary directories outside the checkout Section 12 kept xtask's temporary repositories out of a `TMPDIR` inside the checkout; `victory-core`'s `ensure_outside_repo` tests had the same problem the other way round. They need a directory *outside* every source tree, and took it from `tempfile::tempdir()`, which follows `TMPDIR`: ```sh mkdir scratch-tmp && TMPDIR=$PWD/scratch-tmp cargo test -p victory-core policy # 2 failed: accepts_unrelated_directories, resolves_dotdot_after_a_missing_directory # (InsideRepo { path: ".../scratch-tmp/.tmp3CpIBz/does/not/exist", ... }) ``` and `rejects_other_clones_via_marker` passed whether or not the marker mattered, since its directory was refused already. - The tests take their directory from `outside_tempdir()`: `TMPDIR` if `ensure_outside_repo` accepts it, otherwise the nearest writable ancestor of the checkout that it accepts (removed on drop), otherwise a panic saying to set `TMPDIR` outside the source tree. - `rejects_other_clones_via_marker` now checks that the directory is accepted before the marker is written, and refused as `InsideRepo` after. - With `TMPDIR` inside the checkout: 5/5 pass (2 failed before), nothing left behind. ## 23. Numeric arrays and `\xHH` strings count as embedded data `xxd -i` and `bin2c` write a file as `0x4d, 0x5a, ...` and a byte string as `"\x4d\x5a..."`: every token is a few characters, so neither was ever a long hex/base64 run, and an executable pasted into a `const [u8; N]` passed under the size limit. Lists of numeric literals joined by commas, and back-to-back `\xHH` escapes, are now capped at 512 elements; the largest table in the tree (XMA's) has 272, and a bracket or comment between rows ends a list. ## 24. Trace output pointed at stdout is not read as git's output The check parses git's stdout. With `GIT_TRACE=/dev/stdout` (or `GIT_TRACE_SETUP`, `GIT_TRACE2_EVENT`, any trace variable pointed at stdout) trace lines lead the first NUL-separated field. In the full check that is the first file listed: its name no longer exists, so it is never read and passes whatever it holds. `--staged` stops at a record it cannot parse. Before the fix: ```sh GIT_TRACE=/dev/stdout cargo test -p xtask # 3 failed, e.g. nested_repositories_are_violations: # left: ["23:54:41.355115 git.c:506 trace: built-in: git ls-files -z ...\ninner/"] # (GIT_TRACE_SETUP / GIT_TRACE2_EVENT=/dev/stdout: 3 failed as well) ``` - Every git the check runs drops `GIT_TRACE*` and `GIT_REDIRECT_*` (Git for Windows' `GIT_REDIRECT_STDOUT` sends output to a file, and the check would see an empty repository), and sets `GIT_TRACE2`, `GIT_TRACE2_EVENT` and `GIT_TRACE2_PERF` to `0`, since trace2 can also be turned on from global or system config, which those variables override. This applies to the hook too, not only to tests. - New test `trace_output_is_not_read_as_git_output`: git with the trace variables at `/dev/stdout` prints more than the names; after `unredirect_output` it prints exactly `a.bin\0`; and the full and staged checks both refuse the staged `a.bin`. - The two tests that run plain git as a control drop the same variables. - `cargo test -p xtask`: 31/31 pass (34/34 with sections 25 and 26), and also with each of `GIT_TRACE`, `GIT_TRACE_SETUP`, `GIT_TRACE_PERFORMANCE`, `GIT_TRACE2`, `GIT_TRACE2_EVENT` set to `/dev/stdout`. ## 25. A tracked file missing from disk is read from the index Deleted but not `git rm`ed, or left out of a sparse checkout, a file is still in the index and a plain `git commit` keeps it. The full check skipped it unread, so a binary committed with `--no-verify` and then deleted from disk passed `cargo test`. It now reads the indexed blob by object id. New test `tracked_files_missing_from_disk_are_read_from_the_index`. ## 26. ascii85, Z85 and uuencoded data count as encoded runs Their alphabets put punctuation every few characters, so their output never made a long hex/base64 run (sections 18 and 21), and a file of it passed under the size limit: ```sh python3 -c "import base64,os; open('strings.txt','wb').write(base64.a85encode(os.urandom(3000), wrapcol=76))" head -c 3000 game.bin | basenc --z85 -w0 > z.txt git add strings.txt z.txt && cargo xtask policy --staged # asset policy: ... files ok ``` - A run of printable ASCII without whitespace (`!` to `~`) over 512 characters is now refused: `3750-character run without whitespace (ascii85, Z85 or uuencoded data?)`. - A single line break continues the run only after a line of at least 40 characters, as encoders wrap (60 to 80 columns), so a list of short entries without spaces, such as `.gitignore` patterns, does not join into one run. - The longest such run in the tree is 89 characters; `cargo xtask policy`: 152 files ok. - New tests `rejects_ascii85_z85_and_uuencoded_data` (each alphabet unwrapped, wrapped with LF and with CRLF; the hex/base64 check alone sees runs under 32) and `printable_runs_join_only_long_lines` (whitespace, blank lines, short lines, a 100-line `.gitignore` and a long URL pass). `docs/asset-policy.md` says so. ## 27. A tracked file is read as the index holds it as well as on disk The full check read only the working copy of a tracked file. A binary committed with `--no-verify` and then overwritten on disk with text stays in the repository and in every later commit, yet `cargo xtask policy` and `cargo test` passed; `git update-index --assume-unchanged` or `--skip-worktree` hide it from `git status` as well. ```sh printf 'MZ\220\0binary' > game.rs && git add game.rs && git commit --no-verify -m x echo 'fn game() {}' > game.rs && git update-index --assume-unchanged game.rs cargo xtask policy # asset policy: ... files ok ``` - Every tracked file's index blob is read with one `git cat-file --batch` (not a process per file) and checked as well when it differs from the disk, reported as `game.rs (as indexed): ...`. An object git does not have is a violation. - New test `tracked_files_are_read_as_indexed_as_well`: edited on disk, then each of `--assume-unchanged` and `--skip-worktree`, fails; once the text is staged both checks pass. `docs/asset-policy.md` says so. - `cargo test -p xtask`: 35/35 pass, also with `TMPDIR` inside the checkout; clippy `-D warnings` clean; `cargo xtask policy`: 152 files ok. ## 28. Binary without NUL bytes, and base65536-style text, are refused `check` took a file for binary only if it held a NUL. Byte stuffing such as COBS removes every NUL, and bytes over `0x7F` break every run check, so the result passed as text. base32768 and base65536 write 15–16 bits per CJK (or similar) letter with no whitespace, which no ASCII run saw at all: ```sh python3 -c "from cobs import cobs; import sys; sys.stdout.buffer.write(cobs.encode(open('game.bin','rb').read(400000)))" > strings.txt git add strings.txt && cargo xtask policy --staged # asset policy: ... files ok ``` - Content must be UTF-8 without control characters other than tab, line breaks and form feed (`not UTF-8 text (binary content?)`, `control character U+0001 ...`). Every file in the tree already is. - The printable run from section 26 now counts any character that is neither whitespace nor a control, in characters, so base32768/base65536 runs are refused; prose in any script, with its spaces and line breaks, passes. - New tests `rejects_binary_without_nul_bytes` (COBS of pseudo-random bytes, and a 7-bit variant; ordinary non-ASCII prose passes) and `rejects_base65536_like_data` (a string literal and 64-column wrapped lines). Both fail without the fix. `docs/asset-policy.md` says so. - `cargo test -p xtask`: 37/37, also with `TMPDIR` inside the checkout; clippy `-D warnings` clean; `cargo xtask policy`: 152 files ok. ## 29. Every stage of a conflicted path is read The full check mapped each indexed path to one blob, so a conflicted path kept only its last stage: game data in stage 1 or 2 passed unread, though `git checkout --ours` puts it in the next commit. - Each index entry of a path is kept, and every stage's blob is checked (`<path> (as indexed): ...`). - New test `every_stage_of_a_conflicted_path_is_read`. ## 30. A file over the size limit is not read into memory whole Every file and blob was read whole before `check` refused it as over 512 KiB. A game dump or disc image of several gigabytes left untracked in the checkout (not ignored), or staged by mistake, was loaded into memory first and could exhaust it: ```sh truncate -s 8G game.rs && cargo xtask policy # allocates 8 GiB before refusing it ``` - On disk, in `git cat-file --batch` and in `git cat-file blob` (now streamed rather than `output()`), only the first 512 KiB is kept; the rest is copied to a sink to count the size. The violation reports the whole size, and the start is still checked, so a too-big PE still says `looks like a PE executable`. - A file over the limit is never taken for the one exception, whose content is within it. - New test `files_over_the_limit_are_not_read_whole`: an 8 MiB sparse file untracked, staged, and indexed under a small working copy is read to the limit with its full size and refused; a file of exactly 512 KiB is read whole and passes. `docs/asset-policy.md` says so. - `cargo test -p xtask`: 39/39, also with `TMPDIR` inside the checkout; `cargo test -p victory-core` passes; clippy `-D warnings` clean; `cargo xtask policy`: 152 files ok. ## 31. Escape strings split into many literals count as one run Section 23 capped back-to-back `\xHH` escapes at 512, but any string boundary ended the count. Split every 64 escapes, a byte string of any length passed: ```rust const DATA: &[u8] = b"\x4d\x5a\x90...(64 escapes)\ \x00\x03...(64 more)\ ..."; // also "..." "..." (C/HLSL), concat!("...", "..."), [b"...", b"..."] ``` - Escapes now join across a boundary made only of quotes, commas, whitespace, `b"` and `\`-newline continuations; `\u{H..}` escapes (1 to 6 digits, what `escape_default` and `{:?}` write) count as well. Whitespace or a comma alone inside one string, or any other text between literals, still ends a run. - New tests `rejects_escape_strings_split_across_literals` (five ways of splitting, plus `\u{..}`) and `escape_runs_join_only_across_string_boundaries`; both fail without the fix. `docs/asset-policy.md` says so. - `cargo test -p xtask`: 41/41, also with `TMPDIR` inside the checkout; `cargo test -p victory-core policy` passes; clippy `-D warnings` clean; `cargo xtask policy`: 152 files ok. ## 32. The tests pass under any TMPDIR name Under a `TMPDIR` holding `'` or `:`, three tests failed on the test, not on the check: ```sh TMPDIR="/tmp/it's a:dir" cargo test -p xtask # every_way_of_committing_runs_a_tracked_hook, lfs_tracked_files_are_violations: the hook # and LFS clean filter they write ('…/it's a:dir/…') are shell syntax errors, so git fails # directories_outside_any_repository_are_walked: "a repository above was found" ``` - Paths embedded in the scripts the tests write are now quoted for `sh` (`sh_quote`). - Git splits `GIT_CEILING_DIRECTORIES` at `:` with no escape, so the ceiling `git_command` puts on a temporary directory did not hold and git found the repository around it. `tempdir` now skips a candidate whose path holds `:`, falling back to the directory beside the test binary as it already does for a `TMPDIR` inside the checkout. - New test `temporary_directories_survive_any_tmpdir_name`: shows the split ceiling finding the outer repository, that the fallback is taken, and that `sh_quote` round-trips `'`, `$`, backticks, `\` and `"` through `sh`. - `cargo test -p xtask`: 45/45 with the default `TMPDIR`, with one inside the checkout, and with `it's a:dir`, `co:lon` and `q'x`; clippy `-D warnings` and `cargo fmt --check` clean. ## 33. Merges and `git am` run the policy check too `git merge` runs `pre-merge-commit`, not `pre-commit`, before it records a merge made without conflicts, and `git am` runs `pre-applypatch`. So a branch committed with `--no-verify`, or a mailed patch, brought its files in unchecked: ```sh git checkout -b side && printf 'MZ\220\0' > data.rs && git add data.rs && git commit --no-verify -m data git checkout main && git merge side # no hook ran; data.rs is in main ``` - New `.githooks/pre-merge-commit` and `.githooks/pre-applypatch`, tracked `100755` (so `hooks_are_tracked_executable` covers them), both `exec cargo xtask policy --staged`. - New test `every_way_of_committing_runs_a_tracked_hook`: with stand-in hooks under `core.hooksPath`, a commit, a merge and an `am` each run at least one tracked hook, and the staged check refuses what the merge brings in. `install-hooks` and `docs/asset-policy.md` say so. ## 34. Hex dumps (`xxd`, `hexdump -C`, `od`) count as embedded data A dump writes a file as short hex or octal groups separated by spaces, with an offset in front and sometimes the printable bytes behind: no long hex run, whitespace every few characters, no commas. A dump of an executable in a `.txt` or `.md` passed every check under the size limit: ```sh head -c 40000 game.bin | xxd > notes.txt && git add notes.txt && cargo xtask policy --staged # ... files ok ``` - A line counts when at least 4 of its words, and three in four, are hex values (up to 16 digits, optional `0x` and `:`); consecutive counting lines add up against the same 512-value limit as numeric arrays. Prose fond of `cafe`/`dead`/`beef` does not count. - New tests `rejects_hex_dumps` (`xxd`, `hexdump -C` and `od` layouts) and `hex_dumps_are_only_lines_of_hex_values`. `docs/asset-policy.md` says so. ## 35. Octal and `\uHHHH` / `\UHHHHHHHH` escapes count as byte escapes Sections 23 and 31 counted `\xHH` and `\u{..}` escapes only. C, HLSL, Python and shell `printf` write bytes as octal (`\115\132\220`), and JSON, JavaScript, Java and Python as `\uHHHH` (`json.dumps` escapes every non-ASCII character so) or `\UHHHHHHHH`. Split into strings short enough for the printable-run check, a file of them passed: ```c static const char data[] = "\115\132\220\0\3\0..." /* 40 escapes a line, any number of lines */ "..."; ``` ```json ["ÍÚĐ...", "...", ...] ``` - `escape_len` also takes `\` + 1 to 3 octal digits, `\u` + exactly 4 hex digits and `\U` + exactly 8; they join across string boundaries as in section 31, and mix with the other kinds. A lone `"\0"` terminator or the odd `café` stays a run of one. - New test `rejects_octal_and_fixed_width_unicode_escapes` (C octal, Python `\NNN` byte strings, a JSON array of `\uHHHH` strings, Python `\U` strings; each string is shown to be under the printable-run limit); it fails without the fix. `docs/asset-policy.md` lists the new escapes. - `cargo test -p xtask`: 46/46, also with `TMPDIR` inside the checkout; clippy `-D warnings` and `cargo fmt` clean; `cargo xtask policy`: 154 files ok. ## 36. `cargo xtask` checks the worktree it ran in, not the one it was built in Worktrees that share a `CARGO_TARGET_DIR` build xtask packages with the same name and version, and cargo treats one worktree's binary as up to date for another. The `CARGO_MANIFEST_DIR` compiled into the binary then named the other worktree, so this worktree's pre-commit hook checked the other worktree's files. `workspace_root` now takes the `CARGO_MANIFEST_DIR` that cargo sets at run time, as long as it names an xtask package directory, and falls back to the compiled-in value otherwise. The new test is `workspace_root_is_where_cargo_ran`. ## 37. The hooks find cargo off the PATH that GUI git clients give them Git clients started from a desktop launcher (IDEs, GUI git tools) often run hooks with a PATH that does not include `~/.cargo/bin`, where rustup installs cargo. Every hook then failed with only `cargo: not found` and refused the commit with no hint why. - `pre-commit` looks for cargo on the PATH first. If it is not there, it tries `${CARGO_HOME:-$HOME/.cargo}/bin/cargo` (and `cargo.exe`, for Git for Windows). If cargo is in none of those places, the hook refuses the commit with `asset policy: cargo not found on PATH or in …`, and says to add cargo to the PATH git runs hooks with or to set `CARGO_HOME`. - `pre-merge-commit` and `pre-applypatch` now `exec` `pre-commit` by path instead of repeating the lookup. Git runs hooks by path from the top of the worktree. - New test `hooks_find_cargo_off_the_path` runs every tracked hook with an empty environment and an empty PATH, against a stub `cargo` that logs its arguments. It covers three cases: the stub found under `$HOME/.cargo/bin`, found under `CARGO_HOME`, and cargo nowhere (the hook must fail and print `cargo not found`). The test fails against the previous hooks. - `cargo test -p xtask -p victory-core`: all pass (xtask 48/48), also with `TMPDIR` inside the checkout. `cargo clippy -p xtask --all-targets -- -D warnings` and `cargo fmt --check` are clean. `cargo xtask policy` reports 154 files ok. This commit was itself made through the new `pre-commit`. ## 38. A TMPDIR whose path is not UTF-8 is passed over, not panicked on Several tests build hook and filter scripts, and some git arguments, from the temporary directory's path as text. Under a TMPDIR that is not UTF-8 (for example `TMPDIR=$'/tmp/bad\xff'`), five tests panicked in `to_str`: `lfs_tracked_files_are_violations`, `every_way_of_committing_runs_a_tracked_hook`, `hooks_find_cargo_off_the_path`, `symlinks_are_checked_as_git_stores_them` and `temporary_directories_survive_any_tmpdir_name`. - `tempdir_in_first` now skips a candidate that is not UTF-8, as it already skips one holding `:`, and falls back to the directory beside the test binary. The panic message names both conditions. - New test `temporary_directories_skip_a_tmpdir_that_is_not_utf8` offers a non-UTF-8 directory and then a plain one, and checks that the plain one is chosen and that nothing is left in the other. It returns early on filesystems that refuse such names (APFS). - `TMPDIR=$'…/bad\xff' cargo test -p xtask`: 47 passed and 5 failed before, 53/53 after. `cargo clippy -p xtask --all-targets -- -D warnings` and `cargo fmt --check` are clean, and `cargo xtask policy` reports 154 files ok. ## 39. A build directory inside the checkout no longer fails the full check `.gitignore` ignores `/target/` only. With `CARGO_TARGET_DIR` inside the checkout under another name, for example one kept beside a worktree, every object file built there was listed as untracked. `CARGO_TARGET_DIR=$PWD/build-out cargo test -p xtask` failed `repository_passes_policy` with 947 violations (`build-out/debug/incremental/…/*.o: binary content`), and `cargo xtask policy` failed the same way. With `TMPDIR` also in the checkout, `tempdir()` had nowhere unseen left, because its fallback beside the test binary was visible too. - New `build_dir_in(root, exe)` finds the Cargo target directory the running program was built in: the outermost ancestor of the executable, below the checkout and never the checkout itself, that holds a `CACHEDIR.TAG` with Cargo's signature. - The full check skips only the **untracked** files of that one directory, in a repository and in the walk outside one. Files tracked there are still read. Another build directory, or a sibling whose name only starts the same (`build-outer/`), is still read. The staged check is unchanged, so what a commit holds is still checked in full. - `unseen_by_full_check` treats that directory as unseen, so the fallback beside the test binary works again. - New tests: `build_directories_are_found_by_their_cache_tag` covers inner and outer tags, a tag without the signature, a tag at the root, and a program built outside the checkout. `the_running_build_directory_is_passed_over` covers git and walk modes, a tracked file in the build directory, another build directory, and the prefix sibling. - `CARGO_TARGET_DIR=$PWD/build-out cargo test -p xtask`: 1 failure before, 56/56 after, and also 56/56 with `TMPDIR` inside the checkout. With the target directory in `/tmp` it is also 56/56. `cargo clippy -p xtask --all-targets -- -D warnings` and `cargo fmt --check` are clean, and `cargo xtask policy` reports 154 files ok. ## Testing (Linux) - `cargo test -p xtask -p victory-core`: all pass, including every new test; also with `GIT_INDEX_FILE` and `GIT_DIR` pointing elsewhere, and with a hostile `GIT_CONFIG_GLOBAL`, with `TMPDIR` inside the checkout, with `XDG_CONFIG_HOME/git/ignore` holding `*.rs`, and with `GIT_QUARANTINE_PATH` and `GIT_TEST_ASSUME_DIFFERENT_OWNER` set, and with the trace variables pointed at stdout. - `cargo clippy -p xtask -p victory-core --all-targets -- -D warnings`: clean. - `cargo clippy -p xtask --all-targets --target x86_64-pc-windows-msvc -- -D warnings`: clean before section 9; with `blake3` added it needs MSVC's `lib.exe` for blake3's C build, which this Linux machine lacks, so Windows CI covers it. - `rustfmt --check` on the touched files: clean. - `cargo xtask policy`: `asset policy: 152 files ok`.
catminou4 commented 2026-11-24 06:47:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T06:47:23Z.

Review: APPROVED


Verified locally on macOS 26 arm64, rustc 1.98.1 (aarch64-apple-darwin) at head 3e8e988:

  • cargo test -p victory-core -p xtask --locked: victory-core 10 passed (main: 8), xtask 48 passed (main: 4) — 0 failed. The new policy/hook tests, including the staged-type-change and pinned-exception cases, run green on macOS.

Approving.

<!-- greyfinch-sync:Marvisak/VIctory:review:6034834909 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/246#pullrequestreview-6034834909). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T06:47:23Z. **Review:** APPROVED --- Verified locally on macOS 26 arm64, rustc 1.98.1 (aarch64-apple-darwin) at head 3e8e988: - `cargo test -p victory-core -p xtask --locked`: victory-core **10 passed** (main: 8), xtask **48 passed** (main: 4) — 0 failed. The new policy/hook tests, including the staged-type-change and pinned-exception cases, run green on macOS. Approving.
jeremygold02 commented 2026-11-24 06:56:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T05:23:00Z.


Tested current PR head d283acec55f511d1ad39161f1163e678b0c532f2.

  • cargo test --locked -p xtask --bin xtask -- --test-threads=1: 16 passed. The run includes policy checks for pinned exception contents, LFS pointers, wrapped hex/base64 and base64url, ascii85/Z85/uuencoded data, numeric arrays and escaped bytes, the repository policy scan, temporary-repository Git configuration, and executable hook tracking (xtask policy tests).
  • cargo test --locked -p victory-core --lib policy -- --test-threads=1: 5 passed, including missing-directory .. resolution, repository-boundary rejection, and the clone-marker case (policy test).
  • cargo xtask policy: asset policy: 152 files ok.
  • git diff --check d2a4bae1f49533ef5cb512fd1b1ba1513f2e1989 HEAD and rustfmt --check --edition 2024 crates/victory-core/src/policy.rs xtask/src/main.rs xtask/src/policy.rs: passed. Workspace-wide cargo fmt --all -- --check emits formatting diffs in unrelated files.

Unix-only cases were not exercised by this run, including tracked_files_missing_from_disk_are_read_from_the_index and the new tracked_files_are_read_as_indexed_as_well regression (test), plus symlink, non-UTF-8 path, and submodule cases. Those tests are gated with #[cfg(unix)].

<!-- greyfinch-sync:Marvisak/VIctory:comment:7122895150 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/246#issuecomment-7122895150). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-24T05:23:00Z. --- Tested current PR head `d283acec55f511d1ad39161f1163e678b0c532f2`. - `cargo test --locked -p xtask --bin xtask -- --test-threads=1`: 16 passed. The run includes policy checks for pinned exception contents, LFS pointers, wrapped hex/base64 and base64url, ascii85/Z85/uuencoded data, numeric arrays and escaped bytes, the repository policy scan, temporary-repository Git configuration, and executable hook tracking ([xtask policy tests](https://github.com/Marvisak/VIctory/blob/d283acec55f511d1ad39161f1163e678b0c532f2/xtask/src/policy.rs)). - `cargo test --locked -p victory-core --lib policy -- --test-threads=1`: 5 passed, including missing-directory `..` resolution, repository-boundary rejection, and the clone-marker case ([policy test](https://github.com/Marvisak/VIctory/blob/d283acec55f511d1ad39161f1163e678b0c532f2/crates/victory-core/src/policy.rs#L179)). - `cargo xtask policy`: `asset policy: 152 files ok`. - `git diff --check d2a4bae1f49533ef5cb512fd1b1ba1513f2e1989 HEAD` and `rustfmt --check --edition 2024 crates/victory-core/src/policy.rs xtask/src/main.rs xtask/src/policy.rs`: passed. Workspace-wide `cargo fmt --all -- --check` emits formatting diffs in unrelated files. Unix-only cases were not exercised by this run, including `tracked_files_missing_from_disk_are_read_from_the_index` and the new `tracked_files_are_read_as_indexed_as_well` regression ([test](https://github.com/Marvisak/VIctory/blob/d283acec55f511d1ad39161f1163e678b0c532f2/xtask/src/policy.rs#L1195-L1236)), plus symlink, non-UTF-8 path, and submodule cases. Those tests are gated with `#[cfg(unix)]`.
Marvisak commented 2026-11-25 01:07:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:23:54Z.


Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: xtask/src/policy.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148467364 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/246#issuecomment-7148467364). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:23:54Z. --- <!-- victory-triage v1 head=0d6cf21506d14c27b14e0c5eb86baaf6e6698594 verdict=needs-rebase at=2026-11-25T00:13:20Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (ac2525d). Conflicting files: `xtask/src/policy.rs`. The content has not been reviewed yet; it will be once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 02:02:38 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!246
No description provided.