Skip to content

Commit ba6783d

Browse files
committed
WIP
1 parent aab613f commit ba6783d

11 files changed

+85
-51
lines changed

LibGit2Sharp/Core/GitCheckoutOpts.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ internal struct GitCheckoutOpts
158158
public GitStrArray paths;
159159

160160
public IntPtr baseline;
161+
public IntPtr baseline_index;
161162
public IntPtr target_directory;
162163

163164
public IntPtr ancestor_label;

LibGit2Sharp/Core/GitFetchOptions.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Runtime.InteropServices;
2+
3+
namespace LibGit2Sharp.Core
4+
{
5+
[StructLayout(LayoutKind.Sequential)]
6+
internal class GitFetchOptions
7+
{
8+
GitRemoteCallbacks remote_callbacks;
9+
FetchPruneStrategy prune;
10+
int update_fetchhead;
11+
TagFetchMode download_tags;
12+
}
13+
}

LibGit2Sharp/Core/GitIndexEntry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal class GitIndexEntry
1515
public uint Mode;
1616
public uint Uid;
1717
public uint Gid;
18-
public Int64 file_size;
18+
public uint file_size;
1919
public GitOid Id;
2020
public ushort Flags;
2121
public ushort ExtendedFlags;

LibGit2Sharp/Core/GitIndexTime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace LibGit2Sharp.Core
55
[StructLayout(LayoutKind.Sequential)]
66
internal class GitIndexTime
77
{
8-
public long seconds;
8+
public uint seconds;
99
public uint nanoseconds;
1010
}
1111
}

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ internal static extern int git_note_remove(
744744

745745
[DllImport(libgit2)]
746746
internal static extern int git_note_default_ref(
747-
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))] out string notes_ref,
747+
GitBuf buf,
748748
RepositorySafeHandle repo);
749749

