Skip to content

Commit 0720b17

Browse files
committed
Improve git version check for safe.directory
1 parent 488658d commit 0720b17

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

modules/git/git.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,17 @@ func syncGitConfig() (err error) {
251251
}
252252
}
253253

254-
//
255254
// Disable the security check because Gitea runs the git CLI from within the
256255
// repository. See https://github.com/go-gitea/gitea/issues/19455 for the full discussion.
257-
//
258-
if err := configAddNonExist("safe.directory", "*"); err != nil {
259-
return err
256+
// safe.directory accept * was introduced in https://github.com/git/git/blob/main/Documentation/RelNotes/2.30.4.txt
257+
if CheckGitVersionAtLeast("2.30.4") == nil {
258+
if err := configAddNonExist("safe.directory", "*"); err != nil {
259+
return err
260+
}
261+
} else {
262+
if err := configSet("safe.directory", setting.RepoRootPath); err != nil {
263+
return err
264+
}
260265
}
261266

262267
if runtime.GOOS == "windows" {

0 commit comments

Comments
 (0)