File tree 3 files changed +11
-4
lines changed
transport/internal/common
3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -38,10 +38,10 @@ func NewUploadPackRequestFromCapabilities(adv *capability.List) *UploadPackReque
38
38
}
39
39
}
40
40
41
- // IsEmpty a request if empty if Haves are contained in the Wants, or if Wants
42
- // length is zero
41
+ // IsEmpty returns whether a request is empty - it is empty if Haves are contained
42
+ // in the Wants, or if Wants length is zero, and we don't have any shallows
43
43
func (r * UploadPackRequest ) IsEmpty () bool {
44
- return isSubset (r .Wants , r .Haves )
44
+ return isSubset (r .Wants , r .Haves ) && len ( r . Shallows ) == 0
45
45
}
46
46
47
47
func isSubset (needle []plumbing.Hash , haystack []plumbing.Hash ) bool {
Original file line number Diff line number Diff line change @@ -41,6 +41,13 @@ func (s *UploadPackRequestSuite) TestIsEmpty(c *C) {
41
41
r .Haves = append (r .Haves , plumbing .NewHash ("d82f291cde9987322c8a0c81a325e1ba6159684c" ))
42
42
43
43
c .Assert (r .IsEmpty (), Equals , true )
44
+
45
+ r = NewUploadPackRequest ()
46
+ r .Wants = append (r .Wants , plumbing .NewHash ("d82f291cde9987322c8a0c81a325e1ba6159684c" ))
47
+ r .Haves = append (r .Haves , plumbing .NewHash ("d82f291cde9987322c8a0c81a325e1ba6159684c" ))
48
+ r .Shallows = append (r .Shallows , plumbing .NewHash ("2b41ef280fdb67a9b250678686a0c3e03b0a9989" ))
49
+
50
+ c .Assert (r .IsEmpty (), Equals , false )
44
51
}
45
52
46
53
type UploadHavesSuite struct {}
Original file line number Diff line number Diff line change @@ -232,7 +232,7 @@ func (s *session) handleAdvRefDecodeError(err error) error {
232
232
// UploadPack performs a request to the server to fetch a packfile. A reader is
233
233
// returned with the packfile content. The reader must be closed after reading.
234
234
func (s * session ) UploadPack (ctx context.Context , req * packp.UploadPackRequest ) (* packp.UploadPackResponse , error ) {
235
- if req .IsEmpty () && len ( req . Shallows ) == 0 {
235
+ if req .IsEmpty () {
236
236
return nil , transport .ErrEmptyUploadPackRequest
237
237
}
238
238
You can’t perform that action at this time.
0 commit comments