750750
internal delegate int git_note_foreach_cb(
@@ -1064,12 +1064,14 @@ internal static extern int git_remote_push(
10641064

10651065
[DllImport(libgit2)]
10661066
internal static extern int git_remote_set_url(
1067-
RemoteSafeHandle remote,
1067+
RepositorySafeHandle repo,
1068+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string remote_name,
10681069
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string url);
10691070

10701071
[DllImport(libgit2)]
10711072
internal static extern int git_remote_set_pushurl(
1072-
RemoteSafeHandle remote,
1073+
RepositorySafeHandle repo,
1074+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string remote_name,
10731075
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string url);
10741076

10751077
[DllImport(libgit2)]
@@ -1106,7 +1108,10 @@ internal static extern int git_remote_lookup(
11061108
internal static extern string git_remote_pushurl(RemoteSafeHandle remote);
11071109

11081110
[DllImport(libgit2)]
1109-
internal static extern void git_remote_set_autotag(RemoteSafeHandle remote, TagFetchMode option);
1111+
internal static extern void git_remote_set_autotag(
1112+
RepositorySafeHandle repo,
1113+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string remote_name,
1114+
TagFetchMode option);
11101115

11111116
[DllImport(libgit2)]
11121117
internal static extern int git_remote_set_callbacks(

LibGit2Sharp/Core/Proxy.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,20 +2150,20 @@ public static void git_remote_set_push_refspecs(RemoteSafeHandle remote, IEnumer
21502150
}
21512151
}
21522152

2153-
public static void git_remote_set_url(RemoteSafeHandle remote, string url)
2153+
public static void git_remote_set_url(RepositorySafeHandle repo, string remote_name, string url)
21542154
{
21552155
using (ThreadAffinity())
21562156
{
2157-
int res = NativeMethods.git_remote_set_url(remote, url);
2157+
int res = NativeMethods.git_remote_set_url(repo, remote_name, url);
21582158
Ensure.ZeroResult(res);
21592159
}
21602160
}
21612161

2162-
public static void git_remote_set_pushurl(RemoteSafeHandle remote, string url)
2162+
public static void git_remote_set_pushurl(RepositorySafeHandle repo, string remote_name, string url)
21632163
{
21642164
using (ThreadAffinity())
21652165
{
2166-
int res = NativeMethods.git_remote_set_pushurl(remote, url);
2166+
int res = NativeMethods.git_remote_set_pushurl(repo, remote_name, url);
21672167
Ensure.ZeroResult(res);
21682168
}
21692169
}
@@ -2321,18 +2321,9 @@ public static void git_remote_rename(RepositorySafeHandle repo, string name, str
23212321
}
23222322
}
23232323

2324-
public static void git_remote_save(RemoteSafeHandle remote)
2324+
public static void git_remote_set_autotag(RepositorySafeHandle repo, string remote_name, TagFetchMode value)
23252325
{
2326-
using (ThreadAffinity())
2327-
{
2328-
int res = NativeMethods.git_remote_save(remote);
2329-
Ensure.ZeroResult(res);
2330-
}
2331-
}
2332-
2333-
public static void git_remote_set_autotag(RemoteSafeHandle remote, TagFetchMode value)
2334-
{
2335-
NativeMethods.git_remote_set_autotag(remote, value);
2326+
NativeMethods.git_remote_set_autotag(repo, remote_name, value);
23362327
}
23372328

23382329
public static void git_remote_set_callbacks(RemoteSafeHandle remote, ref GitRemoteCallbacks callbacks)

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<Compile Include="CommitSortStrategies.cs" />
7070
<Compile Include="CompareOptions.cs" />
7171
<Compile Include="Core\FileHistory.cs" />
72+
<Compile Include="Core\GitFetchOptions.cs" />
7273
<Compile Include="Core\Platform.cs" />
7374
<Compile Include="Core\Handles\ConflictIteratorSafeHandle.cs" />
7475
<Compile Include="DescribeOptions.cs" />

LibGit2Sharp/Network.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static void DoFetch(RemoteSafeHandle remoteHandle, FetchOptions options, string
9797

9898
if (options.TagFetchMode.HasValue)
9999
{
100-
Proxy.git_remote_set_autotag(remoteHandle, options.TagFetchMode.Value);
100+
// Proxy.git_remote_set_autotag(remoteHandle, options.TagFetchMode.Value);
101101
}
102102

103103
var callbacks = new RemoteCallbacks(options);
@@ -305,4 +305,23 @@ internal virtual IEnumerable<FetchHead> FetchHeads
305305
}
306306
}
307307
}
308+
309+
/// <summary>
310+
///
311+
/// </summary>
312+
public enum FetchPruneStrategy
313+
{
314+
/**
315+
* Use the setting from the configuration
316+
*/
317+
Fallback = 0,
318+
/**
319+
* Force pruning on
320+
*/
321+
Prune,
322+
/**
323+
* Force pruning off
324+
*/
325+
NoPrune,
326+
}
308327
}

LibGit2Sharp/RemoteCollection.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,10 @@ internal Remote RemoteForName(string name, bool shouldThrowIfNotFound = true)
5757
/// <returns>The updated remote.</returns>
5858
public virtual Remote Update(Remote remote, params Action<RemoteUpdater>[] actions)
5959
{
60-
using (var updater = new RemoteUpdater(this.repository, remote))
60+
var updater = new RemoteUpdater(this.repository, remote);
61+
foreach (Action<RemoteUpdater> action in actions)
6162
{
62-
foreach (Action<RemoteUpdater> action in actions)
63-
{
64-
action(updater);
65-
}
63+
action(updater);
6664
}
6765

6866
return this[remote.Name];

LibGit2Sharp/RemoteUpdater.cs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ namespace LibGit2Sharp
99
/// <summary>
1010
/// Exposes properties of a remote that can be updated.
1111
/// </summary>
12-
public class RemoteUpdater : IDisposable
12+
public class RemoteUpdater
1313
{
1414
private readonly UpdatingCollection<string> fetchRefSpecs;
1515
private readonly UpdatingCollection<string> pushRefSpecs;
16-
private readonly RemoteSafeHandle remoteHandle;
16+
private readonly RepositorySafeHandle repo;
17+
private readonly Remote remote;
1718

1819
/// <summary>
1920
/// Needed for mocking purposes.
@@ -29,29 +30,40 @@ internal RemoteUpdater(Repository repo, Remote remote)
2930
fetchRefSpecs = new UpdatingCollection<string>(GetFetchRefSpecs, SetFetchRefSpecs);
3031
pushRefSpecs = new UpdatingCollection<string>(GetPushRefSpecs, SetPushRefSpecs);
3132

32-
remoteHandle = Proxy.git_remote_lookup(repo.Handle, remote.Name, true);
33+
this.repo = repo.Handle;
34+
this.remote = remote;
3335
}
3436

3537
private IEnumerable<string> GetFetchRefSpecs()
3638
{
37-
return Proxy.git_remote_get_fetch_refspecs(remoteHandle);
39+
using (var remoteHandle = Proxy.git_remote_lookup(repo, remote.Name, true))
40+
{
41+
return Proxy.git_remote_get_fetch_refspecs(remoteHandle);
42+
}
3843
}
3944

4045
private void SetFetchRefSpecs(IEnumerable<string> value)
4146
{
42-
Proxy.git_remote_set_fetch_refspecs(remoteHandle, value);
43-
Proxy.git_remote_save(remoteHandle);
47+
using (var remoteHandle = Proxy.git_remote_lookup(repo, remote.Name, true))
48+
{
49+
Proxy.git_remote_set_fetch_refspecs(remoteHandle, value);
50+
}
4451
}
4552

4653
private IEnumerable<string> GetPushRefSpecs()
4754
{
48-
return Proxy.git_remote_get_push_refspecs(remoteHandle);
55+
using (var remoteHandle = Proxy.git_remote_lookup(repo, remote.Name, true))
56+
{
57+
return Proxy.git_remote_get_push_refspecs(remoteHandle);
58+
}
4959
}
5060

5161
private void SetPushRefSpecs(IEnumerable<string> value)
5262
{
53-
Proxy.git_remote_set_push_refspecs(remoteHandle, value);
54-
Proxy.git_remote_save(remoteHandle);
63+
using (var remoteHandle = Proxy.git_remote_lookup(repo, remote.Name, true))
64+
{
65+
Proxy.git_remote_set_push_refspecs(remoteHandle, value);
66+
}
5567
}
5668

5769
/// <summary>
@@ -61,8 +73,7 @@ public virtual TagFetchMode TagFetchMode
6173
{
6274
set
6375
{
64-
Proxy.git_remote_set_autotag(remoteHandle, value);
65-
Proxy.git_remote_save(remoteHandle);
76+
Proxy.git_remote_set_autotag(repo, remote.Name, value);
6677
}
6778
}
6879

@@ -73,8 +84,7 @@ public virtual string Url
7384
{
7485
set
7586
{
76-
Proxy.git_remote_set_url(remoteHandle, value);
77-
Proxy.git_remote_save(remoteHandle);
87+
Proxy.git_remote_set_url(repo, remote.Name, value);
7888
}
7989
}
8090

@@ -85,8 +95,7 @@ public virtual string PushUrl
8595
{
8696
set
8797
{
88-
Proxy.git_remote_set_pushurl(remoteHandle, value);
89-
Proxy.git_remote_save(remoteHandle);
98+
Proxy.git_remote_set_pushurl(repo, remote.Name, value);
9099
}
91100
}
92101

@@ -188,13 +197,5 @@ private void Save()
188197
setter(list.Value);
189198
}
190199
}
191-
192-
/// <summary>
193-
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
194-
/// </summary>
195-
public void Dispose()
196-
{
197-
remoteHandle.Dispose();
198-
}
199200
}
200201
}

LibGit2Sharp/TagFetchMode.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66
/// </summary>
77
public enum TagFetchMode
88
{
9+
/// <summary>
10+
/// Use setting from config.
11+
/// </summary>
12+
Fallback = 0,
13+
914
/// <summary>
1015
/// Default behavior. Will automatically retrieve tags that
1116
/// point to objects retrieved during this fetch.
1217
/// </summary>
13-
Auto = 0, // GIT_REMOTE_DOWNLOAD_TAGS_AUTO
18+
Auto, // GIT_REMOTE_DOWNLOAD_TAGS_AUTO
1419

1520
/// <summary>
1621
/// No tag will be retrieved.

0 commit comments

Comments
 (0)