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