Repository navigation
fix(hooks): pass the git overrides to the end-of-turn git-hook entries - #17274
Conversation
Eight end-of-turn hooks start their plugin's git-hook entry with --worktree as a separate bash process. It never loads hook-utils.sh, so check-lib.sh and the adapters ran git without the overrides and read the index, which starts the command the repository's core.fsmonitor names. hook-utils.sh keeps the override list in HOOK_GIT_UNTRUSTED_CONFIG. Both hook::git_untrusted (as -c arguments) and the new hook::git_untrusted_env (as GIT_CONFIG_COUNT / GIT_CONFIG_KEY_n / GIT_CONFIG_VALUE_n, appended after any pairs the caller set) are built from it. Each of the eight hooks calls hook::git_untrusted_env in the child's subshell before starting the entry. actionlint and powershell-format now carry a hook-utils.sh copy. Refs: #16959 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…an-root probe worktree-root-resolve.sh, which the worktree-add containment gate sources, ran its config and rev-parse calls with plain `command git`. It now calls hook::git_untrusted when hook-utils.sh is loaded and no _worktree_root_git is defined; the fleet audit's read-only wrapper keeps priority, and the gate's retired-alias rewrite still runs. hpp::resolve_scan_root keeps its exec git and takes its arguments from the same override list. Refs: #16959 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Owner of this pull request: the control-hub session for plugin profiles (melodic-software/control-hub#11). It waits on CI Status and the review lanes; the hub reads the reviews and merges. Other sessions: do not push, resolve threads or queue it. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
claude-security-review reviewed Security review: incremental (872952b → 754f063)I found no security issues in this push. I read all six files on the to-read list, every hunk, in What I checked
Instruction-surface lens: the only lines this push removes are two Spend: none. Nothing in this push changes lane runs, models or billing. critical-findings: 0 |
|
claude-review reviewed Code review (incremental, 872952b → 754f063)No findings. This lane already reviewed an earlier head, so this pass reported blocking findings only. I read all 6 files on the to-read list in What changed
Prior findingThe loosened-check finding on Other checks
Verifier dropped 0 of 0 candidates. |
hpp::resolve_scan_root read hook-utils.sh's override array directly, which needed an SC2154 suppression. hook-utils.sh now defines hook::git_untrusted_exec, which execs git with the same arguments, so the scan root lookup still costs one process and the override list keeps one definition. The two git shims in lib/hook-git.test.sh write each `$` as the printf escape \044 in place of a single-quoted literal, so SC2016 has nothing to flag. Refs: #16959 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Closes #16959
Summary
Eight end-of-turn hooks start their plugin's git-hook entry (
git-hooks/lint.sh --worktree, orformat.sh --worktreefor go-format) as a separate bash process:actionlint-check.sh,bash-format.sh,go-format.sh,javascript-format.sh,markdown-format.sh,powershell-format.sh,python-format.shandspelling.sh. That process never loadshook-utils.sh, socheck-lib.shand the adapters ran git without the overrides, and theirls-filesanddiffcalls read the index. Reading the index starts the command the repository'score.fsmonitornames. As the hub session decided on the issue, the hook now passes the overrides to the child through git's config environment variables.Fix
lib/hook-utils.shkeeps the override list once, inHOOK_GIT_UNTRUSTED_CONFIG(core.fsmonitor=false,core.hooksPath=/dev/null).hook::git_untrustedbuilds its-carguments from it, and the newhook::git_untrusted_envexports it asGIT_CONFIG_COUNT/GIT_CONFIG_KEY_n/GIT_CONFIG_VALUE_n. When the caller already setGIT_CONFIG_COUNT, the pairs are appended after the existing ones and none is overwritten. A count that is not a non-negative integer returns 1 and changes nothing (git itself refuses such a count).hook-utils.shin its end-of-turn branch. It runshook::git_untrusted_envinside the command substitution that starts the entry, so the variables reach only that child.spelling.shexits right after its entry, so it exports them in its own process.hook-utils.shcopy (scripts/shared-copies.txt).scripts/sync-shared-copies.shregenerated all 24 copies.worktree-add-containment-gate.shdefines_worktree_root_gitashook::git_untrusted. Theworktree-root-resolve.shit sources already calls that hook when it is defined (worktree_root_git). The gate's worktree-root lookups (config --get-all,rev-parse --git-dir) ran plaincommand gitbefore.hardcoded-path-patterns.sh,hpp::resolve_scan_rootkeeps itsexec git(one process) and takes its arguments from the same list ("${_HOOK_GIT_UNTRUSTED_ARGS[@]}").patchfragment perhook-utils.shcarrier (24).Git versions and paging
git help config, ENVIRONMENT (git 2.53.0 on this machine): "If GIT_CONFIG_COUNT is set to a positive number, all environment pairs GIT_CONFIG_KEY_ and GIT_CONFIG_VALUE_ up to that number will be added to the process's runtime configuration ... These environment variables will override values in configuration files, but will be overridden by any explicit options passed via git -c."RelNotes/2.31.0.adoc:127-130) say: "Two new ways to feed configuration variable-value pairs via environment variables have been introduced". The ENVIRONMENT section of git-config 2.30.0 lists onlyGIT_CONFIGandGIT_CONFIG_NOSYSTEM; 2.31.0 addsGIT_CONFIG_COUNT,GIT_CONFIG_KEY_<n>andGIT_CONFIG_VALUE_<n>. An older git does not know them, so the child runs as it did before this change, with no override. That reading was not run against a pre-2.31 git.--no-pagerhas no configuration-variable form. The child never pages because git pages only when its standard output is a terminal.git help git,--paginate: "Pipe all output into less (or if set, $PAGER) if standard output is a terminal." Each hook starts its entry with standard output on/dev/null(2>&1 >/dev/null, or>/dev/nullinspelling.sh). Every git the entry starts therefore writes to that, to a pipe or to a command substitution, never to a terminal.Verification
lib/hook-git.test.shadds these cases:core.fsmonitorstarts it. This proves the hook case below exercises an index read.--end-of-turnrun, which must not start the planted fsmonitor.GIT_CONFIG_COUNT=2for the entry's git calls. This proves the entry ran git and received the variables.GIT_CONFIG_COUNT=1pair survives and the overrides follow it.scripts/affected-tests.sh --runover the first commit:worktree-add-containment-gate.test.shcases 40-41 failed with the first attempt. That attempt defined_worktree_root_gitin the gate, which makes the legacy-alias helper treat the gate as read-only. The second commit moves the change intoworktree-root-resolve.shinstead, and the suite now passes 48/48.worktree-gates-spawn-budget.test.shpasses.node_modulesinstalled:check-script-contract(htmlhint missing),graphql-operations(module not found),write-runner-hold-labelsandwrite-runner-never-rules(runner-policy not installed).hardcoded-path-check.test.sh173/0 andblock-github-post-content.test.sh199/0 after the scan-root change.shellcheck -xclean on every changed shell file;check-changelog-fragments.sh --checkpasses; the pre-pushcheck-affectedpassed.plugins/*/hooks/**, in the libraries hooks source, or in the scripts hooks start runs without the overrides, other than the two items below that the issue comment leaves on purpose.plugins/testing/hooks/judge-lib.shis not loaded by any hook.Related
worktree-create.shdoes not passcore.hooksPath=/dev/nulltogit worktree add.filter.<driver>.clean) cannot be turned off with-c.🤖 Generated with Claude Code