summaryrefslogtreecommitdiffstats
path: root/modules/git/parse_gogit_test.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-02-17 21:32:25 +0000
committerGitHub <noreply@github.com>2021-02-17 22:32:25 +0100
commitae7e6cd474747dce1f65c0b1c6e1d6b09ab0bccb (patch)
tree669743542988c694b242f92d512bb219eb300635 /modules/git/parse_gogit_test.go
parent7ba158183a34d71b3989512c059a01d35c4c4673 (diff)
downloadgitea-ae7e6cd474747dce1f65c0b1c6e1d6b09ab0bccb.tar.gz
gitea-ae7e6cd474747dce1f65c0b1c6e1d6b09ab0bccb.zip
Reduce calls to git cat-file -s (#14682)
* Reduce calls to git cat-file -s There are multiple places where there are repeated calls to git cat-file -s due to the blobs not being created with their size. Through judicious use of git ls-tree -l and slight adjustments to the indexer code we can avoid a lot of these calls. * simplify by always expecting the long format * Also always set the sized field and tell the indexer the update is sized
Diffstat (limited to 'modules/git/parse_gogit_test.go')
-rw-r--r--modules/git/parse_gogit_test.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/modules/git/parse_gogit_test.go b/modules/git/parse_gogit_test.go
index cf38c29932..c6374133c0 100644
--- a/modules/git/parse_gogit_test.go
+++ b/modules/git/parse_gogit_test.go
@@ -24,7 +24,7 @@ func TestParseTreeEntries(t *testing.T) {
Expected: []*TreeEntry{},
},
{
- Input: "100644 blob 61ab7345a1a3bbc590068ccae37b8515cfc5843c\texample/file2.txt\n",
+ Input: "100644 blob 61ab7345a1a3bbc590068ccae37b8515cfc5843c 1022\texample/file2.txt\n",
Expected: []*TreeEntry{
{
ID: MustIDFromString("61ab7345a1a3bbc590068ccae37b8515cfc5843c"),
@@ -33,12 +33,14 @@ func TestParseTreeEntries(t *testing.T) {
Name: "example/file2.txt",
Mode: filemode.Regular,
},
+ size: 1022,
+ sized: true,
},
},
},
{
- Input: "120000 blob 61ab7345a1a3bbc590068ccae37b8515cfc5843c\t\"example/\\n.txt\"\n" +
- "040000 tree 1d01fb729fb0db5881daaa6030f9f2d3cd3d5ae8\texample\n",
+ Input: "120000 blob 61ab7345a1a3bbc590068ccae37b8515cfc5843c 234131\t\"example/\\n.txt\"\n" +
+ "040000 tree 1d01fb729fb0db5881daaa6030f9f2d3cd3d5ae8 -\texample\n",
Expected: []*TreeEntry{
{
ID: MustIDFromString("61ab7345a1a3bbc590068ccae37b8515cfc5843c"),
@@ -47,9 +49,12 @@ func TestParseTreeEntries(t *testing.T) {
Name: "example/\n.txt",
Mode: filemode.Symlink,
},
+ size: 234131,
+ sized: true,
},
{
- ID: MustIDFromString("1d01fb729fb0db5881daaa6030f9f2d3cd3d5ae8"),
+ ID: MustIDFromString("1d01fb729fb0db5881daaa6030f9f2d3cd3d5ae8"),
+ sized: true,
gogitTreeEntry: &object.TreeEntry{
Hash: MustIDFromString("1d01fb729fb0db5881daaa6030f9f2d3cd3d5ae8"),
Name: "example",