Skip to content

Libgit2: bump to a0ce87c51 #235

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

Merged
merged 1 commit into from
Oct 26, 2012
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 modified Lib/NativeBinaries/amd64/git2.dll
Binary file not shown.
Binary file modified Lib/NativeBinaries/amd64/git2.pdb
Binary file not shown.
Binary file modified Lib/NativeBinaries/x86/git2.dll
Binary file not shown.
Binary file modified Lib/NativeBinaries/x86/git2.pdb
Binary file not shown.
15 changes: 10 additions & 5 deletions LibGit2Sharp/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -409,11 +410,15 @@ private static Action<string, object, ConfigurationSafeHandle> GetUpdater<T>(Act

IEnumerator<ConfigurationEntry> IEnumerable<ConfigurationEntry>.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();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this better, @jamill? It makes the tests pass.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Great!

}

System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
Expand Down
10 changes: 9 additions & 1 deletion LibGit2Sharp/ConfigurationEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,23 @@ public class ConfigurationEntry
/// </summary>
public string Value { get; private set; }


/// <summary>
/// The origin store.
/// </summary>
public ConfigurationLevel Level { get; private set; }

/// <summary>
/// Initializes a new instance of the <see cref="ConfigurationEntry"/> class with a given key and value
/// </summary>
/// <param name="key">The option name</param>
/// <param name="value">The option value, as a string</param>
public ConfigurationEntry(string key, string value)
/// <param name="level">The origin store</param>
public ConfigurationEntry(string key, string value, ConfigurationLevel level)
{
Key = key;
Value = value;
Level = level;
}
}
}
11 changes: 8 additions & 3 deletions LibGit2Sharp/ConfigurationLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@ public enum ConfigurationLevel
/// <summary>
/// The local .git/config of the current repository.
/// </summary>
Local,
Local = 4,

/// <summary>
/// The global ~/.gitconfig of the current user.
/// </summary>
Global,
Global = 3,

/// <summary>
/// The global ~/.config/git/config of the current user
/// </summary>
XDG = 2,

/// <summary>
/// The system wide .gitconfig.
/// </summary>
System
System = 1,
}
}
14 changes: 14 additions & 0 deletions LibGit2Sharp/Core/GitConfigEntry.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}

17 changes: 12 additions & 5 deletions LibGit2Sharp/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
11 changes: 6 additions & 5 deletions LibGit2Sharp/Core/Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -430,9 +430,9 @@ public static void git_config_set_string(ConfigurationSafeHandle config, string

public static ICollection<TResult> git_config_foreach<TResult>(
ConfigurationSafeHandle config,
Func<IntPtr, IntPtr, TResult> resultSelector)
Func<IntPtr, TResult> 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
Expand Down Expand Up @@ -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);
}
}
Expand Down
17 changes: 13 additions & 4 deletions LibGit2Sharp/FileStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,33 @@ public enum FileStatus
/// </summary>
Removed = (1 << 2), /* GIT_STATUS_INDEX_DELETED */

/// <summary>
/// The renaming of a file has been promoted from the working directory to the Index. A previous version exists in the Head.
/// </summary>
Renamed = (1 << 3), /* GIT_STATUS_INDEX_RENAMED */

TypeChangedInIndex = (1 << 4), /* GIT_STATUS_INDEX_TYPECHANGE */

/// <summary>
/// New file in the working directory, unknown from the Index and the Head.
/// </summary>
Untracked = (1 << 3), /* GIT_STATUS_WT_NEW */
Untracked = (1 << 7), /* GIT_STATUS_WT_NEW */

/// <summary>
/// The file has been updated in the working directory. A previous version exists in the Index.
/// </summary>
Modified = (1 << 4), /* GIT_STATUS_WT_MODIFIED */
Modified = (1 << 8), /* GIT_STATUS_WT_MODIFIED */

/// <summary>
/// The file has been deleted from the working directory. A previous version exists in the Index.
/// </summary>
Missing = (1 << 5), /* GIT_STATUS_WT_DELETED */
Missing = (1 << 9), /* GIT_STATUS_WT_DELETED */

TypeChangedInWorkdir = (1 << 10),

/// <summary>
/// The file is <see cref="Untracked"/> but its name and/or path matches an exclude pattern in a <c>gitignore</c> file.
/// </summary>
Ignored = (1 << 6), /* GIT_STATUS_IGNORED */
Ignored = (1 << 14), /* GIT_STATUS_IGNORED */
}
}
1 change: 1 addition & 0 deletions LibGit2Sharp/LibGit2Sharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<Compile Include="ConfigurationEntry.cs" />
<Compile Include="ContentChanges.cs" />
<Compile Include="Core\GitCheckoutOpts.cs" />
<Compile Include="Core\GitConfigEntry.cs" />
<Compile Include="Core\Proxy.cs" />
<Compile Include="Handlers.cs" />
<Compile Include="ReferenceCollectionExtensions.cs" />
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/libgit2_hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
03452b347ef51f3400e40fb7b33adcb4508dcbe8
a0ce87c51c1a3b1b3b674902148ad28d8e5fa32d
2 changes: 1 addition & 1 deletion libgit2
Submodule libgit2 updated 225 files