mirror of
https://github.com/go-gitea/gitea.git
synced 2026-12-03 21:32:25 -06:00
Gitea supports git 2.34 and newer, but with git 2.34.1 `go test ./modules/git/` panics in `TestReadingBlameOutput/sha256` (nil pointer dereference), which aborts the rest of the package, and `services/pull` fails its `*-MergeTree` cases with `exit status 129`. These tests use sha256 repositories, `cat-file --batch-command` and `merge-tree --write-tree`, which production code only uses when `DefaultFeatures()` says git is new enough (2.42, 2.36 and 2.40). Those cases now skip on the same `DefaultFeatures()` flags, as the check-attr tests in `modules/git/attribute` already do. With git 2.34.1 both packages failed before; now they pass with those cases skipped, and `make test-backend` passes as a whole. With git 2.42.0, 2.43.0 and 2.56.1 nothing is skipped; with 2.41.3 only the sha256 cases are. Related: https://github.com/go-gitea/gitea/pull/39565 Assisted-by: Hermes Agent:claude-opus-5-5
86 lines
1.9 KiB
Go
86 lines
1.9 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package git
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"gitea.dev/modules/git/gitcmd"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func prepareRepoDirRenameConflict(t *testing.T) string {
|
|
repoDir := filepath.Join(t.TempDir(), "repo-dir-rename-conflict.git")
|
|
require.NoError(t, gitcmd.NewCommand("init", "--bare").AddDynamicArguments(repoDir).RunWithStderr(t.Context()))
|
|
stdin := `blob
|
|
mark :1
|
|
data 2
|
|
b
|
|
|
|
blob
|
|
mark :2
|
|
data 2
|
|
c
|
|
|
|
reset refs/heads/master
|
|
commit refs/heads/master
|
|
mark :3
|
|
author test <test@example.com> 1769202331 -0800
|
|
committer test <test@example.com> 1769202331 -0800
|
|
data 2
|
|
O
|
|
M 100644 :1 z/b
|
|
M 100644 :2 z/c
|
|
|
|
commit refs/heads/split
|
|
mark :4
|
|
author test <test@example.com> 1769202336 -0800
|
|
committer test <test@example.com> 1769202336 -0800
|
|
data 2
|
|
A
|
|
from :3
|
|
M 100644 :2 w/c
|
|
M 100644 :1 y/b
|
|
D z/b
|
|
D z/c
|
|
|
|
blob
|
|
mark :5
|
|
data 2
|
|
d
|
|
|
|
commit refs/heads/add
|
|
mark :6
|
|
author test <test@example.com> 1769202342 -0800
|
|
committer test <test@example.com> 1769202342 -0800
|
|
data 2
|
|
B
|
|
from :3
|
|
M 100644 :5 z/d
|
|
`
|
|
require.NoError(t, gitcmd.NewCommand("fast-import").WithDir(repoDir).WithStdinBytes([]byte(stdin)).RunWithStderr(t.Context()))
|
|
return repoDir
|
|
}
|
|
|
|
func TestMergeTreeDirectoryRenameConflictWithoutFiles(t *testing.T) {
|
|
if !DefaultFeatures().SupportGitMergeTree {
|
|
t.Skip("git version 2.40 is required to support merge-tree")
|
|
}
|
|
repoDir := prepareRepoDirRenameConflict(t)
|
|
require.DirExists(t, repoDir)
|
|
repo := mockRepository(repoDir)
|
|
|
|
mergeBase, err := MergeBase(t.Context(), repo, "add", "split")
|
|
require.NoError(t, err)
|
|
|
|
treeID, conflicted, conflictedFiles, err := MergeTree(t.Context(), repo, "add", "split", mergeBase)
|
|
require.NoError(t, err)
|
|
assert.True(t, conflicted)
|
|
assert.Empty(t, conflictedFiles)
|
|
assert.Equal(t, "5e3dd4cfc5b11e278a35b2daa83b7274175e3ab1", treeID)
|
|
}
|