+3
-3
plumbing/protocol/packp/uppackreq.go
+3
-3
plumbing/protocol/packp/uppackreq.go
···
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 {
+7
plumbing/protocol/packp/uppackreq_test.go
+7
plumbing/protocol/packp/uppackreq_test.go
···
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{}
+1
-1
plumbing/transport/internal/common/common.go
+1
-1
plumbing/transport/internal/common/common.go
···
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