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

+2 -6
View File
@@ -178,12 +178,8 @@ func ApplyDiffPatch(ctx reqctx.RequestContext, repo *repo_model.Repository, doer
}
defer t.Close()
cmdApply := gitcmd.NewCommand("apply", "--index", "--recount", "--cached", "--ignore-whitespace", "--whitespace=fix", "--binary")
if git.DefaultFeatures().CheckVersionAtLeast("2.32") {
cmdApply.AddArguments("-3")
}
if err := cmdApply.WithRepo(t.gitRepo).
if err := gitcmd.NewCommand("apply", "--index", "--recount", "--cached", "--ignore-whitespace", "--whitespace=fix", "--binary", "-3").
WithRepo(t.gitRepo).
WithStdinBytes([]byte(opts.Content)).
RunWithStderr(ctx); err != nil {
return nil, fmt.Errorf("git apply error: %w", err)
+2 -2
View File
@@ -86,7 +86,7 @@ func (t *TemporaryUploadRepository) Clone(ctx context.Context, branch string, ba
// Init the repository
func (t *TemporaryUploadRepository) Init(ctx context.Context, objectFormatName string) error {
if err := git.InitRepositoryLocal(ctx, t.basePath, false, objectFormatName); err != nil {
if err := git.InitRepositoryLocal(ctx, t.basePath, false, objectFormatName, ""); err != nil {
return err
}
gitRepo, err := git.OpenRepositoryLocal(ctx, t.basePath)
@@ -363,7 +363,7 @@ func (t *TemporaryUploadRepository) DiffIndex(ctx context.Context, oldContent, n
WithRepo(t.gitRepo).
WithPipelineFunc(func(ctx gitcmd.Context) error {
var diffErr error
diff, diffErr = gitdiff.ParsePatch(ctx, setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, stdoutReader, "")
diff, diffErr = gitdiff.ParsePatch(ctx, setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, stdoutReader)
if diffErr != nil {
// if the diffErr is not nil, it will be returned as the error of "Run()"
return fmt.Errorf("ParsePatch: %w", diffErr)