diff --git a/Lib/NativeBinaries/amd64/git2.dll b/Lib/NativeBinaries/amd64/git2.dll index cdf2a4cbc..04c769094 100644 Binary files a/Lib/NativeBinaries/amd64/git2.dll and b/Lib/NativeBinaries/amd64/git2.dll differ diff --git a/Lib/NativeBinaries/amd64/git2.pdb b/Lib/NativeBinaries/amd64/git2.pdb index 52ef28706..a183d8273 100644 Binary files a/Lib/NativeBinaries/amd64/git2.pdb and b/Lib/NativeBinaries/amd64/git2.pdb differ diff --git a/Lib/NativeBinaries/x86/git2.dll b/Lib/NativeBinaries/x86/git2.dll index 5197e3fee..a29f381c9 100644 Binary files a/Lib/NativeBinaries/x86/git2.dll and b/Lib/NativeBinaries/x86/git2.dll differ diff --git a/Lib/NativeBinaries/x86/git2.pdb b/Lib/NativeBinaries/x86/git2.pdb index cb44fc543..4b8a1e7e5 100644 Binary files a/Lib/NativeBinaries/x86/git2.pdb and b/Lib/NativeBinaries/x86/git2.pdb differ diff --git a/LibGit2Sharp/Configuration.cs b/LibGit2Sharp/Configuration.cs index a372ef424..0028b2108 100644 --- a/LibGit2Sharp/Configuration.cs +++ b/LibGit2Sharp/Configuration.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Runtime.InteropServices; using LibGit2Sharp.Core; using LibGit2Sharp.Core.Handles; @@ -409,11 +410,15 @@ private static Action GetUpdater(Act IEnumerator IEnumerable.GetEnumerator() { - return Proxy.git_config_foreach(LocalHandle, (namePtr, valuePtr) => { - var name = Utf8Marshaler.FromNative(namePtr); - var value = Utf8Marshaler.FromNative(valuePtr); - return new ConfigurationEntry(name, value); - }).GetEnumerator(); + return Proxy.git_config_foreach(LocalHandle, + (entryPtr) => + { + var entry = (GitConfigEntry)Marshal.PtrToStructure(entryPtr, typeof(GitConfigEntry)); + return new ConfigurationEntry(Utf8Marshaler.FromNative(entry.namePtr), + Utf8Marshaler.FromNative(entry.valuePtr), + (ConfigurationLevel) entry.level); + }) + .GetEnumerator(); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() diff --git a/LibGit2Sharp/ConfigurationEntry.cs b/LibGit2Sharp/ConfigurationEntry.cs index f5abb961d..af3a6b83a 100644 --- a/LibGit2Sharp/ConfigurationEntry.cs +++ b/LibGit2Sharp/ConfigurationEntry.cs @@ -15,15 +15,23 @@ public class ConfigurationEntry /// public string Value { get; private set; } + + /// + /// The origin store. + /// + public ConfigurationLevel Level { get; private set; } + /// /// Initializes a new instance of the class with a given key and value /// /// The option name /// The option value, as a string - public ConfigurationEntry(string key, string value) + /// The origin store + public ConfigurationEntry(string key, string value, ConfigurationLevel level) { Key = key; Value = value; + Level = level; } } } diff --git a/LibGit2Sharp/ConfigurationLevel.cs b/LibGit2Sharp/ConfigurationLevel.cs index 987345adf..e4f798a57 100644 --- a/LibGit2Sharp/ConfigurationLevel.cs +++ b/LibGit2Sharp/ConfigurationLevel.cs @@ -8,16 +8,21 @@ public enum ConfigurationLevel /// /// The local .git/config of the current repository. /// - Local, + Local = 4, /// /// The global ~/.gitconfig of the current user. /// - Global, + Global = 3, + + /// + /// The global ~/.config/git/config of the current user + /// + XDG = 2, /// /// The system wide .gitconfig. /// - System + System = 1, } } diff --git a/LibGit2Sharp/Core/GitConfigEntry.cs b/LibGit2Sharp/Core/GitConfigEntry.cs new file mode 100644 index 000000000..c6d614eaa --- /dev/null +++ b/LibGit2Sharp/Core/GitConfigEntry.cs @@ -0,0 +1,14 @@ +using System; +using System.Runtime.InteropServices; + +namespace LibGit2Sharp.Core +{ + [StructLayout(LayoutKind.Sequential)] + internal struct GitConfigEntry + { + public IntPtr namePtr; + public IntPtr valuePtr; + public uint level; + } +} + diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs index ff276da73..550753a54 100644 --- a/LibGit2Sharp/Core/NativeMethods.cs +++ b/LibGit2Sharp/Core/NativeMethods.cs @@ -226,7 +226,8 @@ internal static extern int git_config_get_string( internal static extern int git_config_add_file_ondisk( ConfigurationSafeHandle cfg, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, - int priority); + uint level, + bool force); [DllImport(libgit2)] internal static extern int git_config_new(out ConfigurationSafeHandle cfg); @@ -261,8 +262,7 @@ internal static extern int git_config_set_string( [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string value); internal delegate int config_foreach_callback( - IntPtr var_name, - IntPtr value, + IntPtr entry, IntPtr payload); [DllImport(libgit2)] @@ -591,13 +591,18 @@ internal static extern int git_remote_new( internal static extern void git_remote_disconnect(RemoteSafeHandle remote); [DllImport(libgit2)] - internal static extern int git_remote_download(RemoteSafeHandle remote, ref long bytes, ref GitIndexerStats stats); + internal static extern int git_remote_download( + RemoteSafeHandle remote, + git_transfer_progress_callback progress_cb, + IntPtr progress_payload); [DllImport(libgit2)] internal static extern void git_remote_set_autotag(RemoteSafeHandle remote, TagFetchMode option); [DllImport(libgit2)] - internal static extern void git_remote_set_callbacks(RemoteSafeHandle remote, ref GitRemoteCallbacks callbacks); + internal static extern void git_remote_set_callbacks( + RemoteSafeHandle remote, + ref GitRemoteCallbacks callbacks); internal delegate void remote_progress_callback(IntPtr str, int len, IntPtr data); @@ -776,6 +781,8 @@ internal static extern int git_tag_delete( [DllImport(libgit2)] internal static extern void git_threads_shutdown(); + internal delegate void git_transfer_progress_callback(IntPtr stats, IntPtr payload); + [DllImport(libgit2)] internal static extern int git_tree_create_fromindex(out GitOid treeOid, IndexSafeHandle index); diff --git a/LibGit2Sharp/Core/Proxy.cs b/LibGit2Sharp/Core/Proxy.cs index 0fc1825e4..eaf1c2a17 100644 --- a/LibGit2Sharp/Core/Proxy.cs +++ b/LibGit2Sharp/Core/Proxy.cs @@ -264,11 +264,11 @@ public static ObjectId git_commit_tree_oid(GitObjectSafeHandle obj) #region git_config_ - public static void git_config_add_file_ondisk(ConfigurationSafeHandle config, FilePath path, int priority) + public static void git_config_add_file_ondisk(ConfigurationSafeHandle config, FilePath path, uint level) { using (ThreadAffinity()) { - int res = NativeMethods.git_config_add_file_ondisk(config, path, priority); + int res = NativeMethods.git_config_add_file_ondisk(config, path, level, true); Ensure.Success(res); } } @@ -430,9 +430,9 @@ public static void git_config_set_string(ConfigurationSafeHandle config, string public static ICollection git_config_foreach( ConfigurationSafeHandle config, - Func resultSelector) + Func resultSelector) { - return git_foreach(resultSelector, c => NativeMethods.git_config_foreach(config, (x, y, p) => c(x, y, p), IntPtr.Zero)); + return git_foreach(resultSelector, c => NativeMethods.git_config_foreach(config, (e, p) => c(e, p), IntPtr.Zero)); } #endregion @@ -1041,11 +1041,12 @@ public static void git_remote_disconnect(RemoteSafeHandle remote) } } + // TODO: callback & payload public static void git_remote_download(RemoteSafeHandle remote, ref long bytes, ref GitIndexerStats indexerStats) { using (ThreadAffinity()) { - int res = NativeMethods.git_remote_download(remote, ref bytes, ref indexerStats); + int res = NativeMethods.git_remote_download(remote, null, IntPtr.Zero); Ensure.Success(res); } } diff --git a/LibGit2Sharp/FileStatus.cs b/LibGit2Sharp/FileStatus.cs index 4afc5d0cc..afba95656 100644 --- a/LibGit2Sharp/FileStatus.cs +++ b/LibGit2Sharp/FileStatus.cs @@ -33,24 +33,33 @@ public enum FileStatus /// Removed = (1 << 2), /* GIT_STATUS_INDEX_DELETED */ + /// + /// The renaming of a file has been promoted from the working directory to the Index. A previous version exists in the Head. + /// + Renamed = (1 << 3), /* GIT_STATUS_INDEX_RENAMED */ + + TypeChangedInIndex = (1 << 4), /* GIT_STATUS_INDEX_TYPECHANGE */ + /// /// New file in the working directory, unknown from the Index and the Head. /// - Untracked = (1 << 3), /* GIT_STATUS_WT_NEW */ + Untracked = (1 << 7), /* GIT_STATUS_WT_NEW */ /// /// The file has been updated in the working directory. A previous version exists in the Index. /// - Modified = (1 << 4), /* GIT_STATUS_WT_MODIFIED */ + Modified = (1 << 8), /* GIT_STATUS_WT_MODIFIED */ /// /// The file has been deleted from the working directory. A previous version exists in the Index. /// - Missing = (1 << 5), /* GIT_STATUS_WT_DELETED */ + Missing = (1 << 9), /* GIT_STATUS_WT_DELETED */ + + TypeChangedInWorkdir = (1 << 10), /// /// The file is but its name and/or path matches an exclude pattern in a gitignore file. /// - Ignored = (1 << 6), /* GIT_STATUS_IGNORED */ + Ignored = (1 << 14), /* GIT_STATUS_IGNORED */ } } diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 45734ebc7..8de2023b4 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -69,6 +69,7 @@ + diff --git a/LibGit2Sharp/libgit2_hash.txt b/LibGit2Sharp/libgit2_hash.txt index 8650e69ad..31eb9c145 100644 --- a/LibGit2Sharp/libgit2_hash.txt +++ b/LibGit2Sharp/libgit2_hash.txt @@ -1 +1 @@ -03452b347ef51f3400e40fb7b33adcb4508dcbe8 +a0ce87c51c1a3b1b3b674902148ad28d8e5fa32d diff --git a/libgit2 b/libgit2 index 03452b347..a0ce87c51 160000 --- a/libgit2 +++ b/libgit2 @@ -1 +1 @@ -Subproject commit 03452b347ef51f3400e40fb7b33adcb4508dcbe8 +Subproject commit a0ce87c51c1a3b1b3b674902148ad28d8e5fa32d