Policy and hooks: staged type changes, pinned exception, executable pre-commit #246
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!246
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/246/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@SkippySteve on GitHub · 2026-11-24 01:45 UTC · original
SkippySteve/policy-staged-typechange→main· +5843 −108 · 10 files · 88 commits · closed without mergingFixes 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 withgit diff --cached --name-only --diff-filter=ACMR. A path whose type changed, such as a committed symlink replaced by a regular file, is staged asT, so it is not listed and none of its content is checked. A binary committed under an allowed name such asdata.rspasses the hook.The fix adds
Tto the filter. The new teststaged_check_reads_type_changessets up that case in a temporary repository and checks thatlist_filesreturns the path and thatrun(.., 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_reporesolves..below a directory not yet created (was #252)ensure_outside_reporesolves a destination that does not exist yet by walking up to its longest existing prefix. The walk took each component withPath::file_name, which isNonefor a path ending in.., so a destination such as<tmp>/missing/../cachefailed withcannot resolve ...: No such file or directoryinstead 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 testresolves_dotdot_after_a_missing_directorychecks that<tmp>/missing/../cacheis accepted and that<repo>/not-yet-created/../outis reported asInsideRepo(it was anIoerror before).3. Track
.githooks/pre-commitas executable (was #253).githooks/pre-commitwas tracked as100644. Git outside Windows skips a non-executable hook and only prints a hint, so aftercargo xtask install-hooksa commit on Linux or macOS never ran the policy check:.githooks/pre-commitas100755(mode change only).hooks_are_tracked_executableto xtask: it readsgit ls-files --stage -- .githooksand fails if a tracked hook is not100755(it skips itself outside a git checkout).Git for Windows runs hooks regardless of the bit, so nothing changes there.
4. An
.editorconfigthat says what the tree already holds (was #291)Adds a root
.editorconfigthat states what the tree already holds: UTF-8, LF (as.gitattributessays), a final newline, no trailing whitespace, spaces; 4-space indent for.rs/.toml, 2 for.yml/.yaml/.json; CRLF for.cmd/.ps1, which.gitattributesalready 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_lossyand then read the file back by that decoded name (git show :<name>when staged,fs::readotherwise). For a name that is not UTF-8 the decoded name does not exist, the read failed, and the loopcontinued, so the file was never checked, whatever it held. A submodule (gitlink) failed the read the same way and was skipped too: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.git ls-files --stage, since it may not be checked out).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.mdmentions 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_FILEand similar variables choose the repository over the working directory. A pre-commit hook runs withGIT_INDEX_FILEset, andgit commit -asets it to an absolute path, so tests run from a hook (or withGIT_DIRexported) all wrote into that one outside index:git_command(root). Undercfg(test)it drops the variablesgit rev-parse --local-env-varslists.git commit -aandgit commit <path>stage into a temporary index that onlyGIT_INDEX_FILEnames.test_git_ignores_the_repository_environmentchecks 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 diffhonoursdiff.ignoreSubmodulesand a submodule'signore = allin.gitmodules, which it reads from the working tree even when that file is untracked. Either one left a staged submodule out ofgit diff --cached --raw, so the check from section 5 never saw it:--ignore-submodules=none.staged_submodules_are_seen_whatever_git_ignoressets both the config and an untracked.gitmodules, checks that plaingit diff --cachedhides 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 therepository_passes_policytest) read each path withfs::read, which follows the link, so the two disagreed: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.symlinks_are_checked_as_git_stores_themcovers 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.mdsays how symlinks are checked.9. The one exception covers its content, not its name
EXCEPTIONSskippedcrates/victory-formats/src/bcpack-tables.binby 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:f0f032aa…73c0for the current tables, unchanged frommain). Any other content at that path is a violation that names both hashes.blake3, already a workspace dependency, is added to xtask.exceptions_are_pinned_to_their_content(pure) andexempted_paths_refuse_other_content(temporary repository: other content is refused by the full and staged checks, the real tables pass both).docs/asset-policy.mdsays 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.excludesFilethat matches what a test stages makesgit addrefuse it, and a globalcore.hooksPathruns the developer's hooks inside the test repositories:cfg(test),git_commandsetsGIT_CONFIG_GLOBAL=/dev/nullandGIT_CONFIG_NOSYSTEM=1for any root other than the checkout (Git for Windows opens/dev/nullasNUL).repository_passes_policystill honours a global excludes file (for.DS_Storeand the like), ascargo xtask policydoes.temporary_repositories_read_only_their_own_configchecks thatgit config --list --show-scopein a temporary repository shows onlylocalentries, 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=lfsin.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:checkrefuses content that begins with an LFS pointer's version line (https://git-lfs.github.com/spec/or the pre-1.0https://hawser.github.com/spec/). A mention of the URL elsewhere in a file is not affected.rejects_lfs_pointers(pure) andlfs_tracked_files_are_violations(temporary repository with a stand-infilter.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.mdsays LFS pointers are refused.12. The tests' temporary repositories stay out of a TMPDIR inside the checkout
With
TMPDIRinside the checkout, each test's temporary repository is an untracked directory there, andrepository_passes_policy, running on another thread, sometimes lists it and the files the test stages:tempdir(). It usesTMPDIRwhen the checkout's full check cannot see it (it is outside, orgit check-ignoresays it is ignored), otherwise the test binary's directory undertarget/, which is ignored. If neither is, the test fails with a message saying to setTMPDIRoutside the checkout, so it does not flake.TMPDIRinside 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 --otherslists 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 testnested_repositories_are_violations;docs/asset-policy.mdmentions it.14. Temporary repositories read no default ignore or attributes file
GIT_CONFIG_GLOBAL=/dev/nullempties the global config, but git still reads$XDG_CONFIG_HOME/git/ignore(else~/.config/git/ignore), the matchingattributesfile, and the system gitattributes, with no setting naming them. With*.rsin a developer's~/.config/git/ignore, four policy tests failed atgit add; afilter=there would rewrite what they stage. Temporary repositories now get anXDG_CONFIG_HOMEthat cannot exist, plusGIT_ATTR_NOSYSTEM. The checkout's own check keeps the developer's files. New testtemporary_repositories_read_no_default_ignore_or_attributesruns 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_DIRcopied itsinfo/excludeand hooks into every test'sgit init, andGIT_DEFAULT_HASH=sha256made repositories that refuse the SHA-1 ids the submodule tests stage. Temporary repositories now get an empty template directory and the default hash. New testtemporary_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):
GIT_ATTR_SOURCE=HEADgit add/check-attrin a fresh repository saysbad --attr-source or GIT_ATTR_SOURCE(it has no HEAD)GIT_LITERAL_PATHSPECS,GIT_NOGLOB_PATHSPECS,GIT_ICASE_PATHSPECScheck-ignorerefuses to run (pathspec magic not supported), sotempdir()misreads whether a TMPDIR inside the checkout is ignored; the control in section 14 failedGIT_AUTHOR_NAME, unparseableGIT_AUTHOR_DATE/GIT_COMMITTER_DATE-c user.*, andgit commitexportsGIT_AUTHOR_*to its hooksGIT_ATTR_SOURCE. The checkout's full check passes no pathspecs and keeps its attribute source.@0 +0000) set as variables instead ofuser.*config.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.TMPDIRinside the checkout plusGIT_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 undertarget/, a temporary directory that is not itself a repository sits inside the checkout. Git found the checkout above it, where the directory is ignored, sogit ls-filesthere succeeded and listed nothing, and the full check passed a directory it never read.GIT_CEILING_DIRECTORIESset to the parent ofroot(git stops before entering a ceiling), so it looks no further up thanroot. The checkout keeps git's own discovery.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 undertarget/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.
base64wraps at 76 columns, PEM andopenssl base64at 64,xxd -pat 60, so anything encoded by them passed as many short runs:cargo xtask policy: 152 files ok).rejects_encoded_data_wrapped_across_lines(76/LF, 64/CRLF, 60-column hex) andline_breaks_join_only_payload_lines; both fail without the fix.docs/asset-policy.mdsays 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):
GIT_QUARANTINE_PATH(apre-receivehook runs with it, beside the object directories section 6 already drops)git initsaysref updates forbidden inside quarantine environmentGIT_TEST_ASSUME_DIFFERENT_OWNER=1stands in)safe.directorycould let them inGIT_QUARANTINE_PATHand passes-c safe.directory=*, command-line config that git honours for that setting. The checkout keeps both checks.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_configallows that one command-line entry.20. The staged check reads past
git replacerefsReplace 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 fromdiff --cached. Every policy git command now runs with--no-replace-objects; the teststaged_check_ignores_replace_refscovers 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 --base64urland most web tooling write, broke at every-and_, about one character in 32, so a whole file of it passed as short runs:a+b-cis still two short runs.rejects_base64url_data(a string literal and 76-column wrapped lines); it fails without the fix.docs/asset-policy.mdsays 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
TMPDIRinside the checkout;victory-core'sensure_outside_repotests had the same problem the other way round. They need a directory outside every source tree, and took it fromtempfile::tempdir(), which followsTMPDIR:and
rejects_other_clones_via_markerpassed whether or not the marker mattered, since its directory was refused already.outside_tempdir():TMPDIRifensure_outside_repoaccepts it, otherwise the nearest writable ancestor of the checkout that it accepts (removed on drop), otherwise a panic saying to setTMPDIRoutside the source tree.rejects_other_clones_via_markernow checks that the directory is accepted before the marker is written, and refused asInsideRepoafter.TMPDIRinside the checkout: 5/5 pass (2 failed before), nothing left behind.23. Numeric arrays and
\xHHstrings count as embedded dataxxd -iandbin2cwrite a file as0x4d, 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 aconst [u8; N]passed under the size limit. Lists of numeric literals joined by commas, and back-to-back\xHHescapes, 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(orGIT_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.--stagedstops at a record it cannot parse. Before the fix:GIT_TRACE*andGIT_REDIRECT_*(Git for Windows'GIT_REDIRECT_STDOUTsends output to a file, and the check would see an empty repository), and setsGIT_TRACE2,GIT_TRACE2_EVENTandGIT_TRACE2_PERFto0, 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.trace_output_is_not_read_as_git_output: git with the trace variables at/dev/stdoutprints more than the names; afterunredirect_outputit prints exactlya.bin\0; and the full and staged checks both refuse the stageda.bin.cargo test -p xtask: 31/31 pass (34/34 with sections 25 and 26), and also with each ofGIT_TRACE,GIT_TRACE_SETUP,GIT_TRACE_PERFORMANCE,GIT_TRACE2,GIT_TRACE2_EVENTset 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 plaingit commitkeeps it. The full check skipped it unread, so a binary committed with--no-verifyand then deleted from disk passedcargo test. It now reads the indexed blob by object id. New testtracked_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:
!to~) over 512 characters is now refused:3750-character run without whitespace (ascii85, Z85 or uuencoded data?)..gitignorepatterns, does not join into one run.cargo xtask policy: 152 files ok.rejects_ascii85_z85_and_uuencoded_data(each alphabet unwrapped, wrapped with LF and with CRLF; the hex/base64 check alone sees runs under 32) andprintable_runs_join_only_long_lines(whitespace, blank lines, short lines, a 100-line.gitignoreand a long URL pass).docs/asset-policy.mdsays 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-verifyand then overwritten on disk with text stays in the repository and in every later commit, yetcargo xtask policyandcargo testpassed;git update-index --assume-unchangedor--skip-worktreehide it fromgit statusas well.git cat-file --batch(not a process per file) and checked as well when it differs from the disk, reported asgame.rs (as indexed): .... An object git does not have is a violation.tracked_files_are_read_as_indexed_as_well: edited on disk, then each of--assume-unchangedand--skip-worktree, fails; once the text is staged both checks pass.docs/asset-policy.mdsays so.cargo test -p xtask: 35/35 pass, also withTMPDIRinside the checkout; clippy-D warningsclean;cargo xtask policy: 152 files ok.28. Binary without NUL bytes, and base65536-style text, are refused
checktook a file for binary only if it held a NUL. Byte stuffing such as COBS removes every NUL, and bytes over0x7Fbreak 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:not UTF-8 text (binary content?),control character U+0001 ...). Every file in the tree already is.rejects_binary_without_nul_bytes(COBS of pseudo-random bytes, and a 7-bit variant; ordinary non-ASCII prose passes) andrejects_base65536_like_data(a string literal and 64-column wrapped lines). Both fail without the fix.docs/asset-policy.mdsays so.cargo test -p xtask: 37/37, also withTMPDIRinside the checkout; clippy-D warningsclean;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 --oursputs it in the next commit.<path> (as indexed): ...).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
checkrefused 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:git cat-file --batchand ingit cat-file blob(now streamed rather thanoutput()), 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 sayslooks like a PE executable.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.mdsays so.cargo test -p xtask: 39/39, also withTMPDIRinside the checkout;cargo test -p victory-corepasses; clippy-D warningsclean;cargo xtask policy: 152 files ok.31. Escape strings split into many literals count as one run
Section 23 capped back-to-back
\xHHescapes at 512, but any string boundary ended the count. Split every 64 escapes, a byte string of any length passed:b"and\-newline continuations;\u{H..}escapes (1 to 6 digits, whatescape_defaultand{:?}write) count as well. Whitespace or a comma alone inside one string, or any other text between literals, still ends a run.rejects_escape_strings_split_across_literals(five ways of splitting, plus\u{..}) andescape_runs_join_only_across_string_boundaries; both fail without the fix.docs/asset-policy.mdsays so.cargo test -p xtask: 41/41, also withTMPDIRinside the checkout;cargo test -p victory-core policypasses; clippy-D warningsclean;cargo xtask policy: 152 files ok.32. The tests pass under any TMPDIR name
Under a
TMPDIRholding'or:, three tests failed on the test, not on the check:sh(sh_quote).GIT_CEILING_DIRECTORIESat:with no escape, so the ceilinggit_commandputs on a temporary directory did not hold and git found the repository around it.tempdirnow skips a candidate whose path holds:, falling back to the directory beside the test binary as it already does for aTMPDIRinside the checkout.temporary_directories_survive_any_tmpdir_name: shows the split ceiling finding the outer repository, that the fallback is taken, and thatsh_quoteround-trips',$, backticks,\and"throughsh.cargo test -p xtask: 45/45 with the defaultTMPDIR, with one inside the checkout, and withit's a:dir,co:lonandq'x; clippy-D warningsandcargo fmt --checkclean.33. Merges and
git amrun the policy check toogit mergerunspre-merge-commit, notpre-commit, before it records a merge made without conflicts, andgit amrunspre-applypatch. So a branch committed with--no-verify, or a mailed patch, brought its files in unchecked:.githooks/pre-merge-commitand.githooks/pre-applypatch, tracked100755(sohooks_are_tracked_executablecovers them), bothexec cargo xtask policy --staged.every_way_of_committing_runs_a_tracked_hook: with stand-in hooks undercore.hooksPath, a commit, a merge and anameach run at least one tracked hook, and the staged check refuses what the merge brings in.install-hooksanddocs/asset-policy.mdsay so.34. Hex dumps (
xxd,hexdump -C,od) count as embedded dataA 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
.txtor.mdpassed every check under the size limit:0xand:); consecutive counting lines add up against the same 512-value limit as numeric arrays. Prose fond ofcafe/dead/beefdoes not count.rejects_hex_dumps(xxd,hexdump -Candodlayouts) andhex_dumps_are_only_lines_of_hex_values.docs/asset-policy.mdsays so.35. Octal and
\uHHHH/\UHHHHHHHHescapes count as byte escapesSections 23 and 31 counted
\xHHand\u{..}escapes only. C, HLSL, Python and shellprintfwrite bytes as octal (\115\132\220), and JSON, JavaScript, Java and Python as\uHHHH(json.dumpsescapes every non-ASCII character so) or\UHHHHHHHH. Split into strings short enough for the printable-run check, a file of them passed:escape_lenalso 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 oddcaféstays a run of one.rejects_octal_and_fixed_width_unicode_escapes(C octal, Python\NNNbyte strings, a JSON array of\uHHHHstrings, Python\Ustrings; each string is shown to be under the printable-run limit); it fails without the fix.docs/asset-policy.mdlists the new escapes.cargo test -p xtask: 46/46, also withTMPDIRinside the checkout; clippy-D warningsandcargo fmtclean;cargo xtask policy: 154 files ok.36.
cargo xtaskchecks the worktree it ran in, not the one it was built inWorktrees that share a
CARGO_TARGET_DIRbuild xtask packages with the same name and version, and cargo treats one worktree's binary as up to date for another. TheCARGO_MANIFEST_DIRcompiled into the binary then named the other worktree, so this worktree's pre-commit hook checked the other worktree's files.workspace_rootnow takes theCARGO_MANIFEST_DIRthat 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 isworkspace_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 onlycargo: not foundand refused the commit with no hint why.pre-commitlooks for cargo on the PATH first. If it is not there, it tries${CARGO_HOME:-$HOME/.cargo}/bin/cargo(andcargo.exe, for Git for Windows). If cargo is in none of those places, the hook refuses the commit withasset policy: cargo not found on PATH or in …, and says to add cargo to the PATH git runs hooks with or to setCARGO_HOME.pre-merge-commitandpre-applypatchnowexecpre-commitby path instead of repeating the lookup. Git runs hooks by path from the top of the worktree.hooks_find_cargo_off_the_pathruns every tracked hook with an empty environment and an empty PATH, against a stubcargothat logs its arguments. It covers three cases: the stub found under$HOME/.cargo/bin, found underCARGO_HOME, and cargo nowhere (the hook must fail and printcargo not found). The test fails against the previous hooks.cargo test -p xtask -p victory-core: all pass (xtask 48/48), also withTMPDIRinside the checkout.cargo clippy -p xtask --all-targets -- -D warningsandcargo fmt --checkare clean.cargo xtask policyreports 154 files ok. This commit was itself made through the newpre-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 into_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_themandtemporary_directories_survive_any_tmpdir_name.tempdir_in_firstnow 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.temporary_directories_skip_a_tmpdir_that_is_not_utf8offers 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 warningsandcargo fmt --checkare clean, andcargo xtask policyreports 154 files ok.39. A build directory inside the checkout no longer fails the full check
.gitignoreignores/target/only. WithCARGO_TARGET_DIRinside 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 xtaskfailedrepository_passes_policywith 947 violations (build-out/debug/incremental/…/*.o: binary content), andcargo xtask policyfailed the same way. WithTMPDIRalso in the checkout,tempdir()had nowhere unseen left, because its fallback beside the test binary was visible too.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 aCACHEDIR.TAGwith Cargo's signature.build-outer/), is still read. The staged check is unchanged, so what a commit holds is still checked in full.unseen_by_full_checktreats that directory as unseen, so the fallback beside the test binary works again.build_directories_are_found_by_their_cache_tagcovers 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_overcovers 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 withTMPDIRinside the checkout. With the target directory in/tmpit is also 56/56.cargo clippy -p xtask --all-targets -- -D warningsandcargo fmt --checkare clean, andcargo xtask policyreports 154 files ok.Testing (Linux)
cargo test -p xtask -p victory-core: all pass, including every new test; also withGIT_INDEX_FILEandGIT_DIRpointing elsewhere, and with a hostileGIT_CONFIG_GLOBAL, withTMPDIRinside the checkout, withXDG_CONFIG_HOME/git/ignoreholding*.rs, and withGIT_QUARANTINE_PATHandGIT_TEST_ASSUME_DIFFERENT_OWNERset, 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; withblake3added it needs MSVC'slib.exefor blake3's C build, which this Linux machine lacks, so Windows CI covers it.rustfmt --checkon the touched files: clean.cargo xtask policy:asset policy: 152 files ok.A string of `\xHH` escapes was capped at 512 escapes in a row, but any string boundary ended the count: a Rust string continuation (`\` and a line break), C/HLSL adjacent literals, `concat!` arguments or an array of byte strings. An executable written as rows of 64 escapes passed whatever its length. Escapes now join across a boundary made only of quotes, commas, whitespace, `b"` and continuations, and `\u{..}` escapes count as well. Whitespace or a comma alone, inside one string, still ends a run.The escape-run check knew only \xHH and \u{..}. C, HLSL, Python and shell printf write bytes as octal (\115\132\220), and JSON, JavaScript, Java and Python as \uHHHH or \UHHHHHHHH; split into short strings, each under the printable-run limit, a file of them passed under the size limit. They now join the same 512-escape run.@jeremygold02 on GitHub · 2026-11-24 05:23 UTC · original
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 HEADandrustfmt --check --edition 2024 crates/victory-core/src/policy.rs xtask/src/main.rs xtask/src/policy.rs: passed. Workspace-widecargo fmt --all -- --checkemits formatting diffs in unrelated files.Unix-only cases were not exercised by this run, including
tracked_files_missing_from_disk_are_read_from_the_indexand the newtracked_files_are_read_as_indexed_as_wellregression (test), plus symlink, non-UTF-8 path, and submodule cases. Those tests are gated with#[cfg(unix)].@Marvisak on GitHub · 2026-11-25 00:23 UTC · original
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
Pull request closed