Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit af46dd5

Browse files
mueslimcuadros
authored andcommitted
*: fixed tautological error conditionsautological error conditions
- Added missing error handling around encodeCommitData and prevented shadowing err. - Removed tautological error checks. Signed-off-by: Christian Muehlhaeuser <[email protected]> (cherry picked from commit 7d76176)
1 parent d3c45dc commit af46dd5

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

plumbing/format/commitgraph/encoder.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ func NewEncoder(w io.Writer) *Encoder {
2424

2525
// Encode writes an index into the commit-graph file
2626
func (e *Encoder) Encode(idx Index) error {
27-
var err error
28-
2927
// Get all the hashes in the input index
3028
hashes := idx.Hashes()
3129

@@ -39,26 +37,26 @@ func (e *Encoder) Encode(idx Index) error {
3937
chunkSizes = append(chunkSizes, uint64(extraEdgesCount)*4)
4038
}
4139

42-
if err = e.encodeFileHeader(len(chunkSignatures)); err != nil {
40+
if err := e.encodeFileHeader(len(chunkSignatures)); err != nil {
4341
return err
4442
}
45-
if err = e.encodeChunkHeaders(chunkSignatures, chunkSizes); err != nil {
43+
if err := e.encodeChunkHeaders(chunkSignatures, chunkSizes); err != nil {
4644
return err
4745
}
48-
if err = e.encodeFanout(fanout); err != nil {
46+
if err := e.encodeFanout(fanout); err != nil {
4947
return err
5048
}
51-
if err = e.encodeOidLookup(hashes); err != nil {
49+
if err := e.encodeOidLookup(hashes); err != nil {
5250
return err
5351
}
5452
if extraEdges, err := e.encodeCommitData(hashes, hashToIndex, idx); err == nil {
5553
if err = e.encodeExtraEdges(extraEdges); err != nil {
5654
return err
5755
}
58-
}
59-
if err != nil {
56+
} else {
6057
return err
6158
}
59+
6260
return e.encodeChecksum()
6361
}
6462

plumbing/transport/server/server.go

-5
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,6 @@ func (s *rpSession) updateReferences(req *packp.ReferenceUpdateRequest) {
286286
continue
287287
}
288288

289-
if err != nil {
290-
s.setStatus(cmd.Name, err)
291-
continue
292-
}
293-
294289
ref := plumbing.NewHashReference(cmd.Name, cmd.New)
295290
err := s.storer.SetReference(ref)
296291
s.setStatus(cmd.Name, err)

remote.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ func (r *Remote) updateLocalReferenceStorage(
937937
updated = true
938938
}
939939

940-
if err == nil && forceNeeded {
940+
if forceNeeded {
941941
err = ErrForceNeeded
942942
}
943943

0 commit comments

Comments
 (0)