Skip to content

GIT_CONFIG_SYSTEM and GIT_CONFIG_GLOBAL are not supported #1701

@mdelapenya

Description

@mdelapenya

Bug Description

I'm testing some git capabilities writing tests, and I'd like to avoid writing to the user system. For that, git is aware of GIT_CONFIG_SYSTEM and GIT_CONFIG_GLOBAL to avoid messing up with that.

These env vars are not used by the library, which could be handy for testing purposes.

go-git Version

5.11.0

Steps to Reproduce

This shell script works verifies it:

tmpdir="$(mktemp -d)"
export GIT_CONFIG_SYSTEM="$tmpdir/system.gitconfig"
export GIT_CONFIG_GLOBAL=/dev/null
export XDG_CONFIG_HOME="$tmpdir/xdg"
export HOME="$tmpdir/home"
mkdir -p "$tmpdir/xdg" "$tmpdir/home"

# Write “system” config safely without sudo:
git config --system user.name "Test System User"
git config --system user.email "[email protected]"

# Verify precedence works as expected:
git config --list --show-origin

# ...run your test commands here...

rm -rf "$tmpdir"

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions