Repository.Checkout() doesn't unstage submodule changes

未關閉
#1,206 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
35/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
csharp, git
領域
tooling

研究方向

從 Repository.Checkout 開始,使用 CheckoutModifiers.Force 重現所示的已暫存子模組情境。將其結果與 git checkout master --force 以及現有的 Reset(ResetMode.Hard, "master") 行為進行比較;當 Checkout 與 Git 一致地取消暫存子模組變更,或將差異記錄為預期行為時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

If I have a repo in this status

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

        modified:   App_Data/Submodule
        modified:   file.txt

with App_Data/Submodule being a git submodule and file.txt is just a normal file.

Running git checkout master --force will put the repo in this condition

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:   App_Data/Submodule (new commits)

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

but doing the same from LibGit2Sharp using the following code

using (var repo = new LibGit2Sharp.Repository(RepositoryPath))
{
  repo.Checkout("master", new CheckoutOptions { CheckoutModifiers = CheckoutModifiers.Force });
}

leaves the repo in this state

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

        modified:   App_Data/Submodule

Calling reset however works as expected.

using (var repo = new LibGit2Sharp.Repository(RepositoryPath))
{
    repo.Reset(ResetMode.Hard, "master");
}

Is that behavior expected from LibGit2Sharp? Should I be calling Reset myself if I want to mirror exactly the same git behavior?

ref: http://stackoverflow.com/q/33030355/3234163

主要語言
C#
星號
3.5k
分支
925
PR 合併指標
30 天內沒有已合併 PR

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

libgit2/libgit2sharp 的其他 Issue

查看 libgit2/libgit2sharp 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。