diff --git a/LibGit2Sharp.Tests/FetchFixture.cs b/LibGit2Sharp.Tests/FetchFixture.cs index 3b0d65976..89a7e8a62 100644 --- a/LibGit2Sharp.Tests/FetchFixture.cs +++ b/LibGit2Sharp.Tests/FetchFixture.cs @@ -134,6 +134,18 @@ public void CanFetchCustomRefSpecsIntoAnEmptyRepository(string url, string local 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 ea78f4eb2..dc82a5fc3 100644 --- a/LibGit2Sharp.Tests/RefSpecFixture.cs +++ b/LibGit2Sharp.Tests/RefSpecFixture.cs @@ -183,7 +183,7 @@ public void SettingInvalidRefSpecsThrows(string refSpec) var remote = repo.Network.Remotes["origin"]; var oldRefSpecs = remote.RefSpecs.Select(r => r.Specification).ToList(); - Assert.Throws(() => + Assert.Throws(() => 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 078ad14fe..47b14fb32 100644 --- a/LibGit2Sharp/Configuration.cs +++ b/LibGit2Sharp/Configuration.cs @@ -151,6 +151,16 @@ public virtual void Unset(string key, ConfigurationLevel level) } } + 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); + } + } + /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// diff --git a/LibGit2Sharp/Core/FetchPruneStrategy.cs b/LibGit2Sharp/Core/FetchPruneStrategy.cs new file mode 100644 index 000000000..695709421 --- /dev/null +++ b/LibGit2Sharp/Core/FetchPruneStrategy.cs @@ -0,0 +1,25 @@ +namespace LibGit2Sharp.Core +{ + /// + /// Specify how the remote tracking branches should be locally dealt with + /// when their upstream countepart doesn't exist anymore. + /// + internal enum FetchPruneStrategy + { + /// + /// Use the setting from the configuration + /// or, when there isn't any, fallback to default behavior. + /// + FromConfigurationOrDefault = 0, + + /// + /// Force pruning on + /// + Prune, + + /// + /// Force pruning off + /// + NoPrune, + } +} diff --git a/LibGit2Sharp/Core/GitCheckoutOpts.cs b/LibGit2Sharp/Core/GitCheckoutOpts.cs index 4416aa601..3424094be 100644 --- a/LibGit2Sharp/Core/GitCheckoutOpts.cs +++ b/LibGit2Sharp/Core/GitCheckoutOpts.cs @@ -158,6 +158,7 @@ internal struct GitCheckoutOpts 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 803bc8b3c..bed647e31 100644 --- a/LibGit2Sharp/Core/GitCloneOptions.cs +++ b/LibGit2Sharp/Core/GitCloneOptions.cs @@ -17,7 +17,7 @@ internal struct GitCloneOptions 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 7ce4eafdf..1c71fbb5c 100644 --- a/LibGit2Sharp/Core/GitDiff.cs +++ b/LibGit2Sharp/Core/GitDiff.cs @@ -80,6 +80,13 @@ internal enum GitDiffOptionFlags /// GIT_DIFF_IGNORE_CASE = (1 << 10), + + /// + /// 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. + /// + GIT_DIFF_INCLUDE_CASECHANGE = (1 << 11), + /// /// 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 000000000..02f996dff --- /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 05904c84d..11bee09ea 100644 --- a/LibGit2Sharp/Core/GitIndexEntry.cs +++ b/LibGit2Sharp/Core/GitIndexEntry.cs @@ -15,7 +15,7 @@ internal class GitIndexEntry 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 fb47f2944..9f16c5121 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 a2ebe979d..e122cbdc1 100644 --- a/LibGit2Sharp/Core/GitMergeOpts.cs +++ b/LibGit2Sharp/Core/GitMergeOpts.cs @@ -31,6 +31,11 @@ internal struct GitMergeOpts /// Flags for automerging content. /// public MergeFileFavor MergeFileFavorFlags; + + /// + /// File merging flags. + /// + public GitMergeFileFlags FileFlags; } /// @@ -63,11 +68,11 @@ internal enum GitMergeAnalysis /// 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). - */ + /// + /// 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). + /// GIT_MERGE_ANALYSIS_UNBORN = (1 << 3), } @@ -105,4 +110,53 @@ internal enum GitMergeTreeFlags /// GIT_MERGE_TREE_FIND_RENAMES = (1 << 0), } + + [Flags] + internal enum GitMergeFileFlags + { + /// + /// Defaults + /// + GIT_MERGE_FILE_DEFAULT = 0, + + /// + /// Create standard conflicted merge files + /// + GIT_MERGE_FILE_STYLE_MERGE = (1 << 0), + + /// + /// Create diff3-style files + /// + GIT_MERGE_FILE_STYLE_DIFF3 = (1 << 1), + + /// + /// Condense non-alphanumeric regions for simplified diff file + /// + GIT_MERGE_FILE_SIMPLIFY_ALNUM = (1 << 2), + + /// + /// Ignore all whitespace + /// + GIT_MERGE_FILE_IGNORE_WHITESPACE = (1 << 3), + + /// + /// Ignore changes in amount of whitespace + /// + GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE = (1 << 4), + + /// + /// Ignore whitespace at end of line + /// + GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL = (1 << 5), + + /// + /// Use the "patience diff" algorithm + /// + GIT_MERGE_FILE_DIFF_PATIENCE = (1 << 6), + + /// + /// Take extra time to find minimal diff + /// + GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7), + } } diff --git a/LibGit2Sharp/Core/GitOdbBackend.cs b/LibGit2Sharp/Core/GitOdbBackend.cs index a7b0acf41..e36cdc531 100644 --- a/LibGit2Sharp/Core/GitOdbBackend.cs +++ b/LibGit2Sharp/Core/GitOdbBackend.cs @@ -130,7 +130,7 @@ public delegate int write_callback( public delegate int writestream_callback( out IntPtr stream_out, IntPtr backend, - UIntPtr length, + Int64 length, GitObjectType type); /// diff --git a/LibGit2Sharp/Core/GitOdbBackendStream.cs b/LibGit2Sharp/Core/GitOdbBackendStream.cs index 82f6ce89c..f7eec27d5 100644 --- a/LibGit2Sharp/Core/GitOdbBackendStream.cs +++ b/LibGit2Sharp/Core/GitOdbBackendStream.cs @@ -22,8 +22,8 @@ static GitOdbBackendStream() 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 baebabee7..d4bbcdc3f 100644 --- a/LibGit2Sharp/Core/GitPushOptions.cs +++ b/LibGit2Sharp/Core/GitPushOptions.cs @@ -7,5 +7,6 @@ internal class GitPushOptions { 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 000000000..f38697a42 --- /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 e23d115b7..71537f762 100644 --- a/LibGit2Sharp/Core/GitRemoteCallbacks.cs +++ b/LibGit2Sharp/Core/GitRemoteCallbacks.cs @@ -29,6 +29,10 @@ internal struct GitRemoteCallbacks 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 724c6c414..e721c1e79 100644 --- a/LibGit2Sharp/Core/GitSmartSubtransportRegistration.cs +++ b/LibGit2Sharp/Core/GitSmartSubtransportRegistration.cs @@ -8,9 +8,11 @@ internal class GitSmartSubtransportRegistration { 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 1b64aa1f2..4fb07411a 100644 --- a/LibGit2Sharp/Core/GitSubmoduleOptions.cs +++ b/LibGit2Sharp/Core/GitSubmoduleOptions.cs @@ -9,7 +9,7 @@ internal struct GitSubmoduleOptions 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 a94535299..9b4e818f3 100644 --- a/LibGit2Sharp/Core/NativeMethods.cs +++ b/LibGit2Sharp/Core/NativeMethods.cs @@ -272,7 +272,15 @@ internal static extern int git_commit_create_from_ids( 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 @@ internal static extern int git_note_remove( [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 @@ internal static extern int git_odb_foreach( 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 @@ internal static extern string git_refspec_src( 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 @@ internal static extern int git_remote_create( 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 @@ internal static extern int git_remote_delete( 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 @@ internal static extern int git_remote_push( [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)] @@ -1091,9 +1116,6 @@ internal static extern int git_remote_lookup( [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))] 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 @@ internal static extern int git_remote_lookup( 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 @@ internal delegate int remote_update_tips_callback( 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 68888cae2..4739d7bcc 100644 --- a/LibGit2Sharp/Core/Proxy.cs +++ b/LibGit2Sharp/Core/Proxy.cs @@ -472,6 +472,24 @@ public static bool git_config_delete(ConfigurationSafeHandle config, string name } } + 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 @@ public static ObjectId git_note_create( 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 @@ public static ICollection git_odb_foreach( 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 @@ public static RemoteSafeHandle git_remote_create_with_fetchspec(RepositorySafeHa } } - 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 @@ public static void git_remote_push(RemoteSafeHandle remote, IEnumerable } } - public static void git_remote_set_fetch_refspecs(RemoteSafeHandle remote, IEnumerable 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 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 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 @@ public static void git_remote_rename(RepositorySafeHandle repo, string name, str } } - 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 552b095a4..5286c96a9 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -1,6 +1,6 @@  - + Debug AnyCPU @@ -70,6 +70,8 @@ + + @@ -83,6 +85,7 @@ + @@ -375,7 +378,7 @@ 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}. - +