libgit2 / libgit2/libgit2sharp

Commands.Move is different from git mv

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

還沒有人認領這個 Issue。

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

描述

If I use git mv from the command line, I do not lose my history. It is a rename in the history.

If I use Commands.Move it looks in the git log like a file delete and a file create, therefore losing my history. The file is renamed in the file system, but git didn't see the rename.

I'm using libgit2sharp version 0.31.0 with VS 2022 building with .NET 8 and C# version 13 on Windows 11.

My code looks like:

try
{
    using (var repo = new Repository(repoRoot))
    {
        // Moves the file. Path must be in Posix format (using '/' as path separator)
        Commands.Move(repo, oldPath, newPath);
        ok = true;
    }
}
catch (Exception ex)
{
    Error = "Git Move exception: " + ex.Message;
}

Am I doing something wrong? I convert the Windows path format to Posix format before using them.

貢獻指南

開啟貢獻指南

從這裡開始

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

研究方向

從 Commands.Move 進入點開始,重現提供的 oldPath/newPath 情況,並將其產生的 git log 與命令列 git mv 的行為進行比較。當行為差異得到解釋,且 issue 有已確認的修正或已記錄的預期行為時,即視為完成。

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

評估

技術堆疊
csharp, git
領域
devtools
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
35/100

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

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