 
 deriving instance Show GitError
 
+
+
+retEither :: CInt -> IO (Either GitError a) -> IO (Either GitError a)
+retEither res f | res == 0  = f
+                | otherwise = return . Left . toEnum . fromIntegral $ res
+
+
+retMaybeRes :: CInt -> IO (Maybe GitError)
+retMaybeRes res | res == 0  = return Nothing
+                | otherwise = return $ Just . toEnum . fromIntegral $ res
+
+
 -------------------------------------------------------------------------------
 -- BEGIN: blob.h
 -------------------------------------------------------------------------------

  res <- {#call git_commit_parent#} parent c (fromIntegral n)
  retEither res $ fmap (Right . Commit) $ peek parent

{-
/**
 * Get the oid of a specified parent for a commit. This is different from
 * `git_commit_parent`, which will attempt to load the parent commit from
 * the ODB.
 *
 * @param commit a previously loaded commit.
 * @param n the position of the parent (from 0 to `parentcount`)
 * @return the id of the parent, NULL on error.
 */
GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned int n);

/**
 * Create a new commit in the repository using `git_object`
 * instances as parameters.

  pathStr  <- newCString path
  res      <- {#call git_blob_create_fromfile #} obj repo pathStr
  retMaybeRes res

-- TODO: CPtr here?
blobFromBuffer :: ObjID -> Repository -> CPtr -> IO (Maybe GitError)
