Where to set username and password in git_clone in libgit2?

Hello, the question is, when I use libgit2 to clone the repo it will result in: "Failed to send request: security error occurred", code:

#include <windows.h>
#include "include/git2.h"

#pragma comment(lib, "git2.lib")

int main(int argc, char* argv[])
{
    git_threads_init();

    git_repository* repo = NULL;
    git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
    int iRetVal;

    opts.bare = true;
    iRetVal = git_clone(&repo, "https://github.com/libgit2/libgit2.git", "C:\\test", &opts);
    if( (iRetVal < 0) && (giterr_last() != NULL) )
    {
        MessageBox(NULL, giterr_last()->message, "gittest", MB_ICONERROR | MB_OK);
    }
    if( repo != NULL )
        git_repository_free(repo);

    git_threads_shutdown();
    return 0;
}

      

Libgit2 version - 0.21.2

+3


source to share


1 answer


You have to fill in the remote_callbacks

property git_clone_options

.



Thoses online :: clone.c tests that should perform authenticated cloning at startup.

+2


source







All Articles