【问题标题】:Force LibGit2Sharp to interact with files it says are partially locked强制 LibGit2Sharp 与其说是部分锁定的文件进行交互
【发布时间】:2014-06-14 02:52:47
【问题描述】:

我正在尝试使用 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 表现得像 documented

【问题讨论】:

    标签: c# libgit2sharp filelock


    【解决方案1】:

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

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

    您现在最好的做法是向 issue tracker 提供一个新条目,以便团队可以开始并开始寻找错误 ;-)

    【讨论】:

    • 感谢您的澄清。我希望可能有一个 RepositoryOptionsStatusOptions 标志我错过了“IgnoreLocks”之类的效果。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-24
    • 1970-01-01
    • 2011-07-01
    相关资源
    最近更新 更多