ref: d88c8e20aebd9408df0306e97dffc2896950342d
parent: 5d84c4a2716c9dec5f9fcfcce4ca7f8a65cad3ff
author: Runxi Yu <me@runxiyu.org>
date: Fri Feb 20 17:59:14 EST 2026
*: Replace repo with testRepo
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -11,9 +11,9 @@
"codeberg.org/lindenii/furgit/objectid"
)
-func openConfig(t *testing.T, repo *testgit.TestRepo) *os.File {+func openConfig(t *testing.T, testRepo *testgit.TestRepo) *os.File {t.Helper()
- cfgFile, err := os.Open(filepath.Join(repo.Dir(), "config"))
+ cfgFile, err := os.Open(filepath.Join(testRepo.Dir(), "config"))
if err != nil { t.Fatalf("failed to open config: %v", err)}
@@ -20,20 +20,20 @@
return cfgFile
}
-func gitConfigGet(t *testing.T, repo *testgit.TestRepo, key string) string {+func gitConfigGet(t *testing.T, testRepo *testgit.TestRepo, key string) string {t.Helper()
- return repo.Run(t, "config", "--get", key)
+ return testRepo.Run(t, "config", "--get", key)
}
func TestConfigAgainstGit(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {- repo := testgit.NewBareRepo(t, algo)
- repo.Run(t, "config", "core.bare", "true")
- repo.Run(t, "config", "core.filemode", "false")
- repo.Run(t, "config", "user.name", "Jane Doe")
- repo.Run(t, "config", "user.email", "jane@example.org")
+ testRepo := testgit.NewBareRepo(t, algo)
+ testRepo.Run(t, "config", "core.bare", "true")
+ testRepo.Run(t, "config", "core.filemode", "false")
+ testRepo.Run(t, "config", "user.name", "Jane Doe")
+ testRepo.Run(t, "config", "user.email", "jane@example.org")
- cfgFile := openConfig(t, repo)
+ cfgFile := openConfig(t, testRepo)
defer func() { _ = cfgFile.Close() }()cfg, err := config.ParseConfig(cfgFile)
@@ -58,11 +58,11 @@
func TestConfigSubsectionAgainstGit(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {- repo := testgit.NewBareRepo(t, algo)
- repo.Run(t, "config", "remote.origin.url", "https://example.org/repo.git")
- repo.Run(t, "config", "remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*")
+ testRepo := testgit.NewBareRepo(t, algo)
+ testRepo.Run(t, "config", "remote.origin.url", "https://example.org/repo.git")
+ testRepo.Run(t, "config", "remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*")
- cfgFile := openConfig(t, repo)
+ cfgFile := openConfig(t, testRepo)
defer func() { _ = cfgFile.Close() }()cfg, err := config.ParseConfig(cfgFile)
@@ -81,12 +81,12 @@
func TestConfigMultiValueAgainstGit(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {- repo := testgit.NewBareRepo(t, algo)
- repo.Run(t, "config", "--add", "remote.origin.fetch", "+refs/heads/main:refs/remotes/origin/main")
- repo.Run(t, "config", "--add", "remote.origin.fetch", "+refs/heads/dev:refs/remotes/origin/dev")
- repo.Run(t, "config", "--add", "remote.origin.fetch", "+refs/tags/*:refs/tags/*")
+ testRepo := testgit.NewBareRepo(t, algo)
+ testRepo.Run(t, "config", "--add", "remote.origin.fetch", "+refs/heads/main:refs/remotes/origin/main")
+ testRepo.Run(t, "config", "--add", "remote.origin.fetch", "+refs/heads/dev:refs/remotes/origin/dev")
+ testRepo.Run(t, "config", "--add", "remote.origin.fetch", "+refs/tags/*:refs/tags/*")
- cfgFile := openConfig(t, repo)
+ cfgFile := openConfig(t, testRepo)
defer func() { _ = cfgFile.Close() }()cfg, err := config.ParseConfig(cfgFile)
@@ -114,14 +114,14 @@
func TestConfigCaseInsensitiveAgainstGit(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {- repo := testgit.NewBareRepo(t, algo)
- repo.Run(t, "config", "Core.Bare", "true")
- repo.Run(t, "config", "CORE.FileMode", "false")
+ testRepo := testgit.NewBareRepo(t, algo)
+ testRepo.Run(t, "config", "Core.Bare", "true")
+ testRepo.Run(t, "config", "CORE.FileMode", "false")
- gitVerifyBare := gitConfigGet(t, repo, "core.bare")
- gitVerifyFilemode := gitConfigGet(t, repo, "core.filemode")
+ gitVerifyBare := gitConfigGet(t, testRepo, "core.bare")
+ gitVerifyFilemode := gitConfigGet(t, testRepo, "core.filemode")
- cfgFile := openConfig(t, repo)
+ cfgFile := openConfig(t, testRepo)
defer func() { _ = cfgFile.Close() }()cfg, err := config.ParseConfig(cfgFile)
@@ -143,13 +143,13 @@
func TestConfigBooleanAgainstGit(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {- repo := testgit.NewBareRepo(t, algo)
- repo.Run(t, "config", "test.flag1", "true")
- repo.Run(t, "config", "test.flag2", "false")
- repo.Run(t, "config", "test.flag3", "yes")
- repo.Run(t, "config", "test.flag4", "no")
+ testRepo := testgit.NewBareRepo(t, algo)
+ testRepo.Run(t, "config", "test.flag1", "true")
+ testRepo.Run(t, "config", "test.flag2", "false")
+ testRepo.Run(t, "config", "test.flag3", "yes")
+ testRepo.Run(t, "config", "test.flag4", "no")
- cfgFile := openConfig(t, repo)
+ cfgFile := openConfig(t, testRepo)
defer func() { _ = cfgFile.Close() }()cfg, err := config.ParseConfig(cfgFile)
@@ -161,10 +161,10 @@
key string
want string
}{- {"flag1", gitConfigGet(t, repo, "test.flag1")},- {"flag2", gitConfigGet(t, repo, "test.flag2")},- {"flag3", gitConfigGet(t, repo, "test.flag3")},- {"flag4", gitConfigGet(t, repo, "test.flag4")},+ {"flag1", gitConfigGet(t, testRepo, "test.flag1")},+ {"flag2", gitConfigGet(t, testRepo, "test.flag2")},+ {"flag3", gitConfigGet(t, testRepo, "test.flag3")},+ {"flag4", gitConfigGet(t, testRepo, "test.flag4")},}
for _, tt := range tests {@@ -177,13 +177,13 @@
func TestConfigComplexValuesAgainstGit(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {- repo := testgit.NewBareRepo(t, algo)
- repo.Run(t, "config", "test.spaced", "value with spaces")
- repo.Run(t, "config", "test.special", "value=with=equals")
- repo.Run(t, "config", "test.path", "/path/to/something")
- repo.Run(t, "config", "test.number", "12345")
+ testRepo := testgit.NewBareRepo(t, algo)
+ testRepo.Run(t, "config", "test.spaced", "value with spaces")
+ testRepo.Run(t, "config", "test.special", "value=with=equals")
+ testRepo.Run(t, "config", "test.path", "/path/to/something")
+ testRepo.Run(t, "config", "test.number", "12345")
- cfgFile := openConfig(t, repo)
+ cfgFile := openConfig(t, testRepo)
defer func() { _ = cfgFile.Close() }()cfg, err := config.ParseConfig(cfgFile)
@@ -193,7 +193,7 @@
tests := []string{"spaced", "special", "path", "number"} for _, key := range tests {- want := gitConfigGet(t, repo, "test."+key)
+ want := gitConfigGet(t, testRepo, "test."+key)
if got := cfg.Get("test", "", key); got != want { t.Errorf("test.%s: got %q, want %q (from git)", key, got, want)}
@@ -203,12 +203,12 @@
func TestConfigEntriesAgainstGit(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {- repo := testgit.NewBareRepo(t, algo)
- repo.Run(t, "config", "core.bare", "true")
- repo.Run(t, "config", "core.filemode", "false")
- repo.Run(t, "config", "user.name", "Test User")
+ testRepo := testgit.NewBareRepo(t, algo)
+ testRepo.Run(t, "config", "core.bare", "true")
+ testRepo.Run(t, "config", "core.filemode", "false")
+ testRepo.Run(t, "config", "user.name", "Test User")
- cfgFile := openConfig(t, repo)
+ cfgFile := openConfig(t, testRepo)
defer func() { _ = cfgFile.Close() }()cfg, err := config.ParseConfig(cfgFile)
@@ -229,7 +229,7 @@
}
found[key] = true
- gitValue := gitConfigGet(t, repo, key)
+ gitValue := gitConfigGet(t, testRepo, key)
if entry.Value != gitValue { t.Errorf("entry %s: got value %q, git has %q", key, entry.Value, gitValue)}
--- a/internal/testgit/repo_cat_file.go
+++ b/internal/testgit/repo_cat_file.go
@@ -7,7 +7,7 @@
)
// CatFile returns raw output from git cat-file.
-func (repo *TestRepo) CatFile(tb testing.TB, mode string, id objectid.ObjectID) []byte {+func (testRepo *TestRepo) CatFile(tb testing.TB, mode string, id objectid.ObjectID) []byte {tb.Helper()
- return repo.RunBytes(tb, "cat-file", mode, id.String())
+ return testRepo.RunBytes(tb, "cat-file", mode, id.String())
}
--- a/internal/testgit/repo_commit_tree.go
+++ b/internal/testgit/repo_commit_tree.go
@@ -7,7 +7,7 @@
)
// CommitTree creates a commit from a tree and message, optionally with parents.
-func (repo *TestRepo) CommitTree(tb testing.TB, tree objectid.ObjectID, message string, parents ...objectid.ObjectID) objectid.ObjectID {+func (testRepo *TestRepo) CommitTree(tb testing.TB, tree objectid.ObjectID, message string, parents ...objectid.ObjectID) objectid.ObjectID {tb.Helper()
args := []string{"commit-tree", tree.String()} for _, p := range parents {@@ -14,8 +14,8 @@
args = append(args, "-p", p.String())
}
args = append(args, "-m", message)
- hex := repo.Run(tb, args...)
- id, err := objectid.ParseHex(repo.algo, hex)
+ hex := testRepo.Run(tb, args...)
+ id, err := objectid.ParseHex(testRepo.algo, hex)
if err != nil { tb.Fatalf("parse commit-tree output %q: %v", hex, err)}
--- a/internal/testgit/repo_hash_object.go
+++ b/internal/testgit/repo_hash_object.go
@@ -7,10 +7,10 @@
)
// HashObject hashes and writes an object and returns its object ID.
-func (repo *TestRepo) HashObject(tb testing.TB, objType string, body []byte) objectid.ObjectID {+func (testRepo *TestRepo) HashObject(tb testing.TB, objType string, body []byte) objectid.ObjectID {tb.Helper()
- hex := repo.RunInput(tb, body, "hash-object", "-t", objType, "-w", "--stdin")
- id, err := objectid.ParseHex(repo.algo, hex)
+ hex := testRepo.RunInput(tb, body, "hash-object", "-t", objType, "-w", "--stdin")
+ id, err := objectid.ParseHex(testRepo.algo, hex)
if err != nil { tb.Fatalf("parse git hash-object output %q: %v", hex, err)}
--- a/internal/testgit/repo_make_commit.go
+++ b/internal/testgit/repo_make_commit.go
@@ -7,9 +7,9 @@
)
// MakeCommit creates a commit over a single-file tree and returns (blobID, treeID, commitID).
-func (repo *TestRepo) MakeCommit(tb testing.TB, message string) (objectid.ObjectID, objectid.ObjectID, objectid.ObjectID) {+func (testRepo *TestRepo) MakeCommit(tb testing.TB, message string) (objectid.ObjectID, objectid.ObjectID, objectid.ObjectID) {tb.Helper()
- blobID, treeID := repo.MakeSingleFileTree(tb, "file.txt", []byte("commit-body\n"))- commitID := repo.CommitTree(tb, treeID, message)
+ blobID, treeID := testRepo.MakeSingleFileTree(tb, "file.txt", []byte("commit-body\n"))+ commitID := testRepo.CommitTree(tb, treeID, message)
return blobID, treeID, commitID
}
--- a/internal/testgit/repo_make_single_file_tree.go
+++ b/internal/testgit/repo_make_single_file_tree.go
@@ -8,10 +8,10 @@
)
// MakeSingleFileTree writes one blob and one tree entry for it and returns (blobID, treeID).
-func (repo *TestRepo) MakeSingleFileTree(tb testing.TB, fileName string, fileContent []byte) (objectid.ObjectID, objectid.ObjectID) {+func (testRepo *TestRepo) MakeSingleFileTree(tb testing.TB, fileName string, fileContent []byte) (objectid.ObjectID, objectid.ObjectID) {tb.Helper()
- blobID := repo.HashObject(tb, "blob", fileContent)
+ blobID := testRepo.HashObject(tb, "blob", fileContent)
treeInput := fmt.Sprintf("100644 blob %s\t%s\n", blobID.String(), fileName)- treeID := repo.Mktree(tb, treeInput)
+ treeID := testRepo.Mktree(tb, treeInput)
return blobID, treeID
}
--- a/internal/testgit/repo_mktree.go
+++ b/internal/testgit/repo_mktree.go
@@ -7,10 +7,10 @@
)
// Mktree creates a tree from textual mktree input and returns its ID.
-func (repo *TestRepo) Mktree(tb testing.TB, input string) objectid.ObjectID {+func (testRepo *TestRepo) Mktree(tb testing.TB, input string) objectid.ObjectID {tb.Helper()
- hex := repo.RunInput(tb, []byte(input), "mktree")
- id, err := objectid.ParseHex(repo.algo, hex)
+ hex := testRepo.RunInput(tb, []byte(input), "mktree")
+ id, err := objectid.ParseHex(testRepo.algo, hex)
if err != nil { tb.Fatalf("parse mktree output %q: %v", hex, err)}
--- a/internal/testgit/repo_new.go
+++ b/internal/testgit/repo_new.go
@@ -31,7 +31,7 @@
}
tb.Cleanup(func() { _ = os.RemoveAll(dir) })- repo := &TestRepo{+ testRepo := &TestRepo{dir: dir,
algo: algo,
env: append(os.Environ(),
@@ -51,6 +51,6 @@
args = append(args, "--bare")
}
args = append(args, dir)
- repo.runBytes(tb, nil, "", args...)
- return repo
+ testRepo.runBytes(tb, nil, "", args...)
+ return testRepo
}
--- a/internal/testgit/repo_properties.go
+++ b/internal/testgit/repo_properties.go
@@ -3,11 +3,11 @@
import "codeberg.org/lindenii/furgit/objectid"
// Dir returns the repository directory path.
-func (repo *TestRepo) Dir() string {- return repo.dir
+func (testRepo *TestRepo) Dir() string {+ return testRepo.dir
}
// Algorithm returns the object ID algorithm configured for this repository.
-func (repo *TestRepo) Algorithm() objectid.Algorithm {- return repo.algo
+func (testRepo *TestRepo) Algorithm() objectid.Algorithm {+ return testRepo.algo
}
--- a/internal/testgit/repo_rev_parse.go
+++ b/internal/testgit/repo_rev_parse.go
@@ -7,10 +7,10 @@
)
// RevParse resolves rev expressions to object IDs.
-func (repo *TestRepo) RevParse(tb testing.TB, spec string) objectid.ObjectID {+func (testRepo *TestRepo) RevParse(tb testing.TB, spec string) objectid.ObjectID {tb.Helper()
- hex := repo.Run(tb, "rev-parse", spec)
- id, err := objectid.ParseHex(repo.algo, hex)
+ hex := testRepo.Run(tb, "rev-parse", spec)
+ id, err := objectid.ParseHex(testRepo.algo, hex)
if err != nil { tb.Fatalf("parse rev-parse output %q: %v", hex, err)}
--- a/internal/testgit/repo_run.go
+++ b/internal/testgit/repo_run.go
@@ -8,36 +8,36 @@
)
// Run executes git and returns trimmed textual output.
-func (repo *TestRepo) Run(tb testing.TB, args ...string) string {+func (testRepo *TestRepo) Run(tb testing.TB, args ...string) string {tb.Helper()
- out := repo.runBytes(tb, nil, repo.dir, args...)
+ out := testRepo.runBytes(tb, nil, testRepo.dir, args...)
return strings.TrimSpace(string(out))
}
// RunBytes executes git and returns raw output bytes.
-func (repo *TestRepo) RunBytes(tb testing.TB, args ...string) []byte {+func (testRepo *TestRepo) RunBytes(tb testing.TB, args ...string) []byte {tb.Helper()
- return repo.runBytes(tb, nil, repo.dir, args...)
+ return testRepo.runBytes(tb, nil, testRepo.dir, args...)
}
// RunInput executes git with stdin and returns trimmed textual output.
-func (repo *TestRepo) RunInput(tb testing.TB, stdin []byte, args ...string) string {+func (testRepo *TestRepo) RunInput(tb testing.TB, stdin []byte, args ...string) string {tb.Helper()
- out := repo.runBytes(tb, stdin, repo.dir, args...)
+ out := testRepo.runBytes(tb, stdin, testRepo.dir, args...)
return strings.TrimSpace(string(out))
}
// RunInputBytes executes git with stdin and returns raw output bytes.
-func (repo *TestRepo) RunInputBytes(tb testing.TB, stdin []byte, args ...string) []byte {+func (testRepo *TestRepo) RunInputBytes(tb testing.TB, stdin []byte, args ...string) []byte {tb.Helper()
- return repo.runBytes(tb, stdin, repo.dir, args...)
+ return testRepo.runBytes(tb, stdin, testRepo.dir, args...)
}
-func (repo *TestRepo) runBytes(tb testing.TB, stdin []byte, dir string, args ...string) []byte {+func (testRepo *TestRepo) runBytes(tb testing.TB, stdin []byte, dir string, args ...string) []byte {tb.Helper()
cmd := exec.Command("git", args...)cmd.Dir = dir
- cmd.Env = repo.env
+ cmd.Env = testRepo.env
if stdin != nil {cmd.Stdin = bytes.NewReader(stdin)
}
--- a/internal/testgit/repo_tag_annotated.go
+++ b/internal/testgit/repo_tag_annotated.go
@@ -8,8 +8,8 @@
)
// TagAnnotated creates an annotated tag object and returns the resulting tag object ID.
-func (repo *TestRepo) TagAnnotated(tb testing.TB, name string, target objectid.ObjectID, message string) objectid.ObjectID {+func (testRepo *TestRepo) TagAnnotated(tb testing.TB, name string, target objectid.ObjectID, message string) objectid.ObjectID {tb.Helper()
- repo.Run(tb, "tag", "-a", name, target.String(), "-m", message)
- return repo.RevParse(tb, fmt.Sprintf("refs/tags/%s", name))+ testRepo.Run(tb, "tag", "-a", name, target.String(), "-m", message)
+ return testRepo.RevParse(tb, fmt.Sprintf("refs/tags/%s", name))}
--- a/object/blob_parse_test.go
+++ b/object/blob_parse_test.go
@@ -11,11 +11,11 @@
func TestBlobParseFromGit(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {- repo := testgit.NewBareRepo(t, algo)
+ testRepo := testgit.NewBareRepo(t, algo)
body := []byte("hello\nblob\n")- blobID := repo.HashObject(t, "blob", body)
+ blobID := testRepo.HashObject(t, "blob", body)
- rawBody := repo.CatFile(t, "blob", blobID)
+ rawBody := testRepo.CatFile(t, "blob", blobID)
blob, err := object.ParseBlob(rawBody)
if err != nil { t.Fatalf("ParseBlob: %v", err)--- a/object/blob_serialize_test.go
+++ b/object/blob_serialize_test.go
@@ -10,9 +10,9 @@
func TestBlobSerialize(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {- repo := testgit.NewBareRepo(t, algo)
+ testRepo := testgit.NewBareRepo(t, algo)
body := []byte("hello\nblob\n")- wantID := repo.HashObject(t, "blob", body)
+ wantID := testRepo.HashObject(t, "blob", body)
blob := &object.Blob{Data: body}rawObj, err := blob.SerializeWithHeader()
--- a/object/commit_parse_test.go
+++ b/object/commit_parse_test.go
@@ -11,10 +11,10 @@
func TestCommitParseFromGit(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {- repo := testgit.NewBareRepo(t, algo)
- _, treeID, commitID := repo.MakeCommit(t, "subject\n\nbody")
+ testRepo := testgit.NewBareRepo(t, algo)
+ _, treeID, commitID := testRepo.MakeCommit(t, "subject\n\nbody")
- rawBody := repo.CatFile(t, "commit", commitID)
+ rawBody := testRepo.CatFile(t, "commit", commitID)
commit, err := object.ParseCommit(rawBody, algo)
if err != nil { t.Fatalf("ParseCommit: %v", err)--- a/object/commit_serialize_test.go
+++ b/object/commit_serialize_test.go
@@ -10,10 +10,10 @@
func TestCommitSerialize(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {- repo := testgit.NewBareRepo(t, algo)
- _, _, commitID := repo.MakeCommit(t, "subject\n\nbody")
+ testRepo := testgit.NewBareRepo(t, algo)
+ _, _, commitID := testRepo.MakeCommit(t, "subject\n\nbody")
- rawBody := repo.CatFile(t, "commit", commitID)
+ rawBody := testRepo.CatFile(t, "commit", commitID)
commit, err := object.ParseCommit(rawBody, algo)
if err != nil { t.Fatalf("ParseCommit: %v", err)--- a/object/tag_parse_test.go
+++ b/object/tag_parse_test.go
@@ -6,17 +6,17 @@
"codeberg.org/lindenii/furgit/internal/testgit"
"codeberg.org/lindenii/furgit/object"
- "codeberg.org/lindenii/furgit/objecttype"
"codeberg.org/lindenii/furgit/objectid"
+ "codeberg.org/lindenii/furgit/objecttype"
)
func TestTagParseFromGit(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {- repo := testgit.NewBareRepo(t, algo)
- _, _, commitID := repo.MakeCommit(t, "subject\n\nbody")
- tagID := repo.TagAnnotated(t, "v1", commitID, "tag message")
+ testRepo := testgit.NewBareRepo(t, algo)
+ _, _, commitID := testRepo.MakeCommit(t, "subject\n\nbody")
+ tagID := testRepo.TagAnnotated(t, "v1", commitID, "tag message")
- rawBody := repo.CatFile(t, "tag", tagID)
+ rawBody := testRepo.CatFile(t, "tag", tagID)
tag, err := object.ParseTag(rawBody, algo)
if err != nil { t.Fatalf("ParseTag: %v", err)--- a/object/tag_serialize_test.go
+++ b/object/tag_serialize_test.go
@@ -10,11 +10,11 @@
func TestTagSerialize(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {- repo := testgit.NewBareRepo(t, algo)
- _, _, commitID := repo.MakeCommit(t, "subject\n\nbody")
- tagID := repo.TagAnnotated(t, "v1", commitID, "tag message")
+ testRepo := testgit.NewBareRepo(t, algo)
+ _, _, commitID := testRepo.MakeCommit(t, "subject\n\nbody")
+ tagID := testRepo.TagAnnotated(t, "v1", commitID, "tag message")
- rawBody := repo.CatFile(t, "tag", tagID)
+ rawBody := testRepo.CatFile(t, "tag", tagID)
tag, err := object.ParseTag(rawBody, algo)
if err != nil { t.Fatalf("ParseTag: %v", err)--- a/object/tree_helpers_test.go
+++ b/object/tree_helpers_test.go
@@ -61,20 +61,20 @@
return names
}
-func adversarialRootEntries(t *testing.T, repo *testgit.TestRepo) []object.TreeEntry {+func adversarialRootEntries(t *testing.T, testRepo *testgit.TestRepo) []object.TreeEntry {t.Helper()
- blobA := repo.HashObject(t, "blob", []byte("blob-A\n"))- blobB := repo.HashObject(t, "blob", []byte("blob-B\n"))- blobC := repo.HashObject(t, "blob", []byte("blob-C\n"))+ blobA := testRepo.HashObject(t, "blob", []byte("blob-A\n"))+ blobB := testRepo.HashObject(t, "blob", []byte("blob-B\n"))+ blobC := testRepo.HashObject(t, "blob", []byte("blob-C\n"))- subDirA := repo.Mktree(t,
+ subDirA := testRepo.Mktree(t,
fmt.Sprintf("100644 blob %s\tnested-a.txt\n100755 blob %s\trun-a.sh\n", blobA.String(), blobB.String()))- subDirB := repo.Mktree(t,
+ subDirB := testRepo.Mktree(t,
fmt.Sprintf("100644 blob %s\tnested-b.txt\n100644 blob %s\tz-last\n", blobB.String(), blobC.String()))- subDirC := repo.Mktree(t,
+ subDirC := testRepo.Mktree(t,
fmt.Sprintf("120000 blob %s\tlink-c\n100644 blob %s\tchild\n", blobC.String(), blobA.String()))- subDirD := repo.Mktree(t,
+ subDirD := testRepo.Mktree(t,
fmt.Sprintf("100644 blob %s\tleaf\n", blobA.String())) return []object.TreeEntry{--- a/object/tree_parse_test.go
+++ b/object/tree_parse_test.go
@@ -11,8 +11,8 @@
func TestTreeParseFromGit(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {- repo := testgit.NewBareRepo(t, algo)
- entries := adversarialRootEntries(t, repo)
+ testRepo := testgit.NewBareRepo(t, algo)
+ entries := adversarialRootEntries(t, testRepo)
inserted := &object.Tree{} for _, entry := range entries { if err := inserted.InsertEntry(entry); err != nil {@@ -20,9 +20,9 @@
}
}
- treeID := repo.Mktree(t, buildGitMktreeInput(inserted.Entries))
+ treeID := testRepo.Mktree(t, buildGitMktreeInput(inserted.Entries))
- rawBody := repo.CatFile(t, "tree", treeID)
+ rawBody := testRepo.CatFile(t, "tree", treeID)
tree, err := object.ParseTree(rawBody, algo)
if err != nil { t.Fatalf("ParseTree: %v", err)@@ -40,7 +40,7 @@
}
}
- lsNames := gitLsTreeNames(repo.RunBytes(t, "ls-tree", "--name-only", "-z", treeID.String()))
+ lsNames := gitLsTreeNames(testRepo.RunBytes(t, "ls-tree", "--name-only", "-z", treeID.String()))
if len(lsNames) != len(tree.Entries) { t.Fatalf("ls-tree names = %d, want %d", len(lsNames), len(tree.Entries))}
--- a/object/tree_serialize_test.go
+++ b/object/tree_serialize_test.go
@@ -10,8 +10,8 @@
func TestTreeSerialize(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {- repo := testgit.NewBareRepo(t, algo)
- entries := adversarialRootEntries(t, repo)
+ testRepo := testgit.NewBareRepo(t, algo)
+ entries := adversarialRootEntries(t, testRepo)
tree := &object.Tree{} for i := len(entries) - 1; i >= 0; i-- {@@ -45,7 +45,7 @@
t.Fatalf("Entry(%q) should exist after reinsert", removed.Name)}
- wantTreeID := repo.Mktree(t, buildGitMktreeInput(tree.Entries))
+ wantTreeID := testRepo.Mktree(t, buildGitMktreeInput(tree.Entries))
rawObj, err := tree.SerializeWithHeader()
if err != nil {--
⑨