try to detect repo from tree-entry in tree-entry->object

This allows a tree-entry to be passed to tree-entry->object without an
accompanying repository argument.