From 1864d943cb2556f8213356fd864683e7eba4e9bb Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 7 Jun 2026 07:45:08 +0000 Subject: internal/testgit: Use --end-of-options sensibly --- internal/testgit/fsck.go | 2 ++ internal/testgit/object.go | 2 +- internal/testgit/repo.go | 2 +- internal/testgit/show.go | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) (limited to 'internal') diff --git a/internal/testgit/fsck.go b/internal/testgit/fsck.go index 6eb4047a..5689899e 100644 --- a/internal/testgit/fsck.go +++ b/internal/testgit/fsck.go @@ -27,6 +27,8 @@ func (repo *Repo) Fsck(tb testing.TB, opts FsckOptions, objects ...id.ObjectID) args = append(args, "--no-dangling") } + args = append(args, "--end-of-options") + for _, object := range objects { args = append(args, object.String()) } diff --git a/internal/testgit/object.go b/internal/testgit/object.go index cbdfce76..3d6f476c 100644 --- a/internal/testgit/object.go +++ b/internal/testgit/object.go @@ -33,7 +33,7 @@ func (repo *Repo) HashObject(tb testing.TB, ty typ.Type, body io.Reader) (id.Obj func (repo *Repo) CatFile(tb testing.TB, ty typ.Type, oid id.ObjectID) ([]byte, error) { tb.Helper() - stdout, err := repo.Run(tb, nil, "git", "cat-file", ty.Name(), oid.String()) + stdout, err := repo.Run(tb, nil, "git", "cat-file", ty.Name(), "--end-of-options", oid.String()) if err != nil { return nil, fmt.Errorf("cat-file: %w", err) } diff --git a/internal/testgit/repo.go b/internal/testgit/repo.go index d10c7db9..544cfb1a 100644 --- a/internal/testgit/repo.go +++ b/internal/testgit/repo.go @@ -41,7 +41,7 @@ func NewRepo(tb testing.TB, opts RepoOptions) (*Repo, error) { ), } - return repo, repo.Command(tb, "git", "init", "--object-format="+repo.objectFormat.String(), "--", repo.path).Run() //nolint:wrapcheck + return repo, repo.Command(tb, "git", "init", "--object-format="+repo.objectFormat.String(), "--end-of-options", repo.path).Run() //nolint:wrapcheck } func (repo *Repo) ObjectFormat(tb testing.TB) id.ObjectFormat { diff --git a/internal/testgit/show.go b/internal/testgit/show.go index 31acb9d3..93ecac2c 100644 --- a/internal/testgit/show.go +++ b/internal/testgit/show.go @@ -11,7 +11,7 @@ import ( func (repo *Repo) ShowFormat(tb testing.TB, oid id.ObjectID, format string) ([]byte, error) { tb.Helper() - stdout, err := repo.Run(tb, nil, "git", "show", "--no-patch", "--no-color", "--format="+format, oid.String()) + stdout, err := repo.Run(tb, nil, "git", "show", "--no-patch", "--no-color", "--format="+format, "--end-of-options", oid.String()) if err != nil { return nil, fmt.Errorf("show --format=%q %s: %w", format, oid, err) } -- cgit v1.3.1-10-gc9f91