Use a private gitconfig file

This was changing my own ~/.gitconfig whenever run by hand outside of a
container.  Oops.
This commit is contained in:
Tim Hockin 2023-02-19 10:14:27 -08:00
parent 026c6814c8
commit b36c6851a2
1 changed files with 12 additions and 0 deletions

View File

@ -555,6 +555,18 @@ func main() {
}
}
// Don't pollute the user's .gitconfig if this is being run directly.
if f, err := os.CreateTemp("", "git-sync.gitconfig.*"); err != nil {
log.Error(err, "ERROR: can't create gitconfig file")
os.Exit(1)
} else {
gitConfig := f.Name()
f.Close()
os.Setenv("GIT_CONFIG_GLOBAL", gitConfig)
os.Setenv("GIT_CONFIG_NOSYSTEM", "true")
log.V(2).Info("created private gitconfig file", "path", gitConfig)
}
// Capture the various git parameters.
git := &repoSync{
cmd: *flGitCmd,