Skip to content

Commit ee580ee

Browse files
authored
Merge pull request go-git#124 from cristaloleg/use-one-name-for-receiver
*: use only one name for receiver
2 parents 13095f7 + d07f2fb commit ee580ee

File tree

8 files changed

+54
-54
lines changed

8 files changed

+54
-54
lines changed

plumbing/object/commit.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,16 @@ func (c *Commit) Decode(o plumbing.EncodedObject) (err error) {
243243
}
244244

245245
// Encode transforms a Commit into a plumbing.EncodedObject.
246-
func (b *Commit) Encode(o plumbing.EncodedObject) error {
247-
return b.encode(o, true)
246+
func (c *Commit) Encode(o plumbing.EncodedObject) error {
247+
return c.encode(o, true)
248248
}
249249

250250
// EncodeWithoutSignature export a Commit into a plumbing.EncodedObject without the signature (correspond to the payload of the PGP signature).
251-
func (b *Commit) EncodeWithoutSignature(o plumbing.EncodedObject) error {
252-
return b.encode(o, false)
251+
func (c *Commit) EncodeWithoutSignature(o plumbing.EncodedObject) error {
252+
return c.encode(o, false)
253253
}
254254

255-
func (b *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
255+
func (c *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
256256
o.SetType(plumbing.CommitObject)
257257
w, err := o.Writer()
258258
if err != nil {
@@ -261,11 +261,11 @@ func (b *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
261261

262262
defer ioutil.CheckClose(w, &err)
263263

264-
if _, err = fmt.Fprintf(w, "tree %s\n", b.TreeHash.String()); err != nil {
264+
if _, err = fmt.Fprintf(w, "tree %s\n", c.TreeHash.String()); err != nil {
265265
return err
266266
}
267267

268-
for _, parent := range b.ParentHashes {
268+
for _, parent := range c.ParentHashes {
269269
if _, err = fmt.Fprintf(w, "parent %s\n", parent.String()); err != nil {
270270
return err
271271
}
@@ -275,19 +275,19 @@ func (b *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
275275
return err
276276
}
277277

278-
if err = b.Author.Encode(w); err != nil {
278+
if err = c.Author.Encode(w); err != nil {
279279
return err
280280
}
281281

282282
if _, err = fmt.Fprint(w, "\ncommitter "); err != nil {
283283
return err
284284
}
285285

286-
if err = b.Committer.Encode(w); err != nil {
286+
if err = c.Committer.Encode(w); err != nil {
287287
return err
288288
}
289289

290-
if b.PGPSignature != "" && includeSig {
290+
if c.PGPSignature != "" && includeSig {
291291
if _, err = fmt.Fprint(w, "\n"+headerpgp+" "); err != nil {
292292
return err
293293
}
@@ -296,14 +296,14 @@ func (b *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
296296
// newline. Use join for this so it's clear that a newline should not be
297297
// added after this section, as it will be added when the message is
298298
// printed.
299-
signature := strings.TrimSuffix(b.PGPSignature, "\n")
299+
signature := strings.TrimSuffix(c.PGPSignature, "\n")
300300
lines := strings.Split(signature, "\n")
301301
if _, err = fmt.Fprint(w, strings.Join(lines, "\n ")); err != nil {
302302
return err
303303
}
304304
}
305305

306-
if _, err = fmt.Fprintf(w, "\n\n%s", b.Message); err != nil {
306+
if _, err = fmt.Fprintf(w, "\n\n%s", c.Message); err != nil {
307307
return err
308308
}
309309

plumbing/object/patch.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ type Patch struct {
121121
filePatches []fdiff.FilePatch
122122
}
123123

124-
func (t *Patch) FilePatches() []fdiff.FilePatch {
125-
return t.filePatches
124+
func (p *Patch) FilePatches() []fdiff.FilePatch {
125+
return p.filePatches
126126
}
127127

128-
func (t *Patch) Message() string {
129-
return t.message
128+
func (p *Patch) Message() string {
129+
return p.message
130130
}
131131

132132
func (p *Patch) Encode(w io.Writer) error {
@@ -198,12 +198,12 @@ func (tf *textFilePatch) Files() (from fdiff.File, to fdiff.File) {
198198
return
199199
}
200200

201-
func (t *textFilePatch) IsBinary() bool {
202-
return len(t.chunks) == 0
201+
func (tf *textFilePatch) IsBinary() bool {
202+
return len(tf.chunks) == 0
203203
}
204204

205-
func (t *textFilePatch) Chunks() []fdiff.Chunk {
206-
return t.chunks
205+
func (tf *textFilePatch) Chunks() []fdiff.Chunk {
206+
return tf.chunks
207207
}
208208

209209
// textChunk is an implementation of fdiff.Chunk interface

plumbing/protocol/packp/ulreq.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -109,58 +109,58 @@ func NewUploadRequestFromCapabilities(adv *capability.List) *UploadRequest {
109109
// - is a DepthReference is given capability.DeepenNot MUST be present
110110
// - MUST contain only maximum of one of capability.Sideband and capability.Sideband64k
111111
// - MUST contain only maximum of one of capability.MultiACK and capability.MultiACKDetailed
112-
func (r *UploadRequest) Validate() error {
113-
if len(r.Wants) == 0 {
112+
func (req *UploadRequest) Validate() error {
113+
if len(req.Wants) == 0 {
114114
return fmt.Errorf("want can't be empty")
115115
}
116116

117-
if err := r.validateRequiredCapabilities(); err != nil {
117+
if err := req.validateRequiredCapabilities(); err != nil {
118118
return err
119119
}
120120

121-
if err := r.validateConflictCapabilities(); err != nil {
121+
if err := req.validateConflictCapabilities(); err != nil {
122122
return err
123123
}
124124

125125
return nil
126126
}
127127

128-
func (r *UploadRequest) validateRequiredCapabilities() error {
128+
func (req *UploadRequest) validateRequiredCapabilities() error {
129129
msg := "missing capability %s"
130130

131-
if len(r.Shallows) != 0 && !r.Capabilities.Supports(capability.Shallow) {
131+
if len(req.Shallows) != 0 && !req.Capabilities.Supports(capability.Shallow) {
132132
return fmt.Errorf(msg, capability.Shallow)
133133
}
134134

135-
switch r.Depth.(type) {
135+
switch req.Depth.(type) {
136136
case DepthCommits:
137-
if r.Depth != DepthCommits(0) {
138-
if !r.Capabilities.Supports(capability.Shallow) {
137+
if req.Depth != DepthCommits(0) {
138+
if !req.Capabilities.Supports(capability.Shallow) {
139139
return fmt.Errorf(msg, capability.Shallow)
140140
}
141141
}
142142
case DepthSince:
143-
if !r.Capabilities.Supports(capability.DeepenSince) {
143+
if !req.Capabilities.Supports(capability.DeepenSince) {
144144
return fmt.Errorf(msg, capability.DeepenSince)
145145
}
146146
case DepthReference:
147-
if !r.Capabilities.Supports(capability.DeepenNot) {
147+
if !req.Capabilities.Supports(capability.DeepenNot) {
148148
return fmt.Errorf(msg, capability.DeepenNot)
149149
}
150150
}
151151

152152
return nil
153153
}
154154

155-
func (r *UploadRequest) validateConflictCapabilities() error {
155+
func (req *UploadRequest) validateConflictCapabilities() error {
156156
msg := "capabilities %s and %s are mutually exclusive"
157-
if r.Capabilities.Supports(capability.Sideband) &&
158-
r.Capabilities.Supports(capability.Sideband64k) {
157+
if req.Capabilities.Supports(capability.Sideband) &&
158+
req.Capabilities.Supports(capability.Sideband64k) {
159159
return fmt.Errorf(msg, capability.Sideband, capability.Sideband64k)
160160
}
161161

162-
if r.Capabilities.Supports(capability.MultiACK) &&
163-
r.Capabilities.Supports(capability.MultiACKDetailed) {
162+
if req.Capabilities.Supports(capability.MultiACK) &&
163+
req.Capabilities.Supports(capability.MultiACKDetailed) {
164164
return fmt.Errorf(msg, capability.MultiACK, capability.MultiACKDetailed)
165165
}
166166

plumbing/protocol/packp/ulreq_decode.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import (
1414

1515
// Decode reads the next upload-request form its input and
1616
// stores it in the UploadRequest.
17-
func (u *UploadRequest) Decode(r io.Reader) error {
17+
func (req *UploadRequest) Decode(r io.Reader) error {
1818
d := newUlReqDecoder(r)
19-
return d.Decode(u)
19+
return d.Decode(req)
2020
}
2121

2222
type ulReqDecoder struct {

plumbing/protocol/packp/ulreq_encode.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import (
1515
// All the payloads will end with a newline character. Wants and
1616
// shallows are sorted alphabetically. A depth of 0 means no depth
1717
// request is sent.
18-
func (u *UploadRequest) Encode(w io.Writer) error {
18+
func (req *UploadRequest) Encode(w io.Writer) error {
1919
e := newUlReqEncoder(w)
20-
return e.Encode(u)
20+
return e.Encode(req)
2121
}
2222

2323
type ulReqEncoder struct {

plumbing/protocol/packp/updreq.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ func NewReferenceUpdateRequestFromCapabilities(adv *capability.List) *ReferenceU
6868
return r
6969
}
7070

71-
func (r *ReferenceUpdateRequest) validate() error {
72-
if len(r.Commands) == 0 {
71+
func (req *ReferenceUpdateRequest) validate() error {
72+
if len(req.Commands) == 0 {
7373
return ErrEmptyCommands
7474
}
7575

76-
for _, c := range r.Commands {
76+
for _, c := range req.Commands {
7777
if err := c.validate(); err != nil {
7878
return err
7979
}

plumbing/protocol/packp/updreq_encode.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,33 @@ var (
1414
)
1515

1616
// Encode writes the ReferenceUpdateRequest encoding to the stream.
17-
func (r *ReferenceUpdateRequest) Encode(w io.Writer) error {
18-
if err := r.validate(); err != nil {
17+
func (req *ReferenceUpdateRequest) Encode(w io.Writer) error {
18+
if err := req.validate(); err != nil {
1919
return err
2020
}
2121

2222
e := pktline.NewEncoder(w)
2323

24-
if err := r.encodeShallow(e, r.Shallow); err != nil {
24+
if err := req.encodeShallow(e, req.Shallow); err != nil {
2525
return err
2626
}
2727

28-
if err := r.encodeCommands(e, r.Commands, r.Capabilities); err != nil {
28+
if err := req.encodeCommands(e, req.Commands, req.Capabilities); err != nil {
2929
return err
3030
}
3131

32-
if r.Packfile != nil {
33-
if _, err := io.Copy(w, r.Packfile); err != nil {
32+
if req.Packfile != nil {
33+
if _, err := io.Copy(w, req.Packfile); err != nil {
3434
return err
3535
}
3636

37-
return r.Packfile.Close()
37+
return req.Packfile.Close()
3838
}
3939

4040
return nil
4141
}
4242

43-
func (r *ReferenceUpdateRequest) encodeShallow(e *pktline.Encoder,
43+
func (req *ReferenceUpdateRequest) encodeShallow(e *pktline.Encoder,
4444
h *plumbing.Hash) error {
4545

4646
if h == nil {
@@ -51,7 +51,7 @@ func (r *ReferenceUpdateRequest) encodeShallow(e *pktline.Encoder,
5151
return e.Encodef("%s%s", shallow, objId)
5252
}
5353

54-
func (r *ReferenceUpdateRequest) encodeCommands(e *pktline.Encoder,
54+
func (req *ReferenceUpdateRequest) encodeCommands(e *pktline.Encoder,
5555
cmds []*Command, cap *capability.List) error {
5656

5757
if err := e.Encodef("%s\x00%s",

storage/memory/storage.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ func (o *ObjectStorage) DeleteOldObjectPackAndIndex(plumbing.Hash, time.Time) er
195195

196196
var errNotSupported = fmt.Errorf("Not supported")
197197

198-
func (s *ObjectStorage) LooseObjectTime(hash plumbing.Hash) (time.Time, error) {
198+
func (o *ObjectStorage) LooseObjectTime(hash plumbing.Hash) (time.Time, error) {
199199
return time.Time{}, errNotSupported
200200
}
201-
func (s *ObjectStorage) DeleteLooseObject(plumbing.Hash) error {
201+
func (o *ObjectStorage) DeleteLooseObject(plumbing.Hash) error {
202202
return errNotSupported
203203
}
204204

0 commit comments

Comments
 (0)