它会提示:系统文件'gitconfig'不存在 这是我的代码:
#include <windows.h>
#include <wchar.h>
#include "include/git2.h"
#ifdef _DEBUG
#pragma comment(lib, "git2d.lib")
#else
#pragma comment(lib, "git2.lib")
#endif
int main(int argc, char* argv[])
{
git_threads_init();
git_repository* repo = NULL;
int iRetVal = git_repository_init(&repo, (LPCTSTR)("C:\\test"), false);
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;
}
iRetVal返回-1并且'repo'为NULL,但是在C:\ test中创建的存储库 我知道有三种类型的配置:system,xdg,global,什么样的配置以及放置它的位置?
第二个问题的代码是:
#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;
}