From 7391aa4c244439c246b269ef3e946273aba7ca8b Mon Sep 17 00:00:00 2001 From: "paul.t" Date: Tue, 9 Nov 2021 15:16:55 +0000 Subject: add codecommit packfile for testing external ref resolution --- plumbing/format/packfile/parser_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'plumbing/format/packfile/parser_test.go') diff --git a/plumbing/format/packfile/parser_test.go b/plumbing/format/packfile/parser_test.go index b0b4af8..9c7e218 100644 --- a/plumbing/format/packfile/parser_test.go +++ b/plumbing/format/packfile/parser_test.go @@ -132,6 +132,20 @@ func (s *ParserSuite) TestThinPack(c *C) { } +func (s *ParserSuite) TestResolveExternalRefsInThinPack(c *C) { + f, err := os.Open("testdata/pack-9733763ae7ee6efcf452d373d6fff77424fb1dcc.pack") + c.Assert(err, IsNil) + + scanner := packfile.NewScanner(f) + + obs := new(testObserver) + parser, err := packfile.NewParser(scanner, obs) + c.Assert(err, IsNil) + + _, err = parser.Parse() + c.Assert(err, IsNil) +} + type observerObject struct { hash string otype plumbing.ObjectType -- cgit From bf57a4c6a53423d92aeeadf1bc02877cc80459d4 Mon Sep 17 00:00:00 2001 From: "paul.t" Date: Wed, 5 Jan 2022 06:54:15 +0000 Subject: remove packfile and align to test fixtures --- plumbing/format/packfile/parser_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'plumbing/format/packfile/parser_test.go') diff --git a/plumbing/format/packfile/parser_test.go b/plumbing/format/packfile/parser_test.go index 9c7e218..09f3f97 100644 --- a/plumbing/format/packfile/parser_test.go +++ b/plumbing/format/packfile/parser_test.go @@ -133,10 +133,9 @@ func (s *ParserSuite) TestThinPack(c *C) { } func (s *ParserSuite) TestResolveExternalRefsInThinPack(c *C) { - f, err := os.Open("testdata/pack-9733763ae7ee6efcf452d373d6fff77424fb1dcc.pack") - c.Assert(err, IsNil) + extRefsThinPack := fixtures.ByTag("codecommit").One() - scanner := packfile.NewScanner(f) + scanner := packfile.NewScanner(extRefsThinPack.Packfile()) obs := new(testObserver) parser, err := packfile.NewParser(scanner, obs) -- cgit From 123cdde6f2f6282cb779e03745d384833ac1265b Mon Sep 17 00:00:00 2001 From: Paulo Gomes Date: Wed, 26 Oct 2022 18:12:39 +0100 Subject: Use Sync.Pool pointers to optimise memory usage Signed-off-by: Paulo Gomes --- plumbing/format/packfile/parser_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'plumbing/format/packfile/parser_test.go') diff --git a/plumbing/format/packfile/parser_test.go b/plumbing/format/packfile/parser_test.go index 09f3f97..651d05f 100644 --- a/plumbing/format/packfile/parser_test.go +++ b/plumbing/format/packfile/parser_test.go @@ -10,8 +10,10 @@ import ( fixtures "github.com/go-git/go-git-fixtures/v4" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" + "github.com/go-git/go-git/v5/plumbing/cache" "github.com/go-git/go-git/v5/plumbing/format/packfile" "github.com/go-git/go-git/v5/plumbing/storer" + "github.com/go-git/go-git/v5/storage/filesystem" . "gopkg.in/check.v1" ) @@ -248,3 +250,29 @@ func BenchmarkParseBasic(b *testing.B) { } } } + +func BenchmarkParser(b *testing.B) { + f := fixtures.Basic().One() + defer fixtures.Clean() + + b.ResetTimer() + for n := 0; n < b.N; n++ { + b.StopTimer() + scanner := packfile.NewScanner(f.Packfile()) + fs := osfs.New(os.TempDir()) + storage := filesystem.NewStorage(fs, cache.NewObjectLRUDefault()) + + parser, err := packfile.NewParserWithStorage(scanner, storage) + if err != nil { + b.Error(err) + } + + b.StartTimer() + _, err = parser.Parse() + + b.StopTimer() + if err != nil { + b.Error(err) + } + } +} -- cgit From cdd1e5562d10c6bb19f979ca32f3ae7ef646024f Mon Sep 17 00:00:00 2001 From: ZauberNerd Date: Tue, 15 Mar 2022 17:02:30 +0000 Subject: plumbing: resolve non-external delta references In a self-contained pack file delta references might point to base objects stored later in the file. In this case we need to replace placeholders for external refs with the actual base object and update the children references. Fixes: #484 Co-authored-by: Markus Wolf --- plumbing/format/packfile/parser_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'plumbing/format/packfile/parser_test.go') diff --git a/plumbing/format/packfile/parser_test.go b/plumbing/format/packfile/parser_test.go index 651d05f..b8d080f 100644 --- a/plumbing/format/packfile/parser_test.go +++ b/plumbing/format/packfile/parser_test.go @@ -147,6 +147,19 @@ func (s *ParserSuite) TestResolveExternalRefsInThinPack(c *C) { c.Assert(err, IsNil) } +func (s *ParserSuite) TestResolveExternalRefs(c *C) { + extRefsThinPack := fixtures.ByTag("delta-before-base").One() + + scanner := packfile.NewScanner(extRefsThinPack.Packfile()) + + obs := new(testObserver) + parser, err := packfile.NewParser(scanner, obs) + c.Assert(err, IsNil) + + _, err = parser.Parse() + c.Assert(err, IsNil) +} + type observerObject struct { hash string otype plumbing.ObjectType -- cgit