Skip to content

Commit

Permalink
Improve git version check for safe.directory
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Jun 17, 2022
1 parent 488658d commit 0720b17
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions modules/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,17 @@ func syncGitConfig() (err error) {
}
}

//
// Disable the security check because Gitea runs the git CLI from within the
// repository. See https://github.com/go-gitea/gitea/issues/19455 for the full discussion.
//
if err := configAddNonExist("safe.directory", "*"); err != nil {
return err
// safe.directory accept * was introduced in https://github.com/git/git/blob/main/Documentation/RelNotes/2.30.4.txt
if CheckGitVersionAtLeast("2.30.4") == nil {
if err := configAddNonExist("safe.directory", "*"); err != nil {
return err
}
} else {
if err := configSet("safe.directory", setting.RepoRootPath); err != nil {
return err
}
}

if runtime.GOOS == "windows" {
Expand Down

0 comments on commit 0720b17

Please sign in to comment.