I have decided to try and migrate my project from using GitSharp to LibGit2Sharp since GitSharp is no longer actively maintained. With GitSharp I was able to access the raw bytes of any file checked into my repo given a branch. I cannot locate any documentation or example code of how this is done using LibGit2Sharp.
Can someone give me and example of how this is done?
The
Blob
type exposes aContent
property that returns abyte[]
.The following test in extracted from the BlobFixture.cs file and demonstrates usage of this property.
In this particular test, the Blob GitObject is directly retrieved through the
LookUp()
method. You can also access Blobs from theFiles
property of aTree
.Regarding your more specific request, the following unit test should show you how to access the raw bytes of a Blob from the tip of a
Branch
.Note: This test shows another way of accessing a
Blob
(as an abstractTreeEntry
). Thus, the use of the cast.