TreeEntry: accept either a path or a TreeEntry

A path is only useful if we have the file on the worktree. Passing a
TreeEntry allows us to add an entry with arbitrary attributes.