Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibGit2: Remove TryCopyBlob #34

Merged
merged 1 commit into from
Aug 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions GVFS/GVFS.Common/Git/LibGit2Repo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,46 +114,6 @@ public virtual bool ObjectExists(string sha)
return true;
}

public virtual bool TryCopyBlob(string sha, Action<Stream, long> writeAction)
{
IntPtr objHandle;
if (Native.RevParseSingle(out objHandle, this.RepoHandle, sha) != Native.SuccessCode)
{
return false;
}

try
{
unsafe
{
switch (Native.Object.GetType(objHandle))
{
case Native.ObjectTypes.Blob:
byte* originalData = Native.Blob.GetRawContent(objHandle);
long originalSize = Native.Blob.GetRawSize(objHandle);

// TODO: This will fail in the non-virtualized world, as
// we actually need to write the data to disk instead of
// going through a filter driver!
using (Stream mem = new UnmanagedMemoryStream(originalData, originalSize))
{
writeAction(mem, originalSize);
}

break;
default:
throw new NotSupportedException("Copying object types other than blobs is not supported.");
}
}
}
finally
{
Native.Object.Free(objHandle);
}

return true;
}

public void Dispose()
{
this.Dispose(true);
Expand Down
5 changes: 0 additions & 5 deletions GVFS/GVFS.UnitTests/Mock/Git/MockLibGit2Repo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,5 @@ public override bool ObjectExists(string sha)
{
return false;
}

public override bool TryCopyBlob(string sha, Action<Stream, long> writeAction)
{
throw new NotSupportedException();
}
}
}