Skip to content
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
Binary file added Lib/NativeBinaries/amd64/git2-3f8d005.dll
Binary file not shown.
Binary file not shown.
Binary file removed Lib/NativeBinaries/amd64/git2-e0383fa.dll
Binary file not shown.
Binary file added Lib/NativeBinaries/x86/git2-3f8d005.dll
Binary file not shown.
Binary file not shown.
Binary file removed Lib/NativeBinaries/x86/git2-e0383fa.dll
Binary file not shown.
25 changes: 5 additions & 20 deletions LibGit2Sharp.Tests/RemoteFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,14 @@ public void CanRenameExistingRemote()
}

[Fact]
public void CanRenameNonExistingRemote()
public void RenamingNonExistingRemoteThrows()
{
using (var repo = new Repository(StandardTestRepoPath))
{
Assert.Null(repo.Network.Remotes["i_dont_exist"]);

repo.Network.Remotes.Rename("i_dont_exist", "i_dont_either", problem => Assert.True(false));
Assert.Null(repo.Network.Remotes["i_dont_either"]);
Assert.Throws<NotFoundException>(() =>
{
repo.Network.Remotes.Rename("i_dont_exist", "i_dont_either");
});
}
}

Expand Down Expand Up @@ -327,20 +327,5 @@ public void CanNotRenameWhenRemoteWithSameNameExists()
Assert.Throws<NameConflictException>(() => repo.Network.Remotes.Rename("origin", "upstream"));
}
}

[Theory]
[InlineData("git@github.com:org/repo.git", false)]
[InlineData("git://site.com:80/org/repo.git", true)]
[InlineData("ssh://user@host.com:80/org/repo.git", false)]
[InlineData("http://site.com:80/org/repo.git", true)]
[InlineData("https://github.com:80/org/repo.git", true)]
[InlineData("ftp://site.com:80/org/repo.git", false)]
[InlineData("ftps://site.com:80/org/repo.git", false)]
[InlineData("file:///path/repo.git", true)]
[InlineData("protocol://blah.meh/whatever.git", false)]
public void CanCheckIfUrlisSupported(string url, bool supported)
{
Assert.Equal(supported, Remote.IsSupportedUrl(url));
}
}
}
4 changes: 2 additions & 2 deletions LibGit2Sharp/Core/GitDiff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ internal class GitDiffOptions : IDisposable

/* options controlling how to diff text is generated */

public ushort ContextLines;
public ushort InterhunkLines;
public uint ContextLines;
public uint InterhunkLines;
public ushort IdAbbrev;
public Int64 MaxSize;
public IntPtr OldPrefixString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace LibGit2Sharp.Core.Handles
{
internal class GitMergeHeadHandle : SafeHandleBase
internal class GitAnnotatedCommitHandle : SafeHandleBase
{
protected override bool ReleaseHandleImpl()
{
Proxy.git_merge_head_free(handle);
Proxy.git_annotated_commit_free(handle);
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/Core/NativeDllName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace LibGit2Sharp.Core
{
internal static class NativeDllName
{
public const string Name = "git2-e0383fa";
public const string Name = "git2-3f8d005";
}
}
26 changes: 11 additions & 15 deletions LibGit2Sharp/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,19 +215,15 @@ internal static extern int git_branch_remote_name(
[DllImport(libgit2)]
internal static extern int git_remote_rename(
ref GitStrArray problems,
RemoteSafeHandle remote,
RepositorySafeHandle repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string old_name,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string new_name);

internal delegate int git_remote_rename_problem_cb(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))] string problematic_refspec,
IntPtr payload);


[DllImport(libgit2)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool git_remote_supported_url(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string url);

[DllImport(libgit2)]
internal static extern int git_branch_upstream_name(
GitBuf buf,
Expand Down Expand Up @@ -630,28 +626,28 @@ internal static extern int git_merge_base_octopus(
[In] GitOid[] input_array);

[DllImport(libgit2)]
internal static extern int git_merge_head_from_ref(
out GitMergeHeadHandle mergehead,
internal static extern int git_annotated_commit_from_ref(
out GitAnnotatedCommitHandle annotatedCommit,
RepositorySafeHandle repo,
ReferenceSafeHandle reference);

[DllImport(libgit2)]
internal static extern int git_merge_head_from_fetchhead(
out GitMergeHeadHandle mergehead,
internal static extern int git_annotated_commit_from_fetchhead(
out GitAnnotatedCommitHandle annotatedCommit,
RepositorySafeHandle repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string branch_name,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string remote_url,
ref GitOid oid);

[DllImport(libgit2)]
internal static extern int git_merge_head_from_id(
out GitMergeHeadHandle mergehead,
internal static extern int git_annotated_commit_lookup(
out GitAnnotatedCommitHandle annotatedCommit,
RepositorySafeHandle repo,
ref GitOid id);

[DllImport(libgit2)]
internal static extern OidSafeHandle git_merge_head_id(
GitMergeHeadHandle mergeHead);
internal static extern OidSafeHandle git_annotated_commit_id(
GitAnnotatedCommitHandle annotatedCommit);

[DllImport(libgit2)]
internal static extern int git_merge(
Expand All @@ -670,7 +666,7 @@ internal static extern int git_merge_analysis(
int their_heads_len);

[DllImport(libgit2)]
internal static extern void git_merge_head_free(
internal static extern void git_annotated_commit_free(
IntPtr merge_head);

[DllImport(libgit2)]
Expand Down
80 changes: 37 additions & 43 deletions LibGit2Sharp/Core/Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1048,54 +1048,54 @@ public static ObjectId git_merge_base_octopus(RepositorySafeHandle repo, GitOid[
}
}

public static GitMergeHeadHandle git_merge_head_from_fetchhead(RepositorySafeHandle repo, string branchName, string remoteUrl, GitOid oid)
public static GitAnnotatedCommitHandle git_annotated_commit_from_fetchhead(RepositorySafeHandle repo, string branchName, string remoteUrl, GitOid oid)
{
using (ThreadAffinity())
{
GitMergeHeadHandle merge_head;
GitAnnotatedCommitHandle merge_head;

int res = NativeMethods.git_merge_head_from_fetchhead(out merge_head, repo, branchName, remoteUrl, ref oid);
int res = NativeMethods.git_annotated_commit_from_fetchhead(out merge_head, repo, branchName, remoteUrl, ref oid);

Ensure.ZeroResult(res);

return merge_head;
}
}

public static GitMergeHeadHandle git_merge_head_from_id(RepositorySafeHandle repo, GitOid oid)
public static GitAnnotatedCommitHandle git_annotated_commit_lookup(RepositorySafeHandle repo, GitOid oid)
{
using (ThreadAffinity())
{
GitMergeHeadHandle their_head;
GitAnnotatedCommitHandle their_head;

int res = NativeMethods.git_merge_head_from_id(out their_head, repo, ref oid);
int res = NativeMethods.git_annotated_commit_lookup(out their_head, repo, ref oid);

Ensure.ZeroResult(res);

return their_head;
}
}

public static GitMergeHeadHandle git_merge_head_from_ref(RepositorySafeHandle repo, ReferenceSafeHandle reference)
public static GitAnnotatedCommitHandle git_annotated_commit_from_ref(RepositorySafeHandle repo, ReferenceSafeHandle reference)
{
using (ThreadAffinity())
{
GitMergeHeadHandle their_head;
GitAnnotatedCommitHandle their_head;

int res = NativeMethods.git_merge_head_from_ref(out their_head, repo, reference);
int res = NativeMethods.git_annotated_commit_from_ref(out their_head, repo, reference);

Ensure.ZeroResult(res);

return their_head;
}
}

public static ObjectId git_merge_head_id(GitMergeHeadHandle mergeHead)
public static ObjectId git_annotated_commit_id(GitAnnotatedCommitHandle mergeHead)
{
return NativeMethods.git_merge_head_id(mergeHead).MarshalAsObjectId();
return NativeMethods.git_annotated_commit_id(mergeHead).MarshalAsObjectId();
}

public static void git_merge(RepositorySafeHandle repo, GitMergeHeadHandle[] heads, GitMergeOpts mergeOptions, GitCheckoutOpts checkoutOptions)
public static void git_merge(RepositorySafeHandle repo, GitAnnotatedCommitHandle[] heads, GitMergeOpts mergeOptions, GitCheckoutOpts checkoutOptions)
{
using (ThreadAffinity())
{
Expand All @@ -1114,7 +1114,7 @@ public static void git_merge(RepositorySafeHandle repo, GitMergeHeadHandle[] hea

public static void git_merge_analysis(
RepositorySafeHandle repo,
GitMergeHeadHandle[] heads,
GitAnnotatedCommitHandle[] heads,
out GitMergeAnalysis analysis_out,
out GitMergePreference preference_out)
{
Expand All @@ -1133,9 +1133,9 @@ public static void git_merge_analysis(
}
}

public static void git_merge_head_free(IntPtr handle)
public static void git_annotated_commit_free(IntPtr handle)
{
NativeMethods.git_merge_head_free(handle);
NativeMethods.git_annotated_commit_free(handle);
}

#endregion
Expand Down Expand Up @@ -2125,39 +2125,38 @@ public static void git_remote_rename(RepositorySafeHandle repo, string name, str
{
using (ThreadAffinity())
{
using (RemoteSafeHandle remote = git_remote_load(repo, name, false))
if (callback == null)
{
if (remote == null)
{
return;
}
callback = problem => {};
}

if (callback == null)
{
callback = problem => {};
}
var array = new GitStrArrayNative();

var array = new GitStrArrayNative();
try
{
int res = NativeMethods.git_remote_rename(
ref array.Array,
repo,
name,
new_name);

try
if (res == (int)GitErrorCode.NotFound)
{
int res = NativeMethods.git_remote_rename(
ref array.Array,
remote,
new_name);
throw new NotFoundException(
string.Format("Remote '{0}' does not exist and cannot be renamed.", name));
}

Ensure.ZeroResult(res);
Ensure.ZeroResult(res);

foreach (var item in array.ReadStrings())
{
callback(item);
}
}
finally
foreach (var item in array.ReadStrings())
{
array.Dispose();
callback(item);
}
}
finally
{
array.Dispose();
}
}
}

Expand Down Expand Up @@ -2189,11 +2188,6 @@ public static string git_remote_url(RemoteSafeHandle remote)
return NativeMethods.git_remote_url(remote);
}

public static bool git_remote_supported_url(string url)
{
return NativeMethods.git_remote_supported_url(url);
}

#endregion

#region git_repository_
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/LibGit2Sharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<Compile Include="Core\Handles\ConfigurationIteratorSafeHandle.cs" />
<Compile Include="Core\GitBlame.cs" />
<Compile Include="Core\Handles\BlameSafeHandle.cs" />
<Compile Include="Core\Handles\GitMergeHeadHandle.cs" />
<Compile Include="Core\Handles\GitAnnotatedCommitHandle.cs" />
<Compile Include="Core\PushTransferProgressCallbacks.cs" />
<Compile Include="Core\PackbuilderCallbacks.cs" />
<Compile Include="HistoryDivergence.cs" />
Expand Down
10 changes: 0 additions & 10 deletions LibGit2Sharp/Remote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,6 @@ public static bool IsValidName(string name)
return Proxy.git_remote_is_valid_name(name);
}

/// <summary>
/// Determines if the proposed remote URL is supported by the library.
/// </summary>
/// <param name="url">The URL to be checked.</param>
/// <returns>true if the url is supported; false otherwise.</returns>
public static bool IsSupportedUrl(string url)
{
return Proxy.git_remote_supported_url(url);
}

/// <summary>
/// Determines whether the specified <see cref="Object"/> is equal to the current <see cref="Remote"/>.
/// </summary>
Expand Down
Loading