File returns the hash of the file identified by the `path` argument. The path is interpreted as relative to the tree receiver.
(path string)
| 75 | // File returns the hash of the file identified by the `path` argument. |
| 76 | // The path is interpreted as relative to the tree receiver. |
| 77 | func (t *Tree) File(path string) (*File, error) { |
| 78 | e, err := t.FindEntry(path) |
| 79 | if err != nil { |
| 80 | return nil, ErrFileNotFound |
| 81 | } |
| 82 | |
| 83 | blob, err := GetBlob(t.s, e.Hash) |
| 84 | if err != nil { |
| 85 | if err == plumbing.ErrObjectNotFound { |
| 86 | return nil, ErrFileNotFound |
| 87 | } |
| 88 | return nil, err |
| 89 | } |
| 90 | |
| 91 | return NewFile(path, e.Mode, blob), nil |
| 92 | } |
| 93 | |
| 94 | // Size returns the plaintext size of an object, without reading it |
| 95 | // into memory. |