Handle Option<Hash> better

andybalholm
Mar 29, 2023, 9:50 PM
WQWRJHHFIZPMIZBDFZGOVTGSQRSIJP275I5MFSGLAR63FJQ4PQJQC

Dependencies

  • [2] EVHNGDT7 parse FileAdd hunk
  • [3] PHRWK7NK Parse change headers
  • [4] 4JWXOJIP Parse dependencies
  • [5] 7VEHGTEY Switch from reading text format to reading binary format.

Change contents

  • replacement in hunk.go at line 34
    [2.649][2.649:662]()
    Change Hash
    [2.649]
    [2.662]
    Change OptionalHash
  • replacement in hunk.go at line 38
    [2.688][2.688:743]()
    func optionalHash(data []byte) ([]byte, Hash, error) {
    [2.688]
    [2.743]
    type OptionalHash struct {
    Valid bool
    Hash
    }
    func (h OptionalHash) String() string {
    if !h.Valid {
    return "None"
    }
    return fmt.Sprintf("Some(%s)", h.Hash.String())
    }
    func optionalHash(data []byte) ([]byte, OptionalHash, error) {
  • replacement in hunk.go at line 53
    [2.797][2.797:824]()
    return data, Hash{}, err
    [2.797]
    [2.824]
    return data, OptionalHash{}, err
  • replacement in hunk.go at line 56
    [2.843][2.843:870]()
    return data, Hash{}, nil
    [2.843]
    [2.870]
    return data, OptionalHash{}, nil
  • replacement in hunk.go at line 58
    [2.873][2.873:896]()
    return data, *hp, nil
    [2.873]
    [2.896]
    return data, OptionalHash{true, *hp}, nil
  • replacement in hunk.go at line 75
    [2.1210][2.1210:1229]()
    IntroducedBy Hash
    [2.1210]
    [2.1229]
    IntroducedBy OptionalHash
  • replacement in hunk.go at line 91
    [2.1544][2.1544:1557]()
    Change Hash
    [2.1544]
    [2.1557]
    Change OptionalHash
  • edit in go.sum at line 1
    [3.31]
    [2.4161]
    github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
    github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
  • replacement in go.mod at line 10
    [2.4336][2.4336:4391]()
    require github.com/klausman/hexdump v1.0.0 // indirect
    [2.4336]
    require (
    github.com/davecgh/go-spew v1.1.1 // indirect
    github.com/klausman/hexdump v1.0.0 // indirect
    )
  • edit in change_test.go at line 8
    [3.411]
    [3.411]
    "github.com/davecgh/go-spew/spew"
  • replacement in change_test.go at line 32
    [2.5092][2.5092:5304]()
    Change: Hash{0xe7, 0x82, 0xb1, 0xd7, 0xe4, 0x17, 0x64, 0xe4, 0xfe, 0x45, 0x2d, 0x6f, 0x24, 0x22, 0x40, 0x26, 0x16, 0x12, 0xb7, 0x0f, 0x42, 0x70, 0xd9, 0xac, 0xd8, 0x4e, 0x5a, 0x82, 0xea, 0x85, 0xab, 0x57},
    [2.5092]
    [2.5304]
    Change: OptionalHash{true, Hash{0xe7, 0x82, 0xb1, 0xd7, 0xe4, 0x17, 0x64, 0xe4, 0xfe, 0x45, 0x2d, 0x6f, 0x24, 0x22, 0x40, 0x26, 0x16, 0x12, 0xb7, 0x0f, 0x42, 0x70, 0xd9, 0xac, 0xd8, 0x4e, 0x5a, 0x82, 0xea, 0x85, 0xab, 0x57}},
  • replacement in change_test.go at line 41
    [2.5458][2.5458:5479]()
    Change: Hash{},
    [2.5458]
    [2.5479]
    Change: OptionalHash{true, Hash{}},
  • replacement in change_test.go at line 48
    [2.5576][2.5576:5598]()
    Change: Hash{},
    [2.5576]
    [2.5598]
    Change: OptionalHash{},
  • replacement in change_test.go at line 57
    [2.5754][2.5754:5775]()
    Change: Hash{},
    [2.5754]
    [2.5775]
    Change: OptionalHash{true, Hash{}},
  • replacement in change_test.go at line 64
    [2.5872][2.5872:5894]()
    Change: Hash{},
    [2.5872]
    [2.5894]
    Change: OptionalHash{},
  • replacement in change_test.go at line 73
    [2.6049][2.6049:6070]()
    Change: Hash{},
    [2.6049]
    [2.6070]
    Change: OptionalHash{},
  • replacement in change_test.go at line 90
    [3.9280][3.9280:9330]()
    t.Fatalf("got %#v, want %#v", c, CB7A3P_golden)
    [3.9280]
    [3.700]
    t.Fatalf("got %s, want %s", spew.Sdump(c), spew.Sdump(CB7A3P_golden))
  • edit in change.go at line 32
    [3.1307]
    [3.1307]
    if h == (Hash{}) {
    return ""
    }