make commit_tree a library function