8000 Better safehandles by bording · Pull Request #2130 · libgit2/libgit2sharp · GitHub
[go: up one dir, main page]

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
WIP
  • Loading branch information
bording committed Dec 1, 2024
commit 070d9c3176de4223cfc3a89abd333e21e2882785
4 changes: 2 additions & 2 deletions LibGit2Sharp/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ internal Configuration(
private void Init(Repository repository)
{
configHandle = Proxy.git_config_new();
RepositoryHandle repoHandle = (repository != null) ? repository.Handle : null;
RepositoryHandle repoHandle = repository?.Handle ?? new RepositoryHandle();

if (repoHandle != null)
if (!repoHandle.IsInvalid)
{
//TODO: push back this logic into libgit2.
// As stated by @carlosmn "having a helper function to load the defaults and then allowing you
Expand Down
4 changes: 1 addition & 3 deletions LibGit2Sharp/Core/Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,7 @@ public static unsafe SignatureInfo git_commit_extract_signature(RepositoryHandle

public static unsafe void git_config_add_file_ondisk(ConfigurationHandle config, FilePath path, ConfigurationLevel level, RepositoryHandle repo)
{
// RepositoryHandle does implicit cast voodoo that is not null-safe, thus this explicit check
RepositoryHandle repoHandle = (repo != null) ? (RepositoryHandle)repo : null;
int res = NativeMethods.git_config_add_file_ondisk(config, path, (uint)level, repoHandle, true);
int res = NativeMethods.git_config_add_file_ondisk(config, path, (uint)level, repo, true);
Ensure.ZeroResult(res);
}

Expand Down
Loading
0