Skip to content

Read Environment Config Per Git Command, Not by Index Across a Reading, in the Write Guard #3072

Closed

Description

@ptr727

Problem

_env_config_values in host-setup/agent-safety/claude/gh-write-guard.py pairs GIT_CONFIG_KEY_<n> with GIT_CONFIG_VALUE_<n> by index across every assignment _env_assignments returns for one reading. That covers the prefixes of every git word in the reading at once. A later git command reusing an index overwrites an earlier one's key.

Constructed case:

GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=alias.q GIT_CONFIG_VALUE_0=push git q origin develop; GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=core.pager GIT_CONFIG_VALUE_0=cat git log

The alias.q pair is replaced by core.pager, so the environment alias on the first command is never read, and the push it runs is not denied by _hidden_command.

Fix

Read the environment config per git word, from that word's own prefix plus the exports before it, rather than once per reading.

Found by a local review pass on the promotion fix for #3064. It is pre-existing on develop.

Activity

  1. added
    bug
    pre-existing
    script
    on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpre-existingscript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions