| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package git |
| 6 |
| 7 import ( |
| 8 "fmt" |
| 9 ) |
| 10 |
| 11 // Types /////////////////////////////////////////////////////////////////////// |
| 12 |
| 13 // Blob is a git Object which represents file data |
| 14 type Blob struct { |
| 15 id *ObjectID |
| 16 data string |
| 17 } |
| 18 |
| 19 // Constructors /////////////////////////////////////////////////////////////// |
| 20 |
| 21 // NewBlobFromRaw creates a new *Blob, calculating the ID() from |data| |
| 22 func NewBlobFromRaw(data []byte) *Blob { |
| 23 return NewBlobFromRawWithID(MakeObjectIDForData(BlobType, data), data) |
| 24 } |
| 25 |
| 26 // BlobFromRawWithID creates a new *Blob, trusting |id|. There is no |
| 27 // verification that |data| and |id| match. |
| 28 func NewBlobFromRawWithID(id Identifiable, data []byte) *Blob { |
| 29 return &Blob{id.ID(), string(data)} |
| 30 } |
| 31 |
| 32 // Member functions //////////////////////////////////////////////////////////// |
| 33 |
| 34 func (b *Blob) ID() *ObjectID { return b.id } |
| 35 func (b *Blob) Type() ObjectType { return BlobType } |
| 36 func (b *Blob) Complete() bool { return true } |
| 37 func (b *Blob) RawString() string { return b.data } |
| 38 func (b *Blob) String() string { |
| 39 return fmt.Sprintf("Blob(%s, <data len(%d)>)", b.ID(), len(b.data)) |
| 40 } |
| OLD | NEW |