Skip to content

Commit 44aa149

Browse files
shiftkeynulltoken
authored andcommitted
Drop optional parameters in Diff.cs
1 parent 32da01c commit 44aa149

File tree

1 file changed

+211
-7
lines changed

1 file changed

+211
-7
lines changed

LibGit2Sharp/Diff.cs

Lines changed: 211 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,97 @@ private static IDictionary<DiffTargets, Func<Repository, TreeComparisonHandleRet
102102
{ typeof(PatchStats), diff => new PatchStats(diff) },
103103
};
104104

105+
/// <summary>
106+
/// Show changes between two <see cref="Blob"/>s.
107+
/// </summary>
108+
/// <param name="oldBlob">The <see cref="Blob"/> you want to compare from.</param>
109+
/// <param name="newBlob">The <see cref="Blob"/> you want to compare to.</param>
110+
/// <returns>A <see cref="ContentChanges"/> containing the changes between the <paramref name="oldBlob"/> and the <paramref name="newBlob"/>.</returns>
111+
public virtual ContentChanges Compare(Blob oldBlob, Blob newBlob)
112+
{
113+
return Compare(oldBlob, newBlob, null);
114+
}
115+
105116
/// <summary>
106117
/// Show changes between two <see cref="Blob"/>s.
107118
/// </summary>
108119
/// <param name="oldBlob">The <see cref="Blob"/> you want to compare from.</param>
109120
/// <param name="newBlob">The <see cref="Blob"/> you want to compare to.</param>
110121
/// <param name="compareOptions">Additional options to define comparison behavior.</param>
111122
/// <returns>A <see cref="ContentChanges"/> containing the changes between the <paramref name="oldBlob"/> and the <paramref name="newBlob"/>.</returns>
112-
public virtual ContentChanges Compare(Blob oldBlob, Blob newBlob, CompareOptions compareOptions = null)
123+
public virtual ContentChanges Compare(Blob oldBlob, Blob newBlob, CompareOptions compareOptions)
113124
{
114125
using (GitDiffOptions options = BuildOptions(DiffModifiers.None, compareOptions: compareOptions))
115126
{
116127
return new ContentChanges(repo, oldBlob, newBlob, options);
117128
}
118129
}
119130

131+
/// <summary>
132+
/// Show changes between two <see cref="Tree"/>s.
133+
/// </summary>
134+
/// <param name="oldTree">The <see cref="Tree"/> you want to compare from.</param>
135+
/// <param name="newTree">The <see cref="Tree"/> you want to compare to.</param>
136+
/// <returns>A <see cref="TreeChanges"/> containing the changes between the <paramref name="oldTree"/> and the <paramref name="newTree"/>.</returns>
137+
public virtual T Compare<T>(Tree oldTree, Tree newTree) where T : class
138+
{
139+
return Compare<T>(oldTree, newTree, null, null, null);
140+
}
141+
142+
/// <summary>
143+
/// Show changes between two <see cref="Tree"/>s.
144+
/// </summary>
145+
/// <param name="oldTree">The <see cref="Tree"/> you want to compare from.</param>
146+
/// <param name="newTree">The <see cref="Tree"/> you want to compare to.</param>
147+
/// <param name="paths">The list of paths (either files or directories) that should be compared.</param>
148+
/// <returns>A <see cref="TreeChanges"/> containing the changes between the <paramref name="oldTree"/> and the <paramref name="newTree"/>.</returns>
149+
public virtual T Compare<T>(Tree oldTree, Tree newTree, IEnumerable<string> paths) where T : class
150+
{
151+
return Compare<T>(oldTree, newTree, paths, null, null);
152+
}
153+
154+
/// <summary>
155+
/// Show changes between two <see cref="Tree"/>s.
156+
/// </summary>
157+
/// <param name="oldTree">The <see cref="Tree"/> you want to compare from.</param>
158+
/// <param name="newTree">The <see cref="Tree"/> you want to compare to.</param>
159+
/// <param name="paths">The list of paths (either files or directories) that should be compared.</param>
160+
/// <param name="explicitPathsOptions">
161+
/// If set, the passed <paramref name="paths"/> will be treated as explicit paths.
162+
/// Use these options to determine how unmatched explicit paths should be handled.
163+
/// </param>
164+
/// <returns>A <see cref="TreeChanges"/> containing the changes between the <paramref name="oldTree"/> and the <paramref name="newTree"/>.</returns>
165+
public virtual T Compare<T>(Tree oldTree, Tree newTree, IEnumerable<string> paths,
166+
ExplicitPathsOptions explicitPathsOptions) where T : class
167+
{
168+
return Compare<T>(oldTree, newTree, paths, explicitPathsOptions, null);
169+
}
170+
171+
/// <summary>
172+
/// Show changes between two <see cref="Tree"/>s.
173+
/// </summary>
174+
/// <param name="oldTree">The <see cref="Tree"/> you want to compare from.</param>
175+
/// <param name="newTree">The <see cref="Tree"/> you want to compare to.</param>
176+
/// <param name="paths">The list of paths (either files or directories) that should be compared.</param>
177+
/// <param name="compareOptions">Additional options to define patch generation behavior.</param>
178+
/// <returns>A <see cref="TreeChanges"/> containing the changes between the <paramref name="oldTree"/> and the <paramref name="newTree"/>.</returns>
179+
public virtual T Compare<T>(Tree oldTree, Tree newTree, IEnumerable<string> paths, CompareOptions compareOptions) where T : class
180+
{
181+
return Compare<T>(oldTree, newTree, paths, null, compareOptions);
182+
}
183+
184+
/// <summary>
185+
/// Show changes between two <see cref="Tree"/>s.
186+
/// </summary>
187+
/// <param name="oldTree">The <see cref="Tree"/> you want to compare from.</param>
188+
/// <param name="newTree">The <see cref="Tree"/> you want to compare to.</param>
189+
/// <param name="compareOptions">Additional options to define patch generation behavior.</param>
190+
/// <returns>A <see cref="TreeChanges"/> containing the changes between the <paramref name="oldTree"/> and the <paramref name="newTree"/>.</returns>
191+
public virtual T Compare<T>(Tree oldTree, Tree newTree, CompareOptions compareOptions) where T : class
192+
{
193+
return Compare<T>(oldTree, newTree, null, null, compareOptions);
194+
}
195+
120196
/// <summary>
121197
/// Show changes between two <see cref="Tree"/>s.
122198
/// </summary>
@@ -129,8 +205,8 @@ public virtual ContentChanges Compare(Blob oldBlob, Blob newBlob, CompareOptions
129205
/// </param>
130206
/// <param name="compareOptions">Additional options to define patch generation behavior.</param>
131207
/// <returns>A <see cref="TreeChanges"/> containing the changes between the <paramref name="oldTree"/> and the <paramref name="newTree"/>.</returns>
132-
public virtual T Compare<T>(Tree oldTree, Tree newTree, IEnumerable<string> paths = null, ExplicitPathsOptions explicitPathsOptions = null,
133-
CompareOptions compareOptions = null) where T : class
208+
public virtual T Compare<T>(Tree oldTree, Tree newTree, IEnumerable<string> paths, ExplicitPathsOptions explicitPathsOptions,
209+
CompareOptions compareOptions) where T : class
134210
{
135211
Func<DiffSafeHandle, object> builder;
136212

@@ -164,6 +240,64 @@ public virtual T Compare<T>(Tree oldTree, Tree newTree, IEnumerable<string> path
164240
}
165241
}
166242

243+
/// <summary>
244+
/// Show changes between a <see cref="Tree"/> and the Index, the Working Directory, or both.
245+
/// <para>
246+
/// The level of diff performed can be specified by passing either a <see cref="TreeChanges"/>
247+
/// or <see cref="Patch"/> type as the generic parameter.
248+
/// </para>
249+
/// </summary>
250+
/// <param name="oldTree">The <see cref="Tree"/> to compare from.</param>
251+
/// <param name="diffTargets">The targets to compare to.</param>
252+
/// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or
253+
/// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam>
254+
/// <returns>A <typeparamref name="T"/> containing the changes between the <see cref="Tree"/> and the selected target.</returns>
255+
public virtual T Compare<T>(Tree oldTree, DiffTargets diffTargets) where T : class
256+
{
257+
return Compare<T>(oldTree, diffTargets, null, null, null);
258+
}
259+
260+
/// <summary>
261+
/// Show changes between a <see cref="Tree"/> and the Index, the Working Directory, or both.
262+
/// <para>
263+
/// The level of diff performed can be specified by passing either a <see cref="TreeChanges"/>
264+
/// or <see cref="Patch"/> type as the generic parameter.
265+
/// </para>
266+
/// </summary>
267+
/// <param name="oldTree">The <see cref="Tree"/> to compare from.</param>
268+
/// <param name="diffTargets">The targets to compare to.</param>
269+
/// <param name="paths">The list of paths (either files or directories) that should be compared.</param>
270+
/// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or
271+
/// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam>
272+
/// <returns>A <typeparamref name="T"/> containing the changes between the <see cref="Tree"/> and the selected target.</returns>
273+
public virtual T Compare<T>(Tree oldTree, DiffTargets diffTargets, IEnumerable<string> paths) where T : class
274+
{
275+
return Compare<T>(oldTree, diffTargets, paths, null, null);
276+
}
277+
278+
/// <summary>
279+
/// Show changes between a <see cref="Tree"/> and the Index, the Working Directory, or both.
280+
/// <para>
281+
/// The level of diff performed can be specified by passing either a <see cref="TreeChanges"/>
282+
/// or <see cref="Patch"/> type as the generic parameter.
283+
/// </para>
284+
/// </summary>
285+
/// <param name="oldTree">The <see cref="Tree"/> to compare from.</param>
286+
/// <param name="diffTargets">The targets to compare to.</param>
287+
/// <param name="paths">The list of paths (either files or directories) that should be compared.</param>
288+
/// <param name="explicitPathsOptions">
289+
/// If set, the passed <paramref name="paths"/> will be treated as explicit paths.
290+
/// Use these options to determine how unmatched explicit paths should be handled.
291+
/// </param>
292+
/// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or
293+
/// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam>
294+
/// <returns>A <typeparamref name="T"/> containing the changes between the <see cref="Tree"/> and the selected target.</returns>
295+
public virtual T Compare<T>(Tree oldTree, DiffTargets diffTargets, IEnumerable<string> paths,
296+
ExplicitPathsOptions explicitPathsOptions) where T : class
297+
{
298+
return Compare<T>(oldTree, diffTargets, paths, explicitPathsOptions, null);
299+
}
300+
167301
/// <summary>
168302
/// Show changes between a <see cref="Tree"/> and the Index, the Working Directory, or both.
169303
/// <para>
@@ -182,8 +316,8 @@ public virtual T Compare<T>(Tree oldTree, Tree newTree, IEnumerable<string> path
182316
/// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or
183317
/// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam>
184318
/// <returns>A <typeparamref name="T"/> containing the changes between the <see cref="Tree"/> and the selected target.</returns>
185-
public virtual T Compare<T>(Tree oldTree, DiffTargets diffTargets, IEnumerable<string> paths = null,
186-
ExplicitPathsOptions explicitPathsOptions = null, CompareOptions compareOptions = null) where T : class
319+
public virtual T Compare<T>(Tree oldTree, DiffTargets diffTargets, IEnumerable<string> paths,
320+
ExplicitPathsOptions explicitPathsOptions, CompareOptions compareOptions) where T : class
187321
{
188322
Func<DiffSafeHandle, object> builder;
189323

@@ -219,6 +353,76 @@ public virtual T Compare<T>(Tree oldTree, DiffTargets diffTargets, IEnumerable<s
219353
}
220354
}
221355

356+
/// <summary>
357+
/// Show changes between the working directory and the index.
358+
/// <para>
359+
/// The level of diff performed can be specified by passing either a <see cref="TreeChanges"/>
360+
/// or <see cref="Patch"/> type as the generic parameter.
361+
/// </para>
362+
/// </summary>
363+
/// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or
364+
/// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam>
365+
/// <returns>A <typeparamref name="T"/> containing the changes between the working directory and the index.</returns>
366+
public virtual T Compare<T>() where T : class
367+
{
368+
return Compare<T>(DiffModifiers.None);
369+
}
370+
371+
/// <summary>
372+
/// Show changes between the working directory and the index.
373+
/// <para>
374+
/// The level of diff performed can be specified by passing either a <see cref="TreeChanges"/>
375+
/// or <see cref="Patch"/> type as the generic parameter.
376+
/// </para>
377+
/// </summary>
378+
/// <param name="paths">The list of paths (either files or directories) that should be compared.</param>
379+
/// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or
380+
/// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam>
381+
/// <returns>A <typeparamref name="T"/> containing the changes between the working directory and the index.</returns>
382+
public virtual T Compare<T>(IEnumerable<string> paths) where T : class
383+
{
384+
return Compare<T>(DiffModifiers.None, paths);
385+
}
386+
387+
/// <summary>
388+
/// Show changes between the working directory and the index.
389+
/// <para>
390+
/// The level of diff performed can be specified by passing either a <see cref="TreeChanges"/>
391+
/// or <see cref="Patch"/> type as the generic parameter.
392+
/// </para>
393+
/// </summary>
394+
/// <param name="paths">The list of paths (either files or directories) that should be compared.</param>
395+
/// <param name="includeUntracked">If true, include untracked files from the working dir as additions. Otherwise ignore them.</param>
396+
/// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or
397+
/// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam>
398+
/// <returns>A <typeparamref name="T"/> containing the changes between the working directory and the index.</returns>
399+
public virtual T Compare<T>(IEnumerable<string> paths, bool includeUntracked) where T : class
400+
{
401+
return Compare<T>(includeUntracked ? DiffModifiers.IncludeUntracked : DiffModifiers.None, paths);
402+
}
403+
404+
/// <summary>
405+
/// Show changes between the working directory and the index.
406+
/// <para>
407+
/// The level of diff performed can be specified by passing either a <see cref="TreeChanges"/>
408+
/// or <see cref="Patch"/> type as the generic parameter.
409+
/// </para>
410+
/// </summary>
411+
/// <param name="paths">The list of paths (either files or directories) that should be compared.</param>
412+
/// <param name="includeUntracked">If true, include untracked files from the working dir as additions. Otherwise ignore them.</param>
413+
/// <param name="explicitPathsOptions">
414+
/// If set, the passed <paramref name="paths"/> will be treated as explicit paths.
415+
/// Use these options to determine how unmatched explicit paths should be handled.
416+
/// </param>
417+
/// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or
418+
/// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam>
419+
/// <returns>A <typeparamref name="T"/> containing the changes between the working directory and the index.</returns>
420+
public virtual T Compare<T>(IEnumerable<string> paths, bool includeUntracked,
421+
ExplicitPathsOptions explicitPathsOptions) where T : class
422+
{
423+
return Compare<T>(includeUntracked ? DiffModifiers.IncludeUntracked : DiffModifiers.None, paths, explicitPathsOptions);
424+
}
425+
222426
/// <summary>
223427
/// Show changes between the working directory and the index.
224428
/// <para>
@@ -236,8 +440,8 @@ public virtual T Compare<T>(Tree oldTree, DiffTargets diffTargets, IEnumerable<s
236440
/// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or
237441
/// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam>
238442
/// <returns>A <typeparamref name="T"/> containing the changes between the working directory and the index.</returns>
239-
public virtual T Compare<T>(IEnumerable<string> paths = null, bool includeUntracked = false, ExplicitPathsOptions explicitPathsOptions = null,
240-
CompareOptions compareOptions = null) where T : class
443+
public virtual T Compare<T>(IEnumerable<string> paths, bool includeUntracked, ExplicitPathsOptions explicitPathsOptions,
444+
CompareOptions compareOptions) where T : class
241445
{
242446
return Compare<T>(includeUntracked ? DiffModifiers.IncludeUntracked : DiffModifiers.None, paths, explicitPathsOptions, compareOptions);
243447
}

0 commit comments

Comments
 (0)