Skip to content

Commit 43ca2bf

Browse files
committed
WIP - Updating
1 parent e0cf84f commit 43ca2bf

8 files changed

Lines changed: 74 additions & 47 deletions

File tree

LibGit2Sharp.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHING_EMPTY_BRACES/@EntryValue">True</s:Boolean>
1212
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean>
1313
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
14+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
1415
</wpf:ResourceDictionary>

LibGit2Sharp/CloneOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ CheckoutStrategy IConvertableToGitCheckoutOpts.CheckoutStrategy
5151
get
5252
{
5353
return this.Checkout ?
54-
CheckoutStrategy.GIT_CHECKOUT_SAFE_CREATE :
54+
CheckoutStrategy.GIT_CHECKOUT_SAFE :
5555
CheckoutStrategy.GIT_CHECKOUT_NONE;
5656
}
5757
}

LibGit2Sharp/Core/GitCheckoutOpts.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ internal enum CheckoutStrategy
1717
GIT_CHECKOUT_SAFE = (1 << 0),
1818

1919
/// <summary>
20-
/// Allow safe updates plus creation of missing files.
20+
/// Allow update of entries in working dir that are modified from HEAD.
2121
/// </summary>
22-
GIT_CHECKOUT_SAFE_CREATE = (1 << 1),
22+
GIT_CHECKOUT_FORCE = (1 << 1),
2323

2424
/// <summary>
25-
/// Allow update of entries in working dir that are modified from HEAD.
25+
/// Allow checkout to recreate missing files.
2626
/// </summary>
27-
GIT_CHECKOUT_FORCE = (1 << 2),
27+
GIT_CHECKOUT_RECREATE_MISSING = (1 << 2),
2828

2929
/// <summary>
3030
/// Allow checkout to make safe updates even if conflicts are found
@@ -48,6 +48,7 @@ internal enum CheckoutStrategy
4848

4949
/// <summary>
5050
/// Normally checkout updates index entries as it goes; this stops that
51+
/// Implies `GIT_CHECKOUT_DONT_WRITE_INDEX`.
5152
/// </summary>
5253
GIT_CHECKOUT_DONT_UPDATE_INDEX = (1 << 8),
5354

@@ -94,6 +95,18 @@ internal enum CheckoutStrategy
9495
/// </summary>
9596
GIT_CHECKOUT_CONFLICT_STYLE_DIFF3 = (1 << 21),
9697

98+
/// <summary>
99+
/// Don't overwrite existing files or folders
100+
/// </summary>
101+
GIT_CHECKOUT_DONT_REMOVE_EXISTING = (1 << 22),
102+
103+
/// <summary>
104+
/// Normally checkout writes the index upon completion; this prevents that.
105+
/// </summary>
106+
GIT_CHECKOUT_DONT_WRITE_INDEX = (1 << 23),
107+
108+
// THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED
109+
97110
/// <summary>
98111
/// Recursively checkout submodules with same options (NOT IMPLEMENTED)
99112
/// </summary>

LibGit2Sharp/Core/GitSubmoduleOptions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@ internal struct GitSubmoduleOptions
1313
public GitRemoteCallbacks RemoteCallbacks;
1414

1515
public CheckoutStrategy CloneCheckoutStrategy;
16-
17-
public IntPtr Signature;
1816
}
1917
}
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
using System.Runtime.InteropServices;
2-
31
namespace LibGit2Sharp.Core.Handles
42
{
5-
internal class GitConfigEntryHandle : NotOwnedSafeHandleBase
3+
internal class GitConfigEntryHandle : SafeHandleBase
64
{
75
public GitConfigEntry MarshalAsGitConfigEntry()
86
{
97
return handle.MarshalAs<GitConfigEntry>();
108
}
9+
10+
protected override bool ReleaseHandleImpl()
11+
{
12+
Proxy.git_config_entry_free(handle);
13+
return true;
14+
}
1115
}
1216
}

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,7 @@ internal static extern int git_branch_create(
174174
RepositorySafeHandle repo,
175175
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string branch_name,
176176
GitObjectSafeHandle target, // TODO: GitCommitSafeHandle?
177-
[MarshalAs(UnmanagedType.Bool)] bool force,
178-
SignatureSafeHandle signature,
179-
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
177+
[MarshalAs(UnmanagedType.Bool)] bool force);
180178

181179
[DllImport(libgit2)]
182180
internal static extern int git_branch_delete(
@@ -202,9 +200,7 @@ internal static extern int git_branch_move(
202200
out ReferenceSafeHandle ref_out,
203201
ReferenceSafeHandle reference,
204202
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string new_branch_name,
205-
[MarshalAs(UnmanagedType.Bool)] bool force,
206-
SignatureSafeHandle signature,
207-
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
203+
[MarshalAs(UnmanagedType.Bool)] bool force);
208204

209205
[DllImport(libgit2)]
210206
internal static extern int git_branch_next(
@@ -313,6 +309,9 @@ internal static extern int git_commit_create_from_ids(
313309
[DllImport(libgit2)]
314310
internal static extern void git_config_free(IntPtr cfg);
315311

312+
[DllImport(libgit2)]
313+
internal static extern void git_config_entry_free(IntPtr entry);
314+
316315
[DllImport(libgit2)]
317316
internal static extern int git_config_get_entry(
318317
out GitConfigEntryHandle entry,
@@ -846,7 +845,6 @@ internal static extern int git_reference_create(
846845
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name,
847846
ref GitOid oid,
848847
[MarshalAs(UnmanagedType.Bool)] bool force,
849-
SignatureSafeHandle signature,
850848
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
851849

852850
[DllImport(libgit2)]
@@ -856,7 +854,6 @@ internal static extern int git_reference_symbolic_create(
856854
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name,
857855
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string target,
858856
[MarshalAs(UnmanagedType.Bool)] bool force,
859-
SignatureSafeHandle signature,
860857
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
861858

862859
internal delegate int ref_glob_callback(
@@ -904,23 +901,20 @@ internal static extern int git_reference_rename(
904901
ReferenceSafeHandle reference,
905902
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string newName,
906903
[MarshalAs(UnmanagedType.Bool)] bool force,
907-
SignatureSafeHandle signature,
908904
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
909905

910906
[DllImport(libgit2)]
911907
internal static extern int git_reference_set_target(
912908
out ReferenceSafeHandle ref_out,
913909
ReferenceSafeHandle reference,
914910
ref GitOid id,
915-
SignatureSafeHandle signature,
916911
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
917912

918913
[DllImport(libgit2)]
919914
internal static extern int git_reference_symbolic_set_target(
920915
out ReferenceSafeHandle ref_out,
921916
ReferenceSafeHandle reference,
922917
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string target,
923-
SignatureSafeHandle signature,
924918
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
925919

926920
[DllImport(libgit2)]
@@ -1038,7 +1032,6 @@ internal static extern int git_remote_delete(
10381032
internal static extern int git_remote_fetch(
10391033
RemoteSafeHandle remote,
10401034
ref GitStrArray refspecs,
1041-
SignatureSafeHandle signature,
10421035
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
10431036

10441037
[DllImport(libgit2)]
@@ -1057,9 +1050,7 @@ internal static extern int git_remote_fetch(
10571050
internal static extern int git_remote_push(
10581051
RemoteSafeHandle remote,
10591052
ref GitStrArray refSpecs,
1060-
GitPushOptions opts,
1061-
SignatureSafeHandle signature,
1062-
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string reflogMessage);
1053+
GitPushOptions opts);
10631054

10641055
[DllImport(libgit2)]
10651056
internal static extern UIntPtr git_remote_refspec_count(RemoteSafeHandle remote);
@@ -1160,6 +1151,12 @@ internal static extern int git_repository_fetchhead_foreach(
11601151
[DllImport(libgit2)]
11611152
internal static extern int git_repository_head_unborn(RepositorySafeHandle repo);
11621153

1154+
[DllImport(libgit2)]
1155+
internal static extern int git_repository_ident(
1156+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))] out string name,
1157+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))] out string email,
1158+
RepositorySafeHandle repo);
1159+
11631160
[DllImport(libgit2)]
11641161
internal static extern int git_repository_index(out IndexSafeHandle index, RepositorySafeHandle repo);
11651162

@@ -1217,6 +1214,13 @@ internal static extern void git_repository_set_config(
12171214
RepositorySafeHandle repository,
12181215
ConfigurationSafeHandle config);
12191216

1217+
[DllImport(libgit2)]
1218+
internal static extern int git_repository_set_ident(
1219+
RepositorySafeHandle repo,
1220+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name,
1221+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string email);
1222+
1223+
12201224
[DllImport(libgit2)]
12211225
internal static extern void git_repository_set_index(
12221226
RepositorySafeHandle repository,
@@ -1231,16 +1235,12 @@ internal static extern int git_repository_set_workdir(
12311235
[DllImport(libgit2)]
12321236
internal static extern int git_repository_set_head_detached(
12331237
RepositorySafeHandle repo,
1234-
ref GitOid commitish,
1235-
SignatureSafeHandle signature,
1236-
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
1238+
ref GitOid commitish);
12371239

12381240
[DllImport(libgit2)]
12391241
internal static extern int git_repository_set_head(
12401242
RepositorySafeHandle repo,
1241-
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string refname,
1242-
SignatureSafeHandle signature,
1243-
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
1243+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string refname);
12441244

12451245
[DllImport(libgit2)]
12461246
internal static extern int git_repository_state(
@@ -1255,9 +1255,7 @@ internal static extern int git_reset(
12551255
RepositorySafeHandle repo,
12561256
GitObjectSafeHandle target,
12571257
ResetMode reset_type,
1258-
ref GitCheckoutOpts opts,
1259-
SignatureSafeHandle signature,
1260-
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string log_message);
1258+
ref GitCheckoutOpts opts);
12611259

12621260
[DllImport(libgit2)]
12631261
internal static extern int git_revert(

LibGit2Sharp/Core/Proxy.cs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -433,27 +433,41 @@ public static void git_config_free(IntPtr config)
433433
NativeMethods.git_config_free(config);
434434
}
435435

436+
public static void git_config_entry_free(IntPtr entry)
437+
{
438+
NativeMethods.git_config_free(entry);
439+
}
440+
436441
public static ConfigurationEntry<T> git_config_get_entry<T>(ConfigurationSafeHandle config, string key)
437442
{
438-
GitConfigEntryHandle handle;
443+
GitConfigEntryHandle handle = null;
439444

440445
if (!configurationParser.ContainsKey(typeof(T)))
441446
{
442447
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Generic Argument of type '{0}' is not supported.", typeof(T).FullName));
443448
}
444449

445-
using (ThreadAffinity())
450+
GitConfigEntry entry;
451+
452+
try
446453
{
447-
var res = NativeMethods.git_config_get_entry(out handle, config, key);
448-
if (res == (int)GitErrorCode.NotFound)
454+
using (ThreadAffinity())
449455
{
450-
return null;
451-
}
456+
var res = NativeMethods.git_config_get_entry(out handle, config, key);
457+
if (res == (int)GitErrorCode.NotFound)
458+
{
459+
return null;
460+
}
452461

453-
Ensure.ZeroResult(res);
454-
}
462+
Ensure.ZeroResult(res);
455463

456-
GitConfigEntry entry = handle.MarshalAsGitConfigEntry();
464+
entry = handle.MarshalAsGitConfigEntry();
465+
}
466+
}
467+
finally
468+
{
469+
handle.SafeDispose();
470+
}
457471

458472
return new ConfigurationEntry<T>(LaxUtf8Marshaler.FromNative(entry.namePtr),
459473
(T)configurationParser[typeof(T)](LaxUtf8Marshaler.FromNative(entry.valuePtr)),
@@ -1576,10 +1590,9 @@ public static Tuple<int, int> git_patch_line_stats(PatchSafeHandle patch)
15761590
#region git_reference_
15771591

15781592
public static ReferenceSafeHandle git_reference_create(RepositorySafeHandle repo, string name, ObjectId targetId, bool allowOverwrite,
1579-
Signature signature, string logMessage)
1593+
string logMessage)
15801594
{
15811595
using (ThreadAffinity())
1582-
using (var sigHandle = signature.BuildHandle())
15831596
{
15841597
GitOid oid = targetId.Oid;
15851598
ReferenceSafeHandle handle;
@@ -2037,7 +2050,7 @@ public static void git_remote_set_url(RemoteSafeHandle remote, string url)
20372050
Ensure.ZeroResult(res);
20382051
}
20392052
}
2040-
2053+
20412054
public static void git_remote_set_pushurl(RemoteSafeHandle remote, string url)
20422055
{
20432056
using (ThreadAffinity())

LibGit2Sharp/SubmoduleCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public virtual void Update(string name, SubmoduleUpdateOptions options)
108108
Version = 1,
109109
CheckoutOptions = gitCheckoutOptions,
110110
RemoteCallbacks = gitRemoteCallbacks,
111-
CloneCheckoutStrategy = CheckoutStrategy.GIT_CHECKOUT_SAFE_CREATE
111+
CloneCheckoutStrategy = CheckoutStrategy.GIT_CHECKOUT_SAFE
112112
};
113113

114114
Proxy.git_submodule_update(handle, options.Init, ref gitSubmoduleUpdateOpts);

0 commit comments

Comments
 (0)