Skip to content

Better safehandles #2130

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

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
WIP
  • Loading branch information
bording committed Nov 28, 2024
commit 01a3711ee98bd90a4fb73eb2c832873c77cd384c
11 changes: 9 additions & 2 deletions LibGit2Sharp/BlameHunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using System.Globalization;
using LibGit2Sharp.Core;
using LibGit2Sharp.Core.Handles;

namespace LibGit2Sharp
{
Expand Down Expand Up @@ -42,12 +43,18 @@ internal unsafe BlameHunk(IRepository repository, git_blame_hunk* rawHunk)
// Signature objects need to have ownership of their native pointers
if (rawHunk->final_signature != null)
{
FinalSignature = new Signature(rawHunk->final_signature);
var ptr = new IntPtr(rawHunk->final_signature);
var signatureHandle = new SignatureHandle(ptr, false);

FinalSignature = new Signature(signatureHandle);
}

if (rawHunk->orig_signature != null)
{
InitialSignature = new Signature(rawHunk->orig_signature);
var ptr = new IntPtr(rawHunk->orig_signature);
var signatureHandle = new SignatureHandle(ptr, false);

InitialSignature = new Signature(signatureHandle);
}
}

Expand Down
3 changes: 1 addition & 2 deletions LibGit2Sharp/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ internal static extern int git_error_set_str(
internal static extern unsafe uint git_blame_get_hunk_count(BlameHandle blame);

[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe git_blame_hunk* git_blame_get_hunk_byindex(
BlameHandle blame, uint index);
internal static extern unsafe git_blame_hunk* git_blame_get_hunk_byindex(BlameHandle blame, uint index);

[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_blame_file(
Expand Down
7 changes: 4 additions & 3 deletions LibGit2Sharp/FilterSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ internal unsafe FilterSource(FilePath path, FilterMode mode, git_filter_source*
SourceMode = mode;
ObjectId = ObjectId.BuildFromPtr(&source->oid);
Path = path.Native;
Root = Proxy.git_repository_workdir(new IntPtr(source->repository)).Native;

Root = Proxy.git_repository_workdir(source->repository).Native;
}

/// <summary>
/// Take an unmanaged pointer and convert it to filter source callback paramater
/// Take an unmanaged pointer and convert it to filter source callback parameter.
/// </summary>
/// <param name="ptr"></param>
/// <returns></returns>
Expand All @@ -32,7 +33,7 @@ internal static unsafe FilterSource FromNativePtr(IntPtr ptr)
}

/// <summary>
/// Take an unmanaged pointer and convert it to filter source callback paramater
/// Take an unmanaged pointer and convert it to filter source callback parameter.
/// </summary>
/// <param name="ptr"></param>
/// <returns></returns>
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy