using LibGit; namespace LibGitTest; public class Test1 { public static async Task Run() { var repo = new GitRepo(new FileRepoSource(@"/home/root@Rory/tmpgit/MatrixRoomUtils.git")); // var repo = new GitRepo(new WebRepoSource("https://git.rory.gay/MatrixRoomUtils.git/")); var commit = await repo.GetCommit("HEAD"); while (commit.ParentIds.Count > 0) { Console.WriteLine($"{commit.CommitId[..7]} | {commit.AuthorName.PadRight(16)} | {commit.Message.PadRight(32)[..32]} | {commit.TreeId}"); var tree = await commit.GetTreeAsync(); await PrintTreeRecursive(tree); commit = await repo.GetCommit(commit.ParentIds.First()); } async Task PrintTreeRecursive(TreeObject tree, int indent = 0) { foreach (var (key, value) in tree.Entries.Where(x => x.Value.Mode.StartsWith("1"))) { Console.WriteLine($"{value.Mode.PadLeft(6)} {value.Hash}{"".PadRight(indent)} {key}"); } foreach (var (key, value) in tree.Entries.Where(x => !x.Value.Mode.StartsWith("1"))) { Console.WriteLine($"{value.Mode.PadLeft(6)}{"".PadRight(indent + 41)} {key + "/"}"); await PrintTreeRecursive(new TreeObject(tree.RepoSource, value.Hash).ReadFromZlibCompressedObjFile(await tree.RepoSource.GetObjectStreamById(value.Hash)), indent + 2); } } } }