File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
utils/merkletrie/filesystem Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 1
1
package filesystem
2
2
3
3
import (
4
- "io"
5
4
"os"
6
5
"path"
7
6
8
7
"github.com/go-git/go-git/v6/plumbing"
9
8
"github.com/go-git/go-git/v6/plumbing/filemode"
10
9
format "github.com/go-git/go-git/v6/plumbing/format/config"
10
+ "github.com/go-git/go-git/v6/utils/ioutil"
11
11
"github.com/go-git/go-git/v6/utils/merkletrie/noder"
12
12
13
13
"github.com/go-git/go-billy/v6"
@@ -180,7 +180,7 @@ func (n *node) doCalculateHashForRegular() plumbing.Hash {
180
180
defer f .Close ()
181
181
182
182
h := plumbing .NewHasher (format .SHA1 , plumbing .BlobObject , n .size )
183
- if _ , err := io . Copy (h , f ); err != nil {
183
+ if _ , err := ioutil . CopyBufferPool (h , f ); err != nil {
184
184
return plumbing .ZeroHash
185
185
}
186
186
Original file line number Diff line number Diff line change 6
6
"strings"
7
7
"testing"
8
8
9
+ "github.com/go-git/go-billy/v6/memfs"
9
10
"github.com/go-git/go-billy/v6/osfs"
11
+ fixtures "github.com/go-git/go-git-fixtures/v5"
10
12
"github.com/go-git/go-git/v6/plumbing/cache"
11
13
"github.com/go-git/go-git/v6/storage/filesystem"
12
14
"github.com/stretchr/testify/assert"
@@ -87,3 +89,25 @@ func TestIndexEntrySizeUpdatedForNonRegularFiles(t *testing.T) {
87
89
// Check whether the index was updated with the two new line breaks.
88
90
assert .Equal (t , uint32 (len (content )+ 2 ), idx .Entries [0 ].Size )
89
91
}
92
+
93
+ func BenchmarkWorktreeStatus (b * testing.B ) {
94
+ b .StopTimer ()
95
+
96
+ f := fixtures .Basic ().One ()
97
+ st := filesystem .NewStorage (f .DotGit (), cache .NewObjectLRUDefault ())
98
+
99
+ r , err := Open (st , memfs .New ())
100
+ require .NoError (b , err )
101
+
102
+ wt , err := r .Worktree ()
103
+ require .NoError (b , err )
104
+
105
+ err = wt .Reset (& ResetOptions {Mode : HardReset })
106
+ require .NoError (b , err )
107
+
108
+ b .StartTimer ()
109
+
110
+ for range b .N {
111
+ wt .Status ()
112
+ }
113
+ }
You can’t perform that action at this time.
0 commit comments