1

在 Windows XP 32 位机器上,我使用克隆了 libgit2 存储库

git clone git://github.com/libgit2/libgit2.git trunk

然后我从trunk_build_debug为mingw配置了:

cmake ../trunk -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-g 

并用

make

使用这个新建的库,我正在尝试创建一个新的存储库。所以我正在使用

    error_code = git_repository_init( &repo, path, 0 );
    if ( error_code != 0 )
    {
        const git_error * error = giterr_last();
       /* the text representation:
        ( error == NULL || error->message == NULL ? 
        "(no description)" : 
        error->message )
        */
    }

第一次尝试失败并显示错误消息:

Git错误-1:全局文件'.config/git/config'不存在:系统找不到指定的文件。

.git 目录已创建,我可以使用git status它来查询它。另外,我在 Program Files/git 中安装了 git,它工作得很好。提到的文件在用户目录中不存在,这是真的。我不高兴,因为我无法检查返回的错误代码(错误可能是“真实的”)。

所以我在 D:\Documents and Settings\User Name.config\git\config 中创建了一个空文件 .git 目录再次创建,但我得到相同的 -1 错误代码。这次 giterr_last() 返回 NULL。

在调试器中跟踪代码似乎表明该库对我的空文件不满意。

但是,我认为这表明我做错了什么。有初始化方法吗?我是否需要创建文件并使用 git_config_ 函数将库指向它?

顺便说一句,这是问这个错误的地方吗?有专门的论坛我应该问这个问题吗?

谢谢


这是调用失败的回溯:pastebin 似乎无法解析 .git 目录中的配置文件(跟踪中未显示的是失败的 'config_parse()')。


我在 libgit2 中打开了一个问题。

4

1 回答 1

4

To create a new repository, one should rather rely on git_repository_init(). For more information, you can peek at the header and the tests.

git_repository_open() should rather be used when the repository already exists.

Is there a dedicated forum where I should ask this question?

It's ok to ask programming related question on StackOverflow. Beside this, some libgit2 developers hang out in the #libgit2 channel on irc.freenode.net. However, when you encounter bugs, it's recommended to submit them to the issue tracker.

Update

  • There had been some issues in the past with the way the configuration files are being probbed on Windows. Along with some attempts to fix them. See this issue for some background about this.
  • Beside the complexity of the probbing, some users may want to explictly provide alternate locations for their files. This pull request works this angle.

Considering what you discovered while debugging the libgit2, maybe now would be a good time to open a bug in the issue tracker. Beware that two issues may be at play: the probbing one and and the empty config issue.

于 2013-03-06T13:38:29.080 回答