enhance!: raise minimum git version to 2.34 (#39565)

Raise the minimum git version to 2.34, the version in Ubuntu 22.04,
Debian 12 and RHEL 8 ship newer, and remove the fallbacks it makes
obsolete.

- Always enable AGit
- Use `diff --skip-to` and `apply -3` unconditionally
- Set the default branch of new repos and wikis via `git init
--initial-branch`
- Detect rebase conflicts via `REBASE_HEAD`
This commit is contained in:
silverwind authored and GitHub committed 2026-10-04 16:26:14 +08:00
1 parent 4bebd86285
commit eb4468ff4e
38 files changed
+177 -404

No files matched your search

+4 -7
View File
@@ -144,15 +144,16 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir
// InitRepository initializes README and .gitignore if needed.
func initRepository(ctx context.Context, u *user_model.User, repo *repo_model.Repository, opts CreateRepoOptions) (err error) {
repo.DefaultBranch = util.IfZero(opts.DefaultBranch, setting.Repository.DefaultBranch)
repo.DefaultWikiBranch = setting.Repository.DefaultBranch
// Init git bare new repository.
if err = git.InitRepository(ctx, repo, repo.ObjectFormatName); err != nil {
if err = git.InitRepository(ctx, repo, repo.ObjectFormatName, repo.DefaultBranch); err != nil {
return fmt.Errorf("git.InitRepository: %w", err)
} else if err = git.CreateDelegateHooks(ctx, repo); err != nil {
return fmt.Errorf("createDelegateHooks: %w", err)
}
repo.DefaultBranch = util.IfZero(opts.DefaultBranch, setting.Repository.DefaultBranch)
repo.DefaultWikiBranch = setting.Repository.DefaultBranch
if !opts.AutoInit {
repo.IsEmpty = true
}
@@ -179,10 +180,6 @@ func initRepository(ctx context.Context, u *user_model.User, repo *repo_model.Re
}
}
if err = git.SetDefaultBranch(ctx, repo, repo.DefaultBranch); err != nil {
return fmt.Errorf("setDefaultBranch: %w", err)
}
// Re-fetch the repository from database before updating it (keep changes that were done earlier with SQL)
if repo, err = repo_model.GetRepositoryByID(ctx, repo.ID); err != nil {
return fmt.Errorf("getRepositoryByID: %w", err)