forgejo/modules/setting/git_test.go
Gusted ebfac19123 chore: remove some git configuration options (#12681)
`ENABLE_AUTO_GIT_WIRE_PROTOCOL`:

Its sole usage is to set `-c protocol.version=2` on each git command
execution. The default value is already 2 since at least the minimum
version of Git that Forgejo requires. When this setting was added, this
was not the case.

Thus, automatically defaulting to protocol v2 is already the case due to
git themselves making it the default. And instances that want to use a
older protocol already have to override the value like:

```ini
[git.config]
protocol.version=1
```

---

`git.reflog` was deprecated in v1.21 warnings have been emitted. Remove it finally.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12681
Reviewed-by: limiting-factor <limiting-factor@noreply.codeberg.org>
2026-05-24 12:34:59 +02:00

48 lines
1.1 KiB
Go

// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package setting
import (
"testing"
"forgejo.org/modules/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGitConfig(t *testing.T) {
defer test.MockProtect(&Git)()
defer test.MockProtect(&GitConfig)()
cfg, err := NewConfigProviderFromData(`
[git.config]
a.b = 1
`)
require.NoError(t, err)
loadGitFrom(cfg)
assert.Equal(t, "1", GitConfig.Options["a.b"])
assert.Equal(t, "histogram", GitConfig.Options["diff.algorithm"])
cfg, err = NewConfigProviderFromData(`
[git.config]
diff.algorithm = other
`)
require.NoError(t, err)
loadGitFrom(cfg)
assert.Equal(t, "other", GitConfig.Options["diff.algorithm"])
}
func TestGitReflog(t *testing.T) {
defer test.MockProtect(&Git)()
defer test.MockProtect(&GitConfig)()
// default reflog config.
cfg, err := NewConfigProviderFromData(``)
require.NoError(t, err)
loadGitFrom(cfg)
assert.Equal(t, "true", GitConfig.GetOption("core.logAllRefUpdates"))
assert.Equal(t, "90", GitConfig.GetOption("gc.reflogExpire"))
}