Feature request: Create blobs in-memory
還沒有人認領這個 Issue。
評估
研究方向
首先,追蹤 libgit2sharp API 中 Blob 的建構、ObjectDatabase.Write 和 Diff.Compare。所要求的行為是從字串或串流建立 blob,並將它們傳遞給記憶體中的 diff,而不寫入磁碟或要求使用以磁碟為基礎的儲存庫;使用 issue 中顯示的舊內容和新內容進行驗證。
由索引模型根據 Issue 內容生成。
描述
I would like to make a diff between two strings with libgit2sharp. The strings hold file contents loaded elsewhere. The diff.Compare-methods only take blobs, and the constructors of the Blobclass don't accept strings or streams and are marked internal. This prevents me from creating blobs directly. I have to write to disk first.
var oldFileContents = @"
Line 1
Line 2
Line 3
";
var newFileContents = @"
Line 1
Line 2 has changed
";
var path = Repository.Init("C:\\tmp");
var repo = new Repository(path);
var oldObjectId = repo.ObjectDatabase.Write<Blob>(Encoding.UTF8.GetBytes(oldFileContents));
var newObjectId = repo.ObjectDatabase.Write<Blob>(Encoding.UTF8.GetBytes(newFileContents));
var oldBlob = repo.Lookup<Blob>(oldObjectId);
var newBlob = repo.Lookup<Blob>(newObjectId);
var diff = repo.Diff.Compare(oldBlob, newBlob); // Works as expected
// git repo for in-memory operations
var in_memory_repo = new Repository();
// This line failes with the LibGit2SharpException "path cannot exist in repository". As far as I can see this is intentional.
var in_memory_blob = in_memory_repo.ObjectDatabase.Write<Blob>(Encoding.UTF8.GetBytes(oldFileContents));
Seeing that libgit2sharp already supports working with diffs and patches in-memory, it would be nice to be able to create blobs from strings or streams.
- 主要語言
- C#
- 星號
- 3.5k
- 分支
- 925
- PR 合併指標
- 30 天內沒有已合併 PR
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
libgit2/libgit2sharp 的其他 Issue
-
難度 4/5 3-5 天 新手友好度 52/100
libgit2/libgit2sharp#2193 · 2 則留言 ·
-
難度 4/5 3-5 天 新手友好度 38/100
libgit2/libgit2sharp#2192 · 1 則留言 ·
-
Website is down 未關閉
難度 4/5 3-5 天 新手友好度 20/100
libgit2/libgit2sharp#2191 · 2 個 reaction ·
-
難度 3/5 1-2 天 新手友好度 68/100
libgit2/libgit2sharp#2189 · 1 個 reaction ·
-
難度 3/5 1-2 天 新手友好度 35/100
libgit2/libgit2sharp#2187 · 2 則留言 ·
查看 libgit2/libgit2sharp 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
難度 2/5 1-3 小時 新手友好度 92/100
dotnet/AspNetCore.Docs#37699 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
SubtitleEdit/subtitleedit#15108 · 1 則留言 ·
-
area/docs-content Bug pulumi/docs
難度 1/5 1-3 小時 新手友好度 94/100
-
agentic-workflows untriaged
難度 2/5 1-3 小時 新手友好度 76/100