IndexEntry: make the attributes writable

When updating entries in an index, it is necessary to modify the
attributes of tree entries. make it possible to do so.
Index: accept adding either a path or an IndexEntry

A path is only useful if we have the file on the worktree. Passing an
IndexEntry allows us to add an entry with arbitrary attributes.
Index: allow writing the tree to a particular repository

Take an optional repository in Index.write_tree() to serialize to a tree
into a particular repository's odb.