aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git')
-rw-r--r--modules/git/command.go12
-rw-r--r--modules/git/repo_archive.go5
2 files changed, 9 insertions, 8 deletions
diff --git a/modules/git/command.go b/modules/git/command.go
index b231c3beea..2584e3cc57 100644
--- a/modules/git/command.go
+++ b/modules/git/command.go
@@ -236,10 +236,16 @@ type RunOpts struct {
}
func commonBaseEnvs() []string {
- // at the moment, do not set "GIT_CONFIG_NOSYSTEM", users may have put some configs like "receive.certNonceSeed" in it
envs := []string{
- "HOME=" + HomeDir(), // make Gitea use internal git config only, to prevent conflicts with user's git config
- "GIT_NO_REPLACE_OBJECTS=1", // ignore replace references (https://git-scm.com/docs/git-replace)
+ // Make Gitea use internal git config only, to prevent conflicts with user's git config
+ // It's better to use GIT_CONFIG_GLOBAL, but it requires git >= 2.32, so we still use HOME at the moment.
+ "HOME=" + HomeDir(),
+ // Avoid using system git config, it would cause problems (eg: use macOS osxkeychain to show a modal dialog, auto installing lfs hooks)
+ // This might be a breaking change in 1.24, because some users said that they have put some configs like "receive.certNonceSeed" in "/etc/gitconfig"
+ // For these users, they need to migrate the necessary configs to Gitea's git config file manually.
+ "GIT_CONFIG_NOSYSTEM=1",
+ // Ignore replace references (https://git-scm.com/docs/git-replace)
+ "GIT_NO_REPLACE_OBJECTS=1",
}
// some environment variables should be passed to git command
diff --git a/modules/git/repo_archive.go b/modules/git/repo_archive.go
index 1bf1aa41b9..2b45a50f19 100644
--- a/modules/git/repo_archive.go
+++ b/modules/git/repo_archive.go
@@ -8,7 +8,6 @@ import (
"context"
"fmt"
"io"
- "os"
"path/filepath"
"strings"
)
@@ -63,15 +62,11 @@ func (repo *Repository) CreateArchive(ctx context.Context, format ArchiveType, t
cmd.AddOptionFormat("--format=%s", format.String())
cmd.AddDynamicArguments(commitID)
- // Avoid LFS hooks getting installed because of /etc/gitconfig, which can break pull requests.
- env := append(os.Environ(), "GIT_CONFIG_NOSYSTEM=1")
-
var stderr strings.Builder
err := cmd.Run(&RunOpts{
Dir: repo.Path,
Stdout: target,
Stderr: &stderr,
- Env: env,
})
if err != nil {
return ConcatenateError(err, stderr.String())