gitenv

package
v9.17.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearedEnv

func ClearedEnv() []string

ClearedEnv returns os.Environ() with repo-scoping git environment variables removed. Preserves all other environment variables, including authentication config (GIT_SSH_COMMAND, GIT_ASKPASS, SSH_AUTH_SOCK), PATH, HOME, and locale settings.

Why: issue #81 — an inherited GIT_DIR, GIT_WORK_TREE, or similar repo-scoping variable in the caller's environment causes nested git invocations (in templates fetching or migration operations) to inadvertently write to the caller's repository instead of their intended targets. ClearedEnv() creates a clean environment for git commands that respects the explicit repository scope (passed via -C, etc.) without inheriting caller's repo context.

func ScopingVars

func ScopingVars() []string

ScopingVars returns the names of the repo-scoping git variables ClearedEnv removes.

ClearedEnv covers the common case — a git subprocess that must target its own directory. A caller that instead needs its OWN process to stop inheriting the caller's repository (a test fixture, or any code re-entered from a git hook, which git always invokes with GIT_DIR and GIT_INDEX_FILE exported) has to unset the names itself; this is that list, so the two never drift apart.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL