Skip to content

Commit d8a0355

Browse files
committed
massage the API a bit
1 parent 0b4ee8f commit d8a0355

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

LibGit2Sharp/Core/Proxy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ public static IndexReucEntrySafeHandle git_index_reuc_get_bypath(IndexSafeHandle
11351135
return NativeMethods.git_index_reuc_get_bypath(index, path);
11361136
}
11371137

1138-
public static void git_index_update_all(IndexSafeHandle index, FilePath[] filePaths)
1138+
public static void git_index_update_all(IndexSafeHandle index, IEnumerable<string> filePaths)
11391139
{
11401140
// maybe not?
11411141
using (ThreadAffinity())
@@ -1144,7 +1144,7 @@ public static void git_index_update_all(IndexSafeHandle index, FilePath[] filePa
11441144

11451145
try
11461146
{
1147-
array = GitStrArrayManaged.BuildFrom(filePaths);
1147+
array = GitStrArrayManaged.BuildFrom(filePaths.ToArray());
11481148
NativeMethods.git_index_matched_path_cb callback = (path, pathspec, payload) =>
11491149
{
11501150
return 0;

LibGit2Sharp/Index.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,37 @@ public virtual void Add(Blob blob, string indexEntryPath, Mode indexEntryMode)
226226
UpdatePhysicalIndex();
227227
}
228228

229+
/// <summary>
230+
/// Update all files in the index
231+
/// </summary>
229232
public virtual void Update()
230233
{
231-
FilePath defaultPath = "*";
232-
Proxy.git_index_update_all(Handle, new [] { defaultPath });
234+
Proxy.git_index_update_all(Handle, new [] { "*" });
235+
}
236+
237+
/// <summary>
238+
/// Update files for a given pathspec
239+
/// </summary>
240+
/// <param name="pathSpec">
241+
/// Limit the scope of paths to update to the provided pathspecs
242+
/// </param>
243+
public virtual void Update(string pathSpec)
244+
{
245+
Proxy.git_index_update_all(Handle, new[] { pathSpec });
233246
}
234247

248+
/// <summary>
249+
/// Update files for given pathspecs
250+
/// </summary>
251+
/// <param name="pathSpecs">
252+
/// Limit the scope of paths to update to the provided pathspecs
253+
/// </param>
254+
public virtual void Update(IEnumerable<string> pathSpecs)
255+
{
256+
Proxy.git_index_update_all(Handle, pathSpecs);
257+
}
258+
259+
235260
private void UpdatePhysicalIndex()
236261
{
237262
Proxy.git_index_write(handle);

0 commit comments

Comments
 (0)