1

我正在尝试使用 C# 库 LibGit2Sharp 在另一个程序打开时添加和提交二进制文件。调用失败并出现Repository.Index.RetrieveStatus()异常:

为散列读取文件时出错:该进程无法访问该文件,因为另一个进程已锁定该文件的一部分。

但是,从 shell 调用的 git 二进制文件执行相同的操作没有问题:

$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   files/foo.bin

no changes added to commit (use "git add" and/or "git commit -a")

$ git add files/foo.bin

$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   files/foo.bin

有没有办法说服 LibGit2Sharp 表现得像记录的那样?

4

1 回答 1

1

给定一个文件由另一个进程持有,如果 git 在处理它时不畏缩,那么 libgit2 和 LibGit2Sharp 也不应该。

没有办法“强制 LibGit2Sharp 与它说是部分锁定的文件进行交互”。因为这是一个错误,它不应该这样表现。

您现在最好的做法是为问题跟踪器提供一个新条目,以便团队可以开始并进行错误搜索;-)

于 2014-06-14T07:41:39.337 回答