Skip to content

refactor(storage): centralize sanitized Git subprocess execution #4929

Description

@seekskyworld

Problem

Git subprocess setup is repeated across git-worktree-child-executor.ts, workspace-identity.ts, and project-catalog.ts. Each copy assembles -C, timeout, buffers, and a sanitized environment independently, while the worktree executor also maintains separate text and byte output wrappers. This is a security-sensitive boundary: an inherited GIT_DIR, GIT_WORK_TREE, or GIT_COMMON_DIR must never redirect a command away from the path being checked.

Scope

  • Add a storage-local Git execution helper for text and byte output.
  • Centralize removal of ambient repository-selection variables while retaining an explicit GIT_INDEX_FILE override for patch capture.
  • Migrate the three existing callers without changing their timeouts, buffer limits, arguments, or public errors.
  • Add a regression test that supplies poisoned Git environment variables and verifies commands still resolve the requested repository.

Acceptance criteria

  • All three callers use the same sanitized environment policy and no longer duplicate subprocess option assembly.
  • Text and binary output keep their existing encodings and size limits.
  • The poisoned-environment test passes on the supported host platforms.

This implements the Git execution wrapper slice identified by #1404.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions