Fix tree object creation when using non-root target directory (#2)

TreeFormatter only creates one tree object. Before, the code would just
add objects using paths such as "foo/bar", when instead the tree needs
to have "foo" as a tree, which has "bar" as a blob.

To correctly create these intermediate tree objects, construct a
DirCache with the entries of all input trees, and then let it construct
the combined tree.

This is slower than just reusing the trees, but it produces correct
output and enables specifying overlapping target directories, such as
"first:a/b/1" "second:a/b/2".