 author (Commit c) = unsafePerformIO $
   return . Signature =<< {#call unsafe git_commit_author#} c
 
-{-
-/**
- * Get the tree pointed to by a commit.
- *
- * @param tree_out pointer where to store the tree object
- * @param commit a previously loaded commit.
- * @return 0 on success; error code otherwise
- */
-GIT_EXTERN(int) git_commit_tree(git_tree **tree_out, git_commit *commit);
-
+tree :: Commit -> IO (Either GitError Tree)
+tree (Commit c) = alloca $ \tree -> do
+  res <- {#call git_commit_tree#} tree c
+  retEither res $ fmap (Right . Tree) $ peek tree
+
+{-
 /**
  * Get the id of the tree pointed to by a commit. This differs from
  * `git_commit_tree` in that no attempts are made to fetch an object

retMaybeRes res | res == 0  = return Nothing
                | otherwise = return $ Just . toEnum . fromIntegral $ res

blobFromBuffer :: ObjID -> Repository -> CPtr -> IO (Maybe GitError)
blobFromBuffer (ObjID objId) (Repository repo) buf = do
  res <- {#call git_blob_create_frombuffer#} objId repo buf

newtype ObjID      = ObjID CPtr
newtype Commit     = Commit CPtr
newtype Signature  = Signature CPtr
newtype Tree       = Tree CPtr

defaultPort :: String
defaultPort = "9418" -- TODO: Import from net.h?
