libgit2
Clone

#include <git2.h>
#include <iostream>

int main(int argc, char* argv[])
{
    // Initialize the library
    int n = git_libgit2_init();
    std::cout << "git_libgit2_init: " << n << std::endl;

    // Clone an existing repository into a directory called 
    // Libgit2ClonedRepo1. The git_clone function clones the
    // repository and returns a corresponding git_repository
    // instance to interact with the repository.
    // This example doesn't show any progress information while
    // creating the clone. The GitClone2 example does.
    git_repository* repo = 0;
    int err = git_clone(&repo, "https://git01.codeplex.com/needfulsoftwaretutorials", "Libgit2ClonedRepo1", 0);
    if (err == 0)
    {
        std::cout << "Repository cloned successfully" << std::endl;

        git_repository_free(repo);
    }
    else
    {
        std::cout << "Error: git_clone failed" << std::endl;
    }

    // git_libgit2_shutdown should be called
    // once for every call to git_libgit2_init
    n = git_libgit2_shutdown();
    std::cout << "git_libgit2_shutdown: " << n << std::endl;

    return 0;
}

blog comments powered by Disqus

Copyright(c) 2006-2017 Xavier Leclercq | Privacy policy

Home
Contact Us
Search