-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Reduce calls to git cat-file -s #14682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
aecf5a6
Reduce calls to git cat-file -s
zeripath 72e2840
Merge branch 'master' into reduce-cat-file-s-calls
6543 8b3b6df
simplify by always expecting the long format
zeripath b5d8442
Also always set the sized field and tell the indexer the update is sized
zeripath 636377c
Apply suggestions from code review
zeripath 327df10
Merge branch 'master' into reduce-cat-file-s-calls
6543 f0ea4c2
make fmt
6543 d168ab2
Merge branch 'master' into reduce-cat-file-s-calls
lunny 7c79734
Merge branch 'master' into reduce-cat-file-s-calls
techknowlogick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2021 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// +build !gogit | ||
|
||
package git | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestParseTreeEntries(t *testing.T) { | ||
|
||
testCases := []struct { | ||
Input string | ||
Expected []*TreeEntry | ||
}{ | ||
{ | ||
Input: `100644 blob ea0d83c9081af9500ac9f804101b3fd0a5c293af 8218 README.md | ||
100644 blob 037f27dc9d353ae4fd50f0474b2194c593914e35 4681 README_ZH.md | ||
100644 blob 9846a94f7e8350a916632929d0fda38c90dd2ca8 429 SECURITY.md | ||
040000 tree 84b90550547016f73c5dd3f50dea662389e67b6d - assets | ||
`, | ||
Expected: []*TreeEntry{ | ||
{ | ||
ID: MustIDFromString("ea0d83c9081af9500ac9f804101b3fd0a5c293af"), | ||
name: "README.md", | ||
entryMode: EntryModeBlob, | ||
size: 8218, | ||
sized: true, | ||
}, | ||
{ | ||
ID: MustIDFromString("037f27dc9d353ae4fd50f0474b2194c593914e35"), | ||
name: "README_ZH.md", | ||
entryMode: EntryModeBlob, | ||
size: 4681, | ||
sized: true, | ||
}, | ||
{ | ||
ID: MustIDFromString("9846a94f7e8350a916632929d0fda38c90dd2ca8"), | ||
name: "SECURITY.md", | ||
entryMode: EntryModeBlob, | ||
size: 429, | ||
sized: true, | ||
}, | ||
{ | ||
ID: MustIDFromString("84b90550547016f73c5dd3f50dea662389e67b6d"), | ||
name: "assets", | ||
entryMode: EntryModeTree, | ||
sized: true, | ||
}, | ||
}, | ||
}, | ||
} | ||
for _, testCase := range testCases { | ||
entries, err := ParseTreeEntries([]byte(testCase.Input)) | ||
assert.NoError(t, err) | ||
assert.EqualValues(t, len(testCase.Expected), len(entries)) | ||
for i, entry := range entries { | ||
assert.EqualValues(t, testCase.Expected[i].ID, entry.ID) | ||
assert.EqualValues(t, testCase.Expected[i].name, entry.name) | ||
assert.EqualValues(t, testCase.Expected[i].entryMode, entry.entryMode) | ||
assert.EqualValues(t, testCase.Expected[i].sized, entry.sized) | ||
assert.EqualValues(t, testCase.Expected[i].size, entry.size) | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.