def _patch_git_config(name, value):
    """Temporarily add a git config name-value pair, using environment variables."""
    pair_index = int(os.getenv("GIT_CONFIG_COUNT", "0"))

    # This is recomputed each time the context is entered, for compatibility with
    # existing GIT_CONFIG_* environment variables, even if changed in this process.
    patcher = mock.patch.dict(
        os.environ,
        {
            "GIT_CONFIG_COUNT": str(pair_index + 1),
            f"GIT_CONFIG_KEY_{pair_index}": name,
            f"GIT_CONFIG_VALUE_{pair_index}": value,
        },
    )

    with patcher:
        yield
Temporarily add a git config name-value pair, using environment variables.
test/test_submodule.py