Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2023-04-24 10:02:34 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-04-24 10:02:34 +0300
commit91a0ebe01b03c9aa97861f68bef0a0ab2a4f66ee (patch)
treefb3418a922cc9946f5a6895fac6de39e4a64cc9a
parent1e3fdcecbce114fc39878d1932ae46a5a87fddc4 (diff)
git: Unconditionally ignore gitconfig files
A while ago we have introduced the `ignore_gitconfig` configuration. If set, we will override GIT_CONFIG_SYSTEM and GIT_CONFIG_GLOBAL as well as override XDG_CONFIG_HOME so that Git won't pick up gitconfig files found in any of these scopes. The goal of this is that we only ever use the Git configuration that is found either in Gitaly's `config.toml` or in the repository-local gitconfig. This toggle has been enabled in all distributions unconditionally already and was scheduled for removal in v16.0. So let's remove that toggle and unconditionally ignore any global- or system-level gitconfig files. Changelog: removed
-rw-r--r--_support/benchmarking/roles/gitaly/templates/config.toml.j21
-rw-r--r--config.toml.example7
-rw-r--r--internal/git/command_factory.go21
-rw-r--r--internal/git/command_factory_test.go30
-rw-r--r--internal/git/command_options_test.go7
-rw-r--r--internal/git/gittest/testhelper_test.go1
-rw-r--r--internal/gitaly/config/config.go1
-rw-r--r--internal/testhelper/testcfg/gitaly.go3
8 files changed, 11 insertions, 60 deletions
diff --git a/_support/benchmarking/roles/gitaly/templates/config.toml.j2 b/_support/benchmarking/roles/gitaly/templates/config.toml.j2
index f5a43907a..75b912c42 100644
--- a/_support/benchmarking/roles/gitaly/templates/config.toml.j2
+++ b/_support/benchmarking/roles/gitaly/templates/config.toml.j2
@@ -27,7 +27,6 @@ prometheus_listen_addr = "127.0.0.1:9236"
[git]
use_bundled_binaries = true
catfile_cache_size = 10
-ignore_gitconfig = true
[[storage]]
name = "default"
diff --git a/config.toml.example b/config.toml.example
index aa434f288..019a9e811 100644
--- a/config.toml.example
+++ b/config.toml.example
@@ -38,13 +38,6 @@ bin_dir = "/home/git/gitaly/_build/bin"
# bin_path = "/usr/bin/git"
# catfile_cache_size = 100
#
-# # Set this setting to `true` to start ignoring gitconfig files installed in
-# # the system. This includes both system-level (e.g. '/etc/gitconffig') and
-# # global-level (e.g. `$HOME/.gitconfig`) files. This setting will become the
-# # default with v16.0. If you intend to override Git configuration you can do
-# # so via `[[git.config]]`. The default value is `false`.
-# ignore_gitconfig = false
-#
# [[git.config]]
# key = fetch.fsckObjects
# value = true
diff --git a/internal/git/command_factory.go b/internal/git/command_factory.go
index 49df94505..dcf5d7c9d 100644
--- a/internal/git/command_factory.go
+++ b/internal/git/command_factory.go
@@ -196,19 +196,14 @@ func setupGitExecutionEnvironments(cfg config.Cfg, factoryCfg execCommandFactory
"LANG=en_US.UTF-8",
// Ask Git to never prompt us for any information like e.g. credentials.
"GIT_TERMINAL_PROMPT=0",
- }
-
- // Prevent the environment from affecting git calls by ignoring the configuration files.
- // This should be done always but we have to wait until 15.0 due to backwards compatibility
- // concerns.
- //
- // See https://gitlab.com/gitlab-org/gitaly/-/issues/3617.
- if cfg.Git.IgnoreGitconfig {
- sharedEnvironment = append(sharedEnvironment,
- "GIT_CONFIG_GLOBAL=/dev/null",
- "GIT_CONFIG_SYSTEM=/dev/null",
- "XDG_CONFIG_HOME=/dev/null",
- )
+ // Prevent the environment from affecting git calls by ignoring the configuration files.
+ // This should be done always but we have to wait until 15.0 due to backwards compatibility
+ // concerns.
+ //
+ // See https://gitlab.com/gitlab-org/gitaly/-/issues/3617.
+ "GIT_CONFIG_GLOBAL=/dev/null",
+ "GIT_CONFIG_SYSTEM=/dev/null",
+ "XDG_CONFIG_HOME=/dev/null",
}
if factoryCfg.gitBinaryPath != "" {
diff --git a/internal/git/command_factory_test.go b/internal/git/command_factory_test.go
index 2b16f32a6..f234bbb8c 100644
--- a/internal/git/command_factory_test.go
+++ b/internal/git/command_factory_test.go
@@ -239,26 +239,10 @@ func TestCommandFactory_ExecutionEnvironment(t *testing.T) {
require.Equal(t, expectedExecEnv.EnvironmentVariables, actualExecEnv.EnvironmentVariables)
}
- t.Run("set in config without ignored gitconfig", func(t *testing.T) {
- assertExecEnv(t, config.Cfg{
- Git: config.Git{
- BinPath: "/path/to/myGit",
- IgnoreGitconfig: false,
- },
- }, git.ExecutionEnvironment{
- BinaryPath: "/path/to/myGit",
- EnvironmentVariables: []string{
- "LANG=en_US.UTF-8",
- "GIT_TERMINAL_PROMPT=0",
- },
- })
- })
-
t.Run("set in config", func(t *testing.T) {
assertExecEnv(t, config.Cfg{
Git: config.Git{
- BinPath: "/path/to/myGit",
- IgnoreGitconfig: true,
+ BinPath: "/path/to/myGit",
},
}, git.ExecutionEnvironment{
BinaryPath: "/path/to/myGit",
@@ -275,11 +259,7 @@ func TestCommandFactory_ExecutionEnvironment(t *testing.T) {
t.Run("set using GITALY_TESTING_GIT_BINARY", func(t *testing.T) {
t.Setenv("GITALY_TESTING_GIT_BINARY", "/path/to/env_git")
- assertExecEnv(t, config.Cfg{
- Git: config.Git{
- IgnoreGitconfig: true,
- },
- }, git.ExecutionEnvironment{
+ assertExecEnv(t, config.Cfg{}, git.ExecutionEnvironment{
BinaryPath: "/path/to/env_git",
EnvironmentVariables: []string{
"NO_SET_GIT_TEMPLATE_DIR=YesPlease",
@@ -453,11 +433,7 @@ func TestCommandFactory_ExecutionEnvironment(t *testing.T) {
resolvedPath, err := exec.LookPath("git")
require.NoError(t, err)
- assertExecEnv(t, config.Cfg{
- Git: config.Git{
- IgnoreGitconfig: true,
- },
- }, git.ExecutionEnvironment{
+ assertExecEnv(t, config.Cfg{}, git.ExecutionEnvironment{
BinaryPath: resolvedPath,
EnvironmentVariables: []string{
"LANG=en_US.UTF-8",
diff --git a/internal/git/command_options_test.go b/internal/git/command_options_test.go
index 7d0a81160..2c1ae03b8 100644
--- a/internal/git/command_options_test.go
+++ b/internal/git/command_options_test.go
@@ -194,9 +194,6 @@ func TestGlobalOption(t *testing.T) {
func TestWithConfig(t *testing.T) {
cfg := config.Cfg{
BinDir: testhelper.TempDir(t),
- Git: config.Git{
- IgnoreGitconfig: true,
- },
}
ctx := testhelper.Context(t)
@@ -274,7 +271,6 @@ func TestExecCommandFactoryGitalyConfigOverrides(t *testing.T) {
Config: []config.GitConfig{
{Key: "foo.bar", Value: "from-gitaly-config"},
},
- IgnoreGitconfig: true,
},
}
@@ -300,9 +296,6 @@ func TestExecCommandFactoryGitalyConfigOverrides(t *testing.T) {
func TestWithConfigEnv(t *testing.T) {
cfg := config.Cfg{
BinDir: testhelper.TempDir(t),
- Git: config.Git{
- IgnoreGitconfig: true,
- },
}
ctx := testhelper.Context(t)
diff --git a/internal/git/gittest/testhelper_test.go b/internal/git/gittest/testhelper_test.go
index a06fbc44c..5f01bb2fa 100644
--- a/internal/git/gittest/testhelper_test.go
+++ b/internal/git/gittest/testhelper_test.go
@@ -27,7 +27,6 @@ func setup(tb testing.TB) (config.Cfg, *gitalypb.Repository, string) {
var cfg config.Cfg
cfg.SocketPath = "it is a stub to bypass Validate method"
- cfg.Git.IgnoreGitconfig = true
cfg.Storages = []config.Storage{
{
diff --git a/internal/gitaly/config/config.go b/internal/gitaly/config/config.go
index 1081c71f6..7efafa1bc 100644
--- a/internal/gitaly/config/config.go
+++ b/internal/gitaly/config/config.go
@@ -229,7 +229,6 @@ type Git struct {
BinPath string `toml:"bin_path,omitempty" json:"bin_path"`
CatfileCacheSize int `toml:"catfile_cache_size,omitempty" json:"catfile_cache_size"`
Config []GitConfig `toml:"config,omitempty" json:"config"`
- IgnoreGitconfig bool `toml:"ignore_gitconfig,omitempty" json:"ignore_gitconfig"`
SigningKey string `toml:"signing_key,omitempty" json:"signing_key"`
}
diff --git a/internal/testhelper/testcfg/gitaly.go b/internal/testhelper/testcfg/gitaly.go
index 572030371..e037e602e 100644
--- a/internal/testhelper/testcfg/gitaly.go
+++ b/internal/testhelper/testcfg/gitaly.go
@@ -125,9 +125,6 @@ func (gc *GitalyCfgBuilder) Build(tb testing.TB) config.Cfg {
}
cfg.PackObjectsCache.Enabled = gc.packObjectsCacheEnabled
- // Ignore the gitconfig so that tests aren't impacted by any configuration the user happens
- // to have lying around.
- cfg.Git.IgnoreGitconfig = true
// The tests don't require GitLab API to be accessible, but as it is required to pass
// validation, so the artificial values are set to pass.