|
33 | 33 | // DefaultContext is the default context to run git commands in, must be initialized by git.InitXxx
|
34 | 34 | DefaultContext context.Context
|
35 | 35 |
|
36 |
| - SupportProcReceive bool // >= 2.29 |
37 |
| - SupportHashSha256 bool // >= 2.42, SHA-256 repositories no longer an ‘experimental curiosity’ |
| 36 | + SupportProcReceive bool // >= 2.29 |
| 37 | + SupportHashSha256 bool // >= 2.42, SHA-256 repositories no longer an ‘experimental curiosity’ |
| 38 | + InvertedGitFlushEnv bool // 2.43.1 |
38 | 39 |
|
39 | 40 | gitVersion *version.Version
|
40 | 41 | )
|
@@ -192,6 +193,8 @@ func InitFull(ctx context.Context) (err error) {
|
192 | 193 | log.Warn("sha256 hash support is disabled - requires Git >= 2.42. Gogit is currently unsupported")
|
193 | 194 | }
|
194 | 195 |
|
| 196 | + InvertedGitFlushEnv = CheckGitVersionEqual("2.43.1") == nil |
| 197 | + |
195 | 198 | if setting.LFS.StartServer {
|
196 | 199 | if CheckGitVersionAtLeast("2.1.2") != nil {
|
197 | 200 | return errors.New("LFS server support requires Git >= 2.1.2")
|
@@ -320,6 +323,21 @@ func CheckGitVersionAtLeast(atLeast string) error {
|
320 | 323 | return nil
|
321 | 324 | }
|
322 | 325 |
|
| 326 | +// CheckGitVersionEqual checks if the git version is equal to the constraint version. |
| 327 | +func CheckGitVersionEqual(equal string) error { |
| 328 | + if _, err := loadGitVersion(); err != nil { |
| 329 | + return err |
| 330 | + } |
| 331 | + atLeastVersion, err := version.NewVersion(equal) |
| 332 | + if err != nil { |
| 333 | + return err |
| 334 | + } |
| 335 | + if !gitVersion.Equal(atLeastVersion) { |
| 336 | + return fmt.Errorf("installed git binary version %s is not equal to %s", gitVersion.Original(), equal) |
| 337 | + } |
| 338 | + return nil |
| 339 | +} |
| 340 | + |
323 | 341 | func configSet(key, value string) error {
|
324 | 342 | stdout, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key).RunStdString(nil)
|
325 | 343 | if err != nil && !err.IsExitCode(1) {
|
|
0 commit comments