summary refs log tree commit diff
path: root/LibGit/GitRepo.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-12-11 18:54:56 +0100
committerRory& <root@rory.gay>2025-12-11 18:54:56 +0100
commit6e2f48e24b0c003b4c8547ff88fc1a7f890a1c1e (patch)
tree7aac58a3a1045bde51e989cb0a1ab1c26c28e68f /LibGit/GitRepo.cs
parentnet10 (diff)
downloadGitTools-6e2f48e24b0c003b4c8547ff88fc1a7f890a1c1e.tar.xz
read indexes and packs correctly
Diffstat (limited to 'LibGit/GitRepo.cs')
-rw-r--r--LibGit/GitRepo.cs13
1 files changed, 11 insertions, 2 deletions
diff --git a/LibGit/GitRepo.cs b/LibGit/GitRepo.cs

index a58bc38..045df6c 100644 --- a/LibGit/GitRepo.cs +++ b/LibGit/GitRepo.cs
@@ -54,6 +54,12 @@ public class GitRepo public async IAsyncEnumerable<GitPack> GetPacks() { + if (!await RepoSource.FileExists("objects/info/packs")) + { + Console.WriteLine("No pack index found."); + yield break; + } + var fs = await RepoSource.GetFileStream("objects/info/packs"); Console.WriteLine("Found packs file:"); fs.Peek(32).HexDump(32); @@ -62,17 +68,20 @@ public class GitRepo Console.WriteLine("WARNING: No packs found!"); yield break; } + while (fs.Remaining() > 0 && fs.Peek() != 0x0A) { //example: P pack-24bd1c46d657f74f40629503d8e5083a9ad36a67.pack var line = fs.ReadTerminatedField((byte)'\n').AsString(); if (line.StartsWith("P ")) { - new GitPackIndex().Read(await RepoSource.GetFileStream($"objects/pack/{line[2..].Replace(".pack", ".idx")}")); + Console.WriteLine($"Reading pack: {RepoSource.BasePath}/objects/pack/{line[2..]}"); + var packStream = await RepoSource.GetFileStream($"objects/pack/{line[2..]}"); + var idxStream = await RepoSource.GetFileStream($"objects/pack/{line[2..].Replace(".pack", ".idx")}"); yield return new GitPack( packId: line[2..], repo: this - ).Read(await RepoSource.GetFileStream($"objects/pack/{line[2..]}")); + ).Read(packStream, idxStream); } else {