diff --git a/libGitWrap/Repository.cpp b/libGitWrap/Repository.cpp index 06c0c92..956bcba 100644 --- a/libGitWrap/Repository.cpp +++ b/libGitWrap/Repository.cpp @@ -171,6 +171,30 @@ namespace Git * @brief Represents a Git repository. */ + /** + * @brief Clone a Git repository. + * + * @param[in,out] result A Result object; see @ref GitWrapErrorHandling + * + * @param[in] from the URL to clone from + * + * @param[in] to the path to clone to + * + * @return the cloned repository + */ + Repository Repository::clone(Result& result, const QString& from, const QString& to) + { + GW_CHECK_RESULT(result, nullptr); + + // TODO: setup clone options and callbacks + + git_repository* clonedRepo = nullptr; + result = git_clone(&clonedRepo, GW_StringFromQt(from), GW_StringFromQt(to), nullptr /*TODO: clone options*/); + GW_CHECK_RESULT(result, nullptr); + + return new Private(clonedRepo); + } + /** * @brief Create a new repository * diff --git a/libGitWrap/Repository.hpp b/libGitWrap/Repository.hpp index c475fba..2c731a6 100644 --- a/libGitWrap/Repository.hpp +++ b/libGitWrap/Repository.hpp @@ -43,6 +43,11 @@ namespace Git GW_PRIVATE_DECL(Repository, Base, public) public: + static Repository clone(Result& result, + const QString& from, + const QString& to + /*TODO: options*/); + static Repository create(Result& result, const QString& path, bool bare);