diff options
author | nulltoken <emeric.fermas@gmail.com> | 2015-05-29 08:59:08 +0300 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2015-05-29 08:59:08 +0300 |
commit | 27abed14f52809a7058b36a980778d8fc0caf50c (patch) | |
tree | 33ec1cc4487f0cf514cf18f2a87632fb083576a1 | |
parent | 73740ffed9574202bed2e74dfafb5ece021ae892 (diff) | |
parent | 6c12de4f4d0d56e0583ac60dc7e351c2447ee938 (diff) |
Merge pull request #1049 from libgit2/ntk/upgrade_nuget
Upgrade to libgit2 ff8d635
32 files changed, 372 insertions, 194 deletions
diff --git a/LibGit2Sharp.Tests/FetchFixture.cs b/LibGit2Sharp.Tests/FetchFixture.cs index 3b0d6597..89a7e8a6 100644 --- a/LibGit2Sharp.Tests/FetchFixture.cs +++ b/LibGit2Sharp.Tests/FetchFixture.cs @@ -134,6 +134,18 @@ namespace LibGit2Sharp.Tests var expectedFetchState = new ExpectedFetchState(remoteName); expectedFetchState.AddExpectedBranch(localBranchName, ObjectId.Zero, remoteInfo.BranchTips[remoteBranchName]); + // Let's account for opportunistic updates during the Fetch() call + if (!string.Equals("master", localBranchName, StringComparison.OrdinalIgnoreCase)) + { + expectedFetchState.AddExpectedBranch("master", ObjectId.Zero, remoteInfo.BranchTips["master"]); + } + + if (string.Equals("master", localBranchName, StringComparison.OrdinalIgnoreCase) + && !string.Equals("master", remoteBranchName, StringComparison.OrdinalIgnoreCase)) + { + expectedFetchState.AddExpectedBranch(remoteBranchName, ObjectId.Zero, remoteInfo.BranchTips[remoteBranchName]); + } + // Perform the actual fetch repo.Network.Fetch(remote, new string[] { refSpec }, new FetchOptions { TagFetchMode = TagFetchMode.None, diff --git a/LibGit2Sharp.Tests/RefSpecFixture.cs b/LibGit2Sharp.Tests/RefSpecFixture.cs index ea78f4eb..dc82a5fc 100644 --- a/LibGit2Sharp.Tests/RefSpecFixture.cs +++ b/LibGit2Sharp.Tests/RefSpecFixture.cs @@ -183,7 +183,7 @@ namespace LibGit2Sharp.Tests var remote = repo.Network.Remotes["origin"]; var oldRefSpecs = remote.RefSpecs.Select(r => r.Specification).ToList(); - Assert.Throws<LibGit2SharpException>(() => + Assert.Throws<InvalidSpecificationException>(() => repo.Network.Remotes.Update(remote, r => r.FetchRefSpecs.Add(refSpec))); var newRemote = repo.Network.Remotes["origin"]; diff --git a/LibGit2Sharp/Configuration.cs b/LibGit2Sharp/Configuration.cs index 078ad14f..47b14fb3 100644 --- a/LibGit2Sharp/Configuration.cs +++ b/LibGit2Sharp/Configuration.cs @@ -151,6 +151,16 @@ namespace LibGit2Sharp } } + internal void UnsetMultivar(string key, ConfigurationLevel level) + { + Ensure.ArgumentNotNullOrEmptyString(key, "key"); + + using (ConfigurationSafeHandle h = RetrieveConfigurationHandle(level, true, configHandle)) + { + Proxy.git_config_delete_multivar(h, key); + } + } + /// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> diff --git a/LibGit2Sharp/Core/FetchPruneStrategy.cs b/LibGit2Sharp/Core/FetchPruneStrategy.cs new file mode 100644 index 00000000..69570942 --- /dev/null +++ b/LibGit2Sharp/Core/FetchPruneStrategy.cs @@ -0,0 +1,25 @@ +namespace LibGit2Sharp.Core +{ + /// <summary> + /// Specify how the remote tracking branches should be locally dealt with + /// when their upstream countepart doesn't exist anymore. + /// </summary> + internal enum FetchPruneStrategy + { + /// <summary> + /// Use the setting from the configuration + /// or, when there isn't any, fallback to default behavior. + /// </summary> + FromConfigurationOrDefault = 0, + + /// <summary> + /// Force pruning on + /// </summary> + Prune, + + /// <summary> + /// Force pruning off + /// </summary> + NoPrune, + } +} diff --git a/LibGit2Sharp/Core/GitCheckoutOpts.cs b/LibGit2Sharp/Core/GitCheckoutOpts.cs index 4416aa60..3424094b 100644 --- a/LibGit2Sharp/Core/GitCheckoutOpts.cs +++ b/LibGit2Sharp/Core/GitCheckoutOpts.cs @@ -158,6 +158,7 @@ namespace LibGit2Sharp.Core public GitStrArray paths; public IntPtr baseline; + public IntPtr baseline_index; public IntPtr target_directory; public IntPtr ancestor_label; diff --git a/LibGit2Sharp/Core/GitCloneOptions.cs b/LibGit2Sharp/Core/GitCloneOptions.cs index 803bc8b3..bed647e3 100644 --- a/LibGit2Sharp/Core/GitCloneOptions.cs +++ b/LibGit2Sharp/Core/GitCloneOptions.cs @@ -17,7 +17,7 @@ namespace LibGit2Sharp.Core public uint Version; public GitCheckoutOpts CheckoutOpts; - public GitRemoteCallbacks RemoteCallbacks; + public GitFetchOptions FetchOpts; public int Bare; public GitCloneLocal Local; diff --git a/LibGit2Sharp/Core/GitDiff.cs b/LibGit2Sharp/Core/GitDiff.cs index 7ce4eafd..1c71fbb5 100644 --- a/LibGit2Sharp/Core/GitDiff.cs +++ b/LibGit2Sharp/Core/GitDiff.cs @@ -80,6 +80,13 @@ namespace LibGit2Sharp.Core /// </summary> GIT_DIFF_IGNORE_CASE = (1 << 10), + + /// <summary> + /// May be combined with `GIT_DIFF_IGNORE_CASE` to specify that a file + /// that has changed case will be returned as an add/delete pair. + /// </summary> + GIT_DIFF_INCLUDE_CASECHANGE = (1 << 11), + /// <summary> /// If the pathspec is set in the diff options, this flags means to /// apply it as an exact match instead of as an fnmatch pattern. diff --git a/LibGit2Sharp/Core/GitFetchOptions.cs b/LibGit2Sharp/Core/GitFetchOptions.cs new file mode 100644 index 00000000..02f996df --- /dev/null +++ b/LibGit2Sharp/Core/GitFetchOptions.cs @@ -0,0 +1,14 @@ +using System.Runtime.InteropServices; + +namespace LibGit2Sharp.Core +{ + [StructLayout(LayoutKind.Sequential)] + internal class GitFetchOptions + { + public int Version = 1; + public GitRemoteCallbacks RemoteCallbacks; + public FetchPruneStrategy Prune; + public bool UpdateFetchHead = true; + public TagFetchMode download_tags; + } +} diff --git a/LibGit2Sharp/Core/GitIndexEntry.cs b/LibGit2Sharp/Core/GitIndexEntry.cs index 05904c84..11bee09e 100644 --- a/LibGit2Sharp/Core/GitIndexEntry.cs +++ b/LibGit2Sharp/Core/GitIndexEntry.cs @@ -15,7 +15,7 @@ namespace LibGit2Sharp.Core public uint Mode; public uint Uid; public uint Gid; - public Int64 file_size; + public uint file_size; public GitOid Id; public ushort Flags; public ushort ExtendedFlags; diff --git a/LibGit2Sharp/Core/GitIndexTime.cs b/LibGit2Sharp/Core/GitIndexTime.cs index fb47f294..9f16c512 100644 --- a/LibGit2Sharp/Core/GitIndexTime.cs +++ b/LibGit2Sharp/Core/GitIndexTime.cs @@ -5,7 +5,7 @@ namespace LibGit2Sharp.Core [StructLayout(LayoutKind.Sequential)] internal class GitIndexTime { - public long seconds; + public int seconds; public uint nanoseconds; } } diff --git a/LibGit2Sharp/Core/GitMergeOpts.cs b/LibGit2Sharp/Core/GitMergeOpts.cs index a2ebe979..e122cbdc 100644 --- a/LibGit2Sharp/Core/GitMergeOpts.cs +++ b/LibGit2Sharp/Core/GitMergeOpts.cs @@ -31,6 +31,11 @@ namespace LibGit2Sharp.Core /// Flags for automerging content. /// </summary> public MergeFileFavor MergeFileFavorFlags; + + /// <summary> + /// File merging flags. + /// </summary> + public GitMergeFileFlags FileFlags; } /// <summary> @@ -63,11 +68,11 @@ namespace LibGit2Sharp.Core /// </summary> GIT_MERGE_ANALYSIS_FASTFORWARD = (1 << 2), - /** - * The HEAD of the current repository is "unborn" and does not point to - * a valid commit. No merge can be performed, but the caller may wish - * to simply set HEAD to the target commit(s). - */ + /// <summary> + /// The HEAD of the current repository is "unborn" and does not point to + /// a valid commit. No merge can be performed, but the caller may wish + /// to simply set HEAD to the target commit(s). + /// </summary> GIT_MERGE_ANALYSIS_UNBORN = (1 << 3), } @@ -105,4 +110,53 @@ namespace LibGit2Sharp.Core /// </summary> GIT_MERGE_TREE_FIND_RENAMES = (1 << 0), } + + [Flags] + internal enum GitMergeFileFlags + { + /// <summary> + /// Defaults + /// </summary> + GIT_MERGE_FILE_DEFAULT = 0, + + /// <summary> + /// Create standard conflicted merge files + /// </summary> + GIT_MERGE_FILE_STYLE_MERGE = (1 << 0), + + /// <summary> + /// Create diff3-style files + /// </summary> + GIT_MERGE_FILE_STYLE_DIFF3 = (1 << 1), + + /// <summary> + /// Condense non-alphanumeric regions for simplified diff file + /// </summary> + GIT_MERGE_FILE_SIMPLIFY_ALNUM = (1 << 2), + + /// <summary> + /// Ignore all whitespace + /// </summary> + GIT_MERGE_FILE_IGNORE_WHITESPACE = (1 << 3), + + /// <summary> + /// Ignore changes in amount of whitespace + /// </summary> + GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE = (1 << 4), + + /// <summary> + /// Ignore whitespace at end of line + /// </summary> + GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL = (1 << 5), + + /// <summary> + /// Use the "patience diff" algorithm + /// </summary> + GIT_MERGE_FILE_DIFF_PATIENCE = (1 << 6), + + /// <summary> + /// Take extra time to find minimal diff + /// </summary> + GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7), + } } diff --git a/LibGit2Sharp/Core/GitOdbBackend.cs b/LibGit2Sharp/Core/GitOdbBackend.cs index a7b0acf4..e36cdc53 100644 --- a/LibGit2Sharp/Core/GitOdbBackend.cs +++ b/LibGit2Sharp/Core/GitOdbBackend.cs @@ -130,7 +130,7 @@ namespace LibGit2Sharp.Core public delegate int writestream_callback( out IntPtr stream_out, IntPtr backend, - UIntPtr length, + Int64 length, GitObjectType type); /// <summary> diff --git a/LibGit2Sharp/Core/GitOdbBackendStream.cs b/LibGit2Sharp/Core/GitOdbBackendStream.cs index 82f6ce89..f7eec27d 100644 --- a/LibGit2Sharp/Core/GitOdbBackendStream.cs +++ b/LibGit2Sharp/Core/GitOdbBackendStream.cs @@ -22,8 +22,8 @@ namespace LibGit2Sharp.Core public GitOdbBackendStreamMode Mode; public IntPtr HashCtx; - public UIntPtr DeclaredSize; - public UIntPtr ReceivedBytes; + public Int64 DeclaredSize; + public Int64 ReceivedBytes; public read_callback Read; public write_callback Write; diff --git a/LibGit2Sharp/Core/GitPushOptions.cs b/LibGit2Sharp/Core/GitPushOptions.cs index baebabee..d4bbcdc3 100644 --- a/LibGit2Sharp/Core/GitPushOptions.cs +++ b/LibGit2Sharp/Core/GitPushOptions.cs @@ -7,5 +7,6 @@ namespace LibGit2Sharp.Core { public int Version = 1; public int PackbuilderDegreeOfParallelism; + public GitRemoteCallbacks RemoteCallbacks; } } diff --git a/LibGit2Sharp/Core/GitPushUpdate.cs b/LibGit2Sharp/Core/GitPushUpdate.cs new file mode 100644 index 00000000..f38697a4 --- /dev/null +++ b/LibGit2Sharp/Core/GitPushUpdate.cs @@ -0,0 +1,14 @@ +using System; +using System.Runtime.InteropServices; + +namespace LibGit2Sharp.Core +{ + [StructLayout(LayoutKind.Sequential)] + internal class GitPushUpdate + { + IntPtr src_refname; + IntPtr dst_refname; + GitOid src; + GitOid dst; + } +} diff --git a/LibGit2Sharp/Core/GitRemoteCallbacks.cs b/LibGit2Sharp/Core/GitRemoteCallbacks.cs index e23d115b..71537f76 100644 --- a/LibGit2Sharp/Core/GitRemoteCallbacks.cs +++ b/LibGit2Sharp/Core/GitRemoteCallbacks.cs @@ -29,6 +29,10 @@ namespace LibGit2Sharp.Core internal NativeMethods.push_update_reference_callback push_update_reference; + internal NativeMethods.push_negotiation_callback push_negotiation; + + internal IntPtr transport; + internal IntPtr payload; } } diff --git a/LibGit2Sharp/Core/GitSmartSubtransportRegistration.cs b/LibGit2Sharp/Core/GitSmartSubtransportRegistration.cs index 724c6c41..e721c1e7 100644 --- a/LibGit2Sharp/Core/GitSmartSubtransportRegistration.cs +++ b/LibGit2Sharp/Core/GitSmartSubtransportRegistration.cs @@ -8,9 +8,11 @@ namespace LibGit2Sharp.Core { public IntPtr SubtransportCallback; public uint Rpc; + public uint Param; public delegate int create_callback( out IntPtr subtransport, - IntPtr transport); + IntPtr owner, + IntPtr param); } } diff --git a/LibGit2Sharp/Core/GitSubmoduleOptions.cs b/LibGit2Sharp/Core/GitSubmoduleOptions.cs index 1b64aa1f..4fb07411 100644 --- a/LibGit2Sharp/Core/GitSubmoduleOptions.cs +++ b/LibGit2Sharp/Core/GitSubmoduleOptions.cs @@ -9,7 +9,7 @@ namespace LibGit2Sharp.Core public GitCheckoutOpts CheckoutOptions; - public GitRemoteCallbacks RemoteCallbacks; + public GitFetchOptions FetchOptions; public CheckoutStrategy CloneCheckoutStrategy; } diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs index a9453529..9b4e818f 100644 --- a/LibGit2Sharp/Core/NativeMethods.cs +++ b/LibGit2Sharp/Core/NativeMethods.cs @@ -272,7 +272,15 @@ namespace LibGit2Sharp.Core internal static extern OidSafeHandle git_commit_tree_id(GitObjectSafeHandle commit); [DllImport(libgit2)] - internal static extern int git_config_delete_entry(ConfigurationSafeHandle cfg, string name); + internal static extern int git_config_delete_entry( + ConfigurationSafeHandle cfg, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name); + + [DllImport(libgit2)] + internal static extern int git_config_delete_multivar( + ConfigurationSafeHandle cfg, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof (StrictUtf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string regexp); [DllImport(libgit2)] internal static extern int git_config_find_global(GitBuf global_config_path); @@ -744,7 +752,7 @@ namespace LibGit2Sharp.Core [DllImport(libgit2)] internal static extern int git_note_default_ref( - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))] out string notes_ref, + GitBuf notes_ref, RepositorySafeHandle repo); internal delegate int git_note_foreach_cb( @@ -779,7 +787,7 @@ namespace LibGit2Sharp.Core IntPtr payload); [DllImport(libgit2)] - internal static extern int git_odb_open_wstream(out OdbStreamSafeHandle stream, ObjectDatabaseSafeHandle odb, UIntPtr size, GitObjectType type); + internal static extern int git_odb_open_wstream(out OdbStreamSafeHandle stream, ObjectDatabaseSafeHandle odb, Int64 size, GitObjectType type); [DllImport(libgit2)] internal static extern void git_odb_free(IntPtr odb); @@ -996,7 +1004,10 @@ namespace LibGit2Sharp.Core internal static extern int git_remote_autotag(RemoteSafeHandle remote); [DllImport(libgit2)] - internal static extern int git_remote_connect(RemoteSafeHandle remote, GitDirection direction); + internal static extern int git_remote_connect( + RemoteSafeHandle remote, + GitDirection direction, + ref GitRemoteCallbacks callbacks); [DllImport(libgit2)] internal static extern int git_remote_create( @@ -1009,8 +1020,7 @@ namespace LibGit2Sharp.Core internal static extern int git_remote_create_anonymous( out RemoteSafeHandle remote, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string url, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string refspec); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string url); [DllImport(libgit2)] @@ -1030,6 +1040,7 @@ namespace LibGit2Sharp.Core internal static extern int git_remote_fetch( RemoteSafeHandle remote, ref GitStrArray refspecs, + GitFetchOptions fetch_opts, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message); [DllImport(libgit2)] @@ -1061,12 +1072,26 @@ namespace LibGit2Sharp.Core [DllImport(libgit2)] internal static extern int git_remote_set_url( - RemoteSafeHandle remote, + RepositorySafeHandle repo, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string remote, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string url); + + [DllImport(libgit2)] + internal static extern int git_remote_add_fetch( + RepositorySafeHandle repo, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string remote, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string url); [DllImport(libgit2)] internal static extern int git_remote_set_pushurl( - RemoteSafeHandle remote, + RepositorySafeHandle repo, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string remote, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string url); + + [DllImport(libgit2)] + internal static extern int git_remote_add_push( + RepositorySafeHandle repo, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string remote, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string url); [DllImport(libgit2)] @@ -1092,9 +1117,6 @@ namespace LibGit2Sharp.Core internal static extern string git_remote_name(RemoteSafeHandle remote); [DllImport(libgit2)] - internal static extern int git_remote_save(RemoteSafeHandle remote); - - [DllImport(libgit2)] [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))] internal static extern string git_remote_url(RemoteSafeHandle remote); @@ -1103,12 +1125,10 @@ namespace LibGit2Sharp.Core internal static extern string git_remote_pushurl(RemoteSafeHandle remote); [DllImport(libgit2)] - internal static extern void git_remote_set_autotag(RemoteSafeHandle remote, TagFetchMode option); - - [DllImport(libgit2)] - internal static extern int git_remote_set_callbacks( - RemoteSafeHandle remote, - ref GitRemoteCallbacks callbacks); + internal static extern void git_remote_set_autotag( + RepositorySafeHandle repo, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name, + TagFetchMode option); internal delegate int remote_progress_callback(IntPtr str, int len, IntPtr data); @@ -1120,6 +1140,12 @@ namespace LibGit2Sharp.Core ref GitOid newId, IntPtr data); + internal delegate int push_negotiation_callback( + IntPtr updates, // GitPushUpdate? + UIntPtr len, + IntPtr payload + ); + internal delegate int push_update_reference_callback( IntPtr refName, IntPtr status, diff --git a/LibGit2Sharp/Core/Proxy.cs b/LibGit2Sharp/Core/Proxy.cs index 68888cae..4739d7bc 100644 --- a/LibGit2Sharp/Core/Proxy.cs +++ b/LibGit2Sharp/Core/Proxy.cs @@ -472,6 +472,24 @@ namespace LibGit2Sharp.Core } } + const string anyValue = ".*"; + + public static bool git_config_delete_multivar(ConfigurationSafeHandle config, string name) + { + using (ThreadAffinity()) + { + int res = NativeMethods.git_config_delete_multivar(config, name, anyValue); + + if (res == (int)GitErrorCode.NotFound) + { + return false; + } + + Ensure.ZeroResult(res); + return true; + } + } + public static FilePath git_config_find_global() { return ConvertPath(NativeMethods.git_config_find_global); @@ -1399,12 +1417,12 @@ namespace LibGit2Sharp.Core public static string git_note_default_ref(RepositorySafeHandle repo) { using (ThreadAffinity()) + using (var buf = new GitBuf()) { - string notes_ref; - int res = NativeMethods.git_note_default_ref(out notes_ref, repo); + int res = NativeMethods.git_note_default_ref(buf, repo); Ensure.ZeroResult(res); - return notes_ref; + return LaxUtf8Marshaler.FromNative(buf.ptr); } } @@ -1609,7 +1627,7 @@ namespace LibGit2Sharp.Core IntPtr.Zero)); } - public static OdbStreamSafeHandle git_odb_open_wstream(ObjectDatabaseSafeHandle odb, UIntPtr size, GitObjectType type) + public static OdbStreamSafeHandle git_odb_open_wstream(ObjectDatabaseSafeHandle odb, long size, GitObjectType type) { using (ThreadAffinity()) { @@ -1996,23 +2014,23 @@ namespace LibGit2Sharp.Core } } - public static RemoteSafeHandle git_remote_create_anonymous(RepositorySafeHandle repo, string url, string refspec) + public static RemoteSafeHandle git_remote_create_anonymous(RepositorySafeHandle repo, string url) { using (ThreadAffinity()) { RemoteSafeHandle handle; - int res = NativeMethods.git_remote_create_anonymous(out handle, repo, url, refspec); + int res = NativeMethods.git_remote_create_anonymous(out handle, repo, url); Ensure.ZeroResult(res); return handle; } } - public static void git_remote_connect(RemoteSafeHandle remote, GitDirection direction) + public static void git_remote_connect(RemoteSafeHandle remote, GitDirection direction, ref GitRemoteCallbacks remoteCallbacks) { using (ThreadAffinity()) { - int res = NativeMethods.git_remote_connect(remote, direction); + int res = NativeMethods.git_remote_connect(remote, direction, ref remoteCallbacks); Ensure.ZeroResult(res); } } @@ -2102,73 +2120,55 @@ namespace LibGit2Sharp.Core } } - public static void git_remote_set_fetch_refspecs(RemoteSafeHandle remote, IEnumerable<string> refSpecs) + public static void git_remote_set_url(RepositorySafeHandle repo, string remote, string url) { using (ThreadAffinity()) { - var array = new GitStrArrayManaged(); - - try - { - array = GitStrArrayManaged.BuildFrom(refSpecs.ToArray()); - - int res = NativeMethods.git_remote_set_fetch_refspecs(remote, ref array.Array); - Ensure.ZeroResult(res); - } - finally - { - array.Dispose(); - } + int res = NativeMethods.git_remote_set_url(repo, remote, url); + Ensure.ZeroResult(res); } } - public static void git_remote_set_push_refspecs(RemoteSafeHandle remote, IEnumerable<string> refSpecs) + public static void git_remote_add_fetch(RepositorySafeHandle repo, string remote, string url) { using (ThreadAffinity()) { - var array = new GitStrArrayManaged(); - - try - { - array = GitStrArrayManaged.BuildFrom(refSpecs.ToArray()); - - int res = NativeMethods.git_remote_set_push_refspecs(remote, ref array.Array); - Ensure.ZeroResult(res); - } - finally - { - array.Dispose(); - } + int res = NativeMethods.git_remote_add_fetch(repo, remote, url); + Ensure.ZeroResult(res); } } - public static void git_remote_set_url(RemoteSafeHandle remote, string url) + public static void git_remote_set_pushurl(RepositorySafeHandle repo, string remote, string url) { using (ThreadAffinity()) { - int res = NativeMethods.git_remote_set_url(remote, url); + int res = NativeMethods.git_remote_set_pushurl(repo, remote, url); Ensure.ZeroResult(res); } } - public static void git_remote_set_pushurl(RemoteSafeHandle remote, string url) + public static void git_remote_add_push(RepositorySafeHandle repo, string remote, string url) { using (ThreadAffinity()) { - int res = NativeMethods.git_remote_set_pushurl(remote, url); + int res = NativeMethods.git_remote_add_push(repo, remote, url); Ensure.ZeroResult(res); } } - public static void git_remote_fetch(RemoteSafeHandle remote, string logMessage) + public static void git_remote_fetch( + RemoteSafeHandle remote, IEnumerable<string> refSpecs, + GitFetchOptions fetchOptions, string logMessage) { using (ThreadAffinity()) { - var array = new GitStrArrayNative(); + var array = new GitStrArrayManaged(); try { - int res = NativeMethods.git_remote_fetch(remote, ref array.Array, logMessage); + array = GitStrArrayManaged.BuildFrom(refSpecs.ToArray()); + + int res = NativeMethods.git_remote_fetch(remote, ref array.Array, fetchOptions, logMessage); Ensure.ZeroResult(res); } finally @@ -2313,27 +2313,9 @@ namespace LibGit2Sharp.Core } } - public static void git_remote_save(RemoteSafeHandle remote) - { - using (ThreadAffinity()) - { - int res = NativeMethods.git_remote_save(remote); - Ensure.ZeroResult(res); - } - } - - public static void git_remote_set_autotag(RemoteSafeHandle remote, TagFetchMode value) + public static void git_remote_set_autotag(RepositorySafeHandle repo, string remote, TagFetchMode value) { - NativeMethods.git_remote_set_autotag(remote, value); - } - - public static void git_remote_set_callbacks(RemoteSafeHandle remote, ref GitRemoteCallbacks callbacks) - { - using (ThreadAffinity()) - { - int res = NativeMethods.git_remote_set_callbacks(remote, ref callbacks); - Ensure.ZeroResult(res); - } + NativeMethods.git_remote_set_autotag(repo, remote, value); } public static string git_remote_url(RemoteSafeHandle remote) diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 552b095a..5286c96a 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="..\packages\LibGit2Sharp.NativeBinaries.1.0.25\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.25\build\LibGit2Sharp.NativeBinaries.props')" /> + <Import Project="..\packages\LibGit2Sharp.NativeBinaries.1.0.51\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.51\build\LibGit2Sharp.NativeBinaries.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -70,6 +70,8 @@ <Compile Include="CommitSortStrategies.cs" /> <Compile Include="CompareOptions.cs" /> <Compile Include="Core\FileHistory.cs" /> + <Compile Include="Core\GitFetchOptions.cs" /> + <Compile Include="Core\GitPushUpdate.cs" /> <Compile Include="Core\Platform.cs" /> <Compile Include="Core\Handles\ConflictIteratorSafeHandle.cs" /> <Compile Include="DescribeOptions.cs" /> @@ -83,6 +85,7 @@ <Compile Include="DiffAlgorithm.cs" /> <Compile Include="EntryExistsException.cs" /> <Compile Include="FetchOptionsBase.cs" /> + <Compile Include="Core\FetchPruneStrategy.cs" /> <Compile Include="LogEntry.cs" /> <Compile Include="FollowFilter.cs" /> <Compile Include="IBelongToARepository.cs" /> @@ -375,7 +378,7 @@ <PropertyGroup> <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> </PropertyGroup> - <Error Condition="!Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.25\build\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LibGit2Sharp.NativeBinaries.1.0.25\build\LibGit2Sharp.NativeBinaries.props'))" /> + <Error Condition="!Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.51\build\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LibGit2Sharp.NativeBinaries.1.0.51\build\LibGit2Sharp.NativeBinaries.props'))" /> </Target> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. diff --git a/LibGit2Sharp/MergeOptionsBase.cs b/LibGit2Sharp/MergeOptionsBase.cs index 7501bd90..2dda65e6 100644 --- a/LibGit2Sharp/MergeOptionsBase.cs +++ b/LibGit2Sharp/MergeOptionsBase.cs @@ -1,8 +1,4 @@ -using LibGit2Sharp.Core; -using LibGit2Sharp.Handlers; -using System; - -namespace LibGit2Sharp +namespace LibGit2Sharp { /// <summary> /// Options controlling the behavior of actions that use merge (merge @@ -14,7 +10,7 @@ namespace LibGit2Sharp /// Initializes a new instance of the <see cref="MergeOptionsBase"/> class. /// The default behavior is to attempt to find renames. /// </summary> - public MergeOptionsBase() + protected MergeOptionsBase() { FindRenames = true; RenameThreshold = 50; diff --git a/LibGit2Sharp/Network.cs b/LibGit2Sharp/Network.cs index 5eb1720c..edfe2fd7 100644 --- a/LibGit2Sharp/Network.cs +++ b/LibGit2Sharp/Network.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Globalization; using System.Linq; using LibGit2Sharp.Core; @@ -70,14 +71,15 @@ namespace LibGit2Sharp using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true)) { + var gitCallbacks = new GitRemoteCallbacks {version = 1}; + if (credentialsProvider != null) { var callbacks = new RemoteCallbacks(credentialsProvider); - GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks(); - Proxy.git_remote_set_callbacks(remoteHandle, ref gitCallbacks); + gitCallbacks = callbacks.GenerateCallbacks(); } - Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch); + Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch, ref gitCallbacks); return Proxy.git_remote_ls(repository, remoteHandle); } } @@ -97,39 +99,67 @@ namespace LibGit2Sharp { Ensure.ArgumentNotNull(url, "url"); - using (RemoteSafeHandle remoteHandle = Proxy.git_remote_create_anonymous(repository.Handle, url, null)) + using (RemoteSafeHandle remoteHandle = Proxy.git_remote_create_anonymous(repository.Handle, url)) { - Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch); + GitRemoteCallbacks gitCallbacks = new GitRemoteCallbacks { version = 1 }; + Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch, ref gitCallbacks); return Proxy.git_remote_ls(repository, remoteHandle); } } - static void DoFetch(RemoteSafeHandle remoteHandle, FetchOptions options, string logMessage) + static RemoteSafeHandle BuildRemoteSafeHandle(RepositorySafeHandle repoHandle, Remote remote, string url) { - if (options == null) + Debug.Assert((remote == null) ^ (url == null)); + + RemoteSafeHandle remoteHandle; + + if (url != null) { - options = new FetchOptions(); + remoteHandle = Proxy.git_remote_create_anonymous(repoHandle, url); + } + else + { + remoteHandle = Proxy.git_remote_lookup(repoHandle, remote.Name, true); } - if (options.TagFetchMode.HasValue) + return remoteHandle; + } + + static void DoFetch(RepositorySafeHandle repoHandle, Remote remote, string url, + FetchOptions options, string logMessage, + IEnumerable<string> refspecs) + { + if (options == null) { - Proxy.git_remote_set_autotag(remoteHandle, options.TagFetchMode.Value); + options = new FetchOptions(); } - var callbacks = new RemoteCallbacks(options); - GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks(); + using (RemoteSafeHandle remoteHandle = BuildRemoteSafeHandle(repoHandle, remote, url)) + { + var callbacks = new RemoteCallbacks(options); + GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks(); - // It is OK to pass the reference to the GitCallbacks directly here because libgit2 makes a copy of - // the data in the git_remote_callbacks structure. If, in the future, libgit2 changes its implementation - // to store a reference to the git_remote_callbacks structure this would introduce a subtle bug - // where the managed layer could move the git_remote_callbacks to a different location in memory, - // but libgit2 would still reference the old address. - // - // Also, if GitRemoteCallbacks were a class instead of a struct, we would need to guard against - // GC occuring in between setting the remote callbacks and actual usage in one of the functions afterwords. - Proxy.git_remote_set_callbacks(remoteHandle, ref gitCallbacks); + // It is OK to pass the reference to the GitCallbacks directly here because libgit2 makes a copy of + // the data in the git_remote_callbacks structure. If, in the future, libgit2 changes its implementation + // to store a reference to the git_remote_callbacks structure this would introduce a subtle bug + // where the managed layer could move the git_remote_callbacks to a different location in memory, + // but libgit2 would still reference the old address. + // + // Also, if GitRemoteCallbacks were a class instead of a struct, we would need to guard against + // GC occuring in between setting the remote callbacks and actual usage in one of the functions afterwords. + var fetchOptions = new GitFetchOptions + { + RemoteCallbacks = gitCallbacks, + download_tags = Proxy.git_remote_autotag(remoteHandle), + }; + + if (options.TagFetchMode.HasValue) + { + fetchOptions.download_tags = options.TagFetchMode.Value; + } - Proxy.git_remote_fetch(remoteHandle, logMessage); + Proxy.git_remote_fetch(remoteHandle, refspecs, fetchOptions, logMessage); + } } /// <summary> @@ -171,10 +201,7 @@ namespace LibGit2Sharp { Ensure.ArgumentNotNull(remote, "remote"); - using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true)) - { - DoFetch(remoteHandle, options, logMessage); - } + DoFetch(repository.Handle, remote, null, options, logMessage, new string[0]); } /// <summary> @@ -221,12 +248,7 @@ namespace LibGit2Sharp Ensure.ArgumentNotNull(remote, "remote"); Ensure.ArgumentNotNull(refspecs, "refspecs"); - using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true)) - { - Proxy.git_remote_set_fetch_refspecs(remoteHandle, refspecs); - - DoFetch(remoteHandle, options, logMessage); - } + DoFetch(repository.Handle, remote, null, options, logMessage, refspecs); } /// <summary> @@ -285,12 +307,7 @@ namespace LibGit2Sharp Ensure.ArgumentNotNull(url, "url"); Ensure.ArgumentNotNull(refspecs, "refspecs"); - using (RemoteSafeHandle remoteHandle = Proxy.git_remote_create_anonymous(repository.Handle, url, null)) - { - Proxy.git_remote_set_fetch_refspecs(remoteHandle, refspecs); - - DoFetch(remoteHandle, options, logMessage); - } + DoFetch(repository.Handle, null, url, options, logMessage, refspecs); } /// <summary> @@ -402,12 +419,12 @@ namespace LibGit2Sharp { var callbacks = new RemoteCallbacks(pushOptions); GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks(); - Proxy.git_remote_set_callbacks(remoteHandle, ref gitCallbacks); Proxy.git_remote_push(remoteHandle, pushRefSpecs, new GitPushOptions() { - PackbuilderDegreeOfParallelism = pushOptions.PackbuilderDegreeOfParallelism + PackbuilderDegreeOfParallelism = pushOptions.PackbuilderDegreeOfParallelism, + RemoteCallbacks = gitCallbacks, }); } } diff --git a/LibGit2Sharp/ObjectDatabase.cs b/LibGit2Sharp/ObjectDatabase.cs index 73bd5e9b..a7996561 100644 --- a/LibGit2Sharp/ObjectDatabase.cs +++ b/LibGit2Sharp/ObjectDatabase.cs @@ -131,10 +131,10 @@ namespace LibGit2Sharp private class Processor { private readonly Stream stream; - private readonly int? numberOfBytesToConsume; + private readonly long? numberOfBytesToConsume; private int totalNumberOfReadBytes; - public Processor(Stream stream, int? numberOfBytesToConsume) + public Processor(Stream stream, long? numberOfBytesToConsume) { this.stream = stream; this.numberOfBytesToConsume = numberOfBytesToConsume; @@ -148,11 +148,11 @@ namespace LibGit2Sharp if (numberOfBytesToConsume.HasValue) { - int totalRemainingBytesToRead = numberOfBytesToConsume.Value - totalNumberOfReadBytes; + long totalRemainingBytesToRead = numberOfBytesToConsume.Value - totalNumberOfReadBytes; if (totalRemainingBytesToRead < max_length) { - bytesToRead = totalRemainingBytesToRead; + bytesToRead = totalRemainingBytesToRead > int.MaxValue ? int.MaxValue : (int)totalRemainingBytesToRead; } } @@ -208,12 +208,12 @@ namespace LibGit2Sharp /// <param name="hintpath">The hintpath is used to determine what git filters should be applied to the object before it can be placed to the object database.</param> /// <param name="numberOfBytesToConsume">The number of bytes to consume from the stream.</param> /// <returns>The created <see cref="Blob"/>.</returns> - public virtual Blob CreateBlob(Stream stream, string hintpath, int numberOfBytesToConsume) + public virtual Blob CreateBlob(Stream stream, string hintpath, long numberOfBytesToConsume) { - return CreateBlob(stream, hintpath, (int?)numberOfBytesToConsume); + return CreateBlob(stream, hintpath, (long?)numberOfBytesToConsume); } - internal Blob CreateBlob(Stream stream, string hintpath, int? numberOfBytesToConsume) + private Blob CreateBlob(Stream stream, string hintpath, long? numberOfBytesToConsume) { Ensure.ArgumentNotNull(stream, "stream"); @@ -240,7 +240,7 @@ namespace LibGit2Sharp /// <param name="stream">The stream from which will be read the content of the blob to be created.</param> /// <param name="numberOfBytesToConsume">Number of bytes to consume from the stream.</param> /// <returns>The created <see cref="Blob"/>.</returns> - public virtual Blob CreateBlob(Stream stream, int numberOfBytesToConsume) + public virtual Blob CreateBlob(Stream stream, long numberOfBytesToConsume) { Ensure.ArgumentNotNull(stream, "stream"); @@ -249,15 +249,15 @@ namespace LibGit2Sharp throw new ArgumentException("The stream cannot be read from.", "stream"); } - using (var odbStream = Proxy.git_odb_open_wstream(handle, (UIntPtr)numberOfBytesToConsume, GitObjectType.Blob)) + using (var odbStream = Proxy.git_odb_open_wstream(handle, numberOfBytesToConsume, GitObjectType.Blob)) { var buffer = new byte[4*1024]; - int totalRead = 0; + long totalRead = 0; while (totalRead < numberOfBytesToConsume) { - var left = numberOfBytesToConsume - totalRead; - var toRead = left < buffer.Length ? left : buffer.Length; + long left = numberOfBytesToConsume - totalRead; + int toRead = left < buffer.Length ? (int)left : buffer.Length; var read = stream.Read(buffer, 0, toRead); if (read == 0) diff --git a/LibGit2Sharp/OdbBackend.cs b/LibGit2Sharp/OdbBackend.cs index 149b996c..8ecd3f73 100644 --- a/LibGit2Sharp/OdbBackend.cs +++ b/LibGit2Sharp/OdbBackend.cs @@ -440,13 +440,11 @@ namespace LibGit2Sharp private static int WriteStream( out IntPtr stream_out, IntPtr backend, - UIntPtr len, + long len, GitObjectType type) { stream_out = IntPtr.Zero; - long length = ConverToLong(len); - OdbBackend odbBackend = MarshalOdbBackend(backend); if (odbBackend == null) { @@ -458,7 +456,7 @@ namespace LibGit2Sharp try { OdbBackendStream stream; - int toReturn = odbBackend.WriteStream(length, objectType, out stream); + int toReturn = odbBackend.WriteStream(len, objectType, out stream); if (toReturn == 0) { diff --git a/LibGit2Sharp/RemoteCollection.cs b/LibGit2Sharp/RemoteCollection.cs index d504ca3c..a85cb6ad 100644 --- a/LibGit2Sharp/RemoteCollection.cs +++ b/LibGit2Sharp/RemoteCollection.cs @@ -57,12 +57,11 @@ namespace LibGit2Sharp /// <returns>The updated remote.</returns> public virtual Remote Update(Remote remote, params Action<RemoteUpdater>[] actions) { - using (var updater = new RemoteUpdater(this.repository, remote)) + var updater = new RemoteUpdater(repository, remote); + + foreach (Action<RemoteUpdater> action in actions) { - foreach (Action<RemoteUpdater> action in actions) - { - action(updater); - } + action(updater); } return this[remote.Name]; diff --git a/LibGit2Sharp/RemoteUpdater.cs b/LibGit2Sharp/RemoteUpdater.cs index 1c419727..07c823bc 100644 --- a/LibGit2Sharp/RemoteUpdater.cs +++ b/LibGit2Sharp/RemoteUpdater.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using LibGit2Sharp.Core; using LibGit2Sharp.Core.Handles; @@ -9,11 +10,12 @@ namespace LibGit2Sharp /// <summary> /// Exposes properties of a remote that can be updated. /// </summary> - public class RemoteUpdater : IDisposable + public class RemoteUpdater { private readonly UpdatingCollection<string> fetchRefSpecs; private readonly UpdatingCollection<string> pushRefSpecs; - private readonly RemoteSafeHandle remoteHandle; + private readonly Repository repo; + private readonly Remote remote; /// <summary> /// Needed for mocking purposes. @@ -26,32 +28,47 @@ namespace LibGit2Sharp Ensure.ArgumentNotNull(repo, "repo"); Ensure.ArgumentNotNull(remote, "remote"); + this.repo = repo; + this.remote = remote; + fetchRefSpecs = new UpdatingCollection<string>(GetFetchRefSpecs, SetFetchRefSpecs); pushRefSpecs = new UpdatingCollection<string>(GetPushRefSpecs, SetPushRefSpecs); - - remoteHandle = Proxy.git_remote_lookup(repo.Handle, remote.Name, true); } private IEnumerable<string> GetFetchRefSpecs() { - return Proxy.git_remote_get_fetch_refspecs(remoteHandle); + using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repo.Handle, remote.Name, true)) + { + return Proxy.git_remote_get_fetch_refspecs(remoteHandle); + } } private void SetFetchRefSpecs(IEnumerable<string> value) { - Proxy.git_remote_set_fetch_refspecs(remoteHandle, value); - Proxy.git_remote_save(remoteHandle); + repo.Config.UnsetMultivar(string.Format("remote.{0}.fetch", remote.Name), ConfigurationLevel.Local); + + foreach (var url in value) + { + Proxy.git_remote_add_fetch(repo.Handle, remote.Name, url); + } } private IEnumerable<string> GetPushRefSpecs() { - return Proxy.git_remote_get_push_refspecs(remoteHandle); + using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repo.Handle, remote.Name, true)) + { + return Proxy.git_remote_get_push_refspecs(remoteHandle); + } } private void SetPushRefSpecs(IEnumerable<string> value) { - Proxy.git_remote_set_push_refspecs(remoteHandle, value); - Proxy.git_remote_save(remoteHandle); + repo.Config.UnsetMultivar(string.Format("remote.{0}.push", remote.Name), ConfigurationLevel.Local); + + foreach (var url in value) + { + Proxy.git_remote_add_push(repo.Handle, remote.Name, url); + } } /// <summary> @@ -61,8 +78,7 @@ namespace LibGit2Sharp { set { - Proxy.git_remote_set_autotag(remoteHandle, value); - Proxy.git_remote_save(remoteHandle); + Proxy.git_remote_set_autotag(repo.Handle, remote.Name, value); } } @@ -73,11 +89,10 @@ namespace LibGit2Sharp { set { - Proxy.git_remote_set_url(remoteHandle, value); - Proxy.git_remote_save(remoteHandle); + Proxy.git_remote_set_url(repo.Handle, remote.Name, value); } } - + /// <summary> /// Sets the push url defined for this <see cref="Remote"/> /// </summary> @@ -85,8 +100,7 @@ namespace LibGit2Sharp { set { - Proxy.git_remote_set_pushurl(remoteHandle, value); - Proxy.git_remote_save(remoteHandle); + Proxy.git_remote_set_pushurl(repo.Handle, remote.Name, value); } } @@ -188,13 +202,5 @@ namespace LibGit2Sharp setter(list.Value); } } - - /// <summary> - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// </summary> - public void Dispose() - { - remoteHandle.Dispose(); - } } } diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs index 189a3cf3..79c9077b 100644 --- a/LibGit2Sharp/Repository.cs +++ b/LibGit2Sharp/Repository.cs @@ -628,7 +628,7 @@ namespace LibGit2Sharp Version = 1, Bare = options.IsBare ? 1 : 0, CheckoutOpts = gitCheckoutOptions, - RemoteCallbacks = gitRemoteCallbacks, + FetchOpts = new GitFetchOptions { RemoteCallbacks = gitRemoteCallbacks }, }; string clonedRepoPath; diff --git a/LibGit2Sharp/SmartSubtransportRegistration.cs b/LibGit2Sharp/SmartSubtransportRegistration.cs index df7c1cb4..8247b023 100644 --- a/LibGit2Sharp/SmartSubtransportRegistration.cs +++ b/LibGit2Sharp/SmartSubtransportRegistration.cs @@ -80,7 +80,8 @@ namespace LibGit2Sharp private static int Subtransport( out IntPtr subtransport, - IntPtr transport) + IntPtr transport, + IntPtr payload) { subtransport = IntPtr.Zero; diff --git a/LibGit2Sharp/SubmoduleCollection.cs b/LibGit2Sharp/SubmoduleCollection.cs index 33abfbf8..14ff416a 100644 --- a/LibGit2Sharp/SubmoduleCollection.cs +++ b/LibGit2Sharp/SubmoduleCollection.cs @@ -107,7 +107,7 @@ namespace LibGit2Sharp { Version = 1, CheckoutOptions = gitCheckoutOptions, - RemoteCallbacks = gitRemoteCallbacks, + FetchOptions = new GitFetchOptions { RemoteCallbacks = gitRemoteCallbacks }, CloneCheckoutStrategy = CheckoutStrategy.GIT_CHECKOUT_SAFE }; diff --git a/LibGit2Sharp/TagFetchMode.cs b/LibGit2Sharp/TagFetchMode.cs index 8e8efc79..993833f4 100644 --- a/LibGit2Sharp/TagFetchMode.cs +++ b/LibGit2Sharp/TagFetchMode.cs @@ -7,10 +7,16 @@ public enum TagFetchMode { /// <summary> - /// Default behavior. Will automatically retrieve tags that + /// Use the setting from the configuration + /// or, when there isn't any, fallback to default behavior. + /// </summary> + FromConfigurationOrDefault = 0, // GIT_REMOTE_DOWNLOAD_TAGS_FALLBACK + + /// <summary> + /// Will automatically retrieve tags that /// point to objects retrieved during this fetch. /// </summary> - Auto = 0, // GIT_REMOTE_DOWNLOAD_TAGS_AUTO + Auto, // GIT_REMOTE_DOWNLOAD_TAGS_AUTO /// <summary> /// No tag will be retrieved. diff --git a/LibGit2Sharp/packages.config b/LibGit2Sharp/packages.config index aa575453..6565d177 100644 --- a/LibGit2Sharp/packages.config +++ b/LibGit2Sharp/packages.config @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> <packages> - <package id="LibGit2Sharp.NativeBinaries" version="1.0.25" targetFramework="net40" allowedVersions="[1.0.25]" /> + <package id="LibGit2Sharp.NativeBinaries" version="1.0.51" targetFramework="net40" allowedVersions="[1.0.51]" /> </packages>
\ No newline at end of file |