@@ -109,10 +109,10 @@ type RunOpts struct {
109109func CommonEnvs () []string {
110110 return []string {
111111 fmt .Sprintf ("LC_ALL=%s" , DefaultLocale ),
112- "GIT_TERMINAL_PROMPT=0" , // avoid prompting for credentials interactively, supported since git v2.3
113- "GIT_NO_REPLACE_OBJECTS=1" , // ignore replace references (https://git-scm.com/docs/git-replace)
114- "GIT_CONFIG_NOSYSTEM=1" , // https://git-scm.com/docs/git-config
115- "GIT_CONFIG_GLOBAL =" + GlobalConfigFile , // make Gitea use internal git config only, to prevent conflicts with user's git config
112+ "GIT_TERMINAL_PROMPT=0" , // avoid prompting for credentials interactively, supported since git v2.3
113+ "GIT_NO_REPLACE_OBJECTS=1" , // ignore replace references (https://git-scm.com/docs/git-replace)
114+ "GIT_CONFIG_NOSYSTEM=1" , // https://git-scm.com/docs/git-config, and GIT_CONFIG_GLOBAL, they require git >= 2.32
115+ "HOME =" + HomeDir , // make Gitea use internal git config only, to prevent conflicts with user's git config
116116 }
117117}
118118
@@ -160,12 +160,12 @@ func (c *Command) Run(opts *RunOpts) error {
160160 cmd .Env = opts .Env
161161 }
162162
163- if GlobalConfigFile == "" {
163+ if HomeDir == "" {
164164 // TODO: now, some unit test code call the git module directly without initialization, which is incorrect.
165- // at the moment, we just use a temp gitconfig to prevent from conflicting with user's gitconfig
165+ // at the moment, we just use a temp HomeDir to prevent from conflicting with user's git config
166166 // in future, the git module should be initialized first before use.
167- GlobalConfigFile = filepath .Join (os .TempDir (), "/gitea-temp-gitconfig " )
168- log .Warn ("GlobalConfigFile is empty, the git module is not initialized correctly, using a temp gitconfig (%s) temporarily" , GlobalConfigFile )
167+ HomeDir = filepath .Join (os .TempDir (), "/gitea-temp-home " )
168+ log .Warn ("Git's HomeDir is empty, the git module is not initialized correctly, using a temp HomeDir (%s) temporarily" , HomeDir )
169169 }
170170
171171 cmd .Env = append (cmd .Env , CommonEnvs ()... )
0 commit comments