diff options
author | Brendan Forster <brendan@github.com> | 2015-05-10 14:04:10 +0300 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2015-05-15 20:31:47 +0300 |
commit | 44aa1498f8159b169af93895c60a7a68c6c1ca2b (patch) | |
tree | f87f45279d7070bbb964e231c2831ea1c4c88017 | |
parent | 32da01c5ff73d73f2865528521e39a8e740596d7 (diff) |
Drop optional parameters in Diff.cs
-rw-r--r-- | LibGit2Sharp/Diff.cs | 218 |
1 files changed, 211 insertions, 7 deletions
diff --git a/LibGit2Sharp/Diff.cs b/LibGit2Sharp/Diff.cs index 126d4bec..54ad11b0 100644 --- a/LibGit2Sharp/Diff.cs +++ b/LibGit2Sharp/Diff.cs @@ -107,9 +107,20 @@ namespace LibGit2Sharp /// </summary> /// <param name="oldBlob">The <see cref="Blob"/> you want to compare from.</param> /// <param name="newBlob">The <see cref="Blob"/> you want to compare to.</param> + /// <returns>A <see cref="ContentChanges"/> containing the changes between the <paramref name="oldBlob"/> and the <paramref name="newBlob"/>.</returns> + public virtual ContentChanges Compare(Blob oldBlob, Blob newBlob) + { + return Compare(oldBlob, newBlob, null); + } + + /// <summary> + /// Show changes between two <see cref="Blob"/>s. + /// </summary> + /// <param name="oldBlob">The <see cref="Blob"/> you want to compare from.</param> + /// <param name="newBlob">The <see cref="Blob"/> you want to compare to.</param> /// <param name="compareOptions">Additional options to define comparison behavior.</param> /// <returns>A <see cref="ContentChanges"/> containing the changes between the <paramref name="oldBlob"/> and the <paramref name="newBlob"/>.</returns> - public virtual ContentChanges Compare(Blob oldBlob, Blob newBlob, CompareOptions compareOptions = null) + public virtual ContentChanges Compare(Blob oldBlob, Blob newBlob, CompareOptions compareOptions) { using (GitDiffOptions options = BuildOptions(DiffModifiers.None, compareOptions: compareOptions)) { @@ -122,6 +133,71 @@ namespace LibGit2Sharp /// </summary> /// <param name="oldTree">The <see cref="Tree"/> you want to compare from.</param> /// <param name="newTree">The <see cref="Tree"/> you want to compare to.</param> + /// <returns>A <see cref="TreeChanges"/> containing the changes between the <paramref name="oldTree"/> and the <paramref name="newTree"/>.</returns> + public virtual T Compare<T>(Tree oldTree, Tree newTree) where T : class + { + return Compare<T>(oldTree, newTree, null, null, null); + } + + /// <summary> + /// Show changes between two <see cref="Tree"/>s. + /// </summary> + /// <param name="oldTree">The <see cref="Tree"/> you want to compare from.</param> + /// <param name="newTree">The <see cref="Tree"/> you want to compare to.</param> + /// <param name="paths">The list of paths (either files or directories) that should be compared.</param> + /// <returns>A <see cref="TreeChanges"/> containing the changes between the <paramref name="oldTree"/> and the <paramref name="newTree"/>.</returns> + public virtual T Compare<T>(Tree oldTree, Tree newTree, IEnumerable<string> paths) where T : class + { + return Compare<T>(oldTree, newTree, paths, null, null); + } + + /// <summary> + /// Show changes between two <see cref="Tree"/>s. + /// </summary> + /// <param name="oldTree">The <see cref="Tree"/> you want to compare from.</param> + /// <param name="newTree">The <see cref="Tree"/> you want to compare to.</param> + /// <param name="paths">The list of paths (either files or directories) that should be compared.</param> + /// <param name="explicitPathsOptions"> + /// If set, the passed <paramref name="paths"/> will be treated as explicit paths. + /// Use these options to determine how unmatched explicit paths should be handled. + /// </param> + /// <returns>A <see cref="TreeChanges"/> containing the changes between the <paramref name="oldTree"/> and the <paramref name="newTree"/>.</returns> + public virtual T Compare<T>(Tree oldTree, Tree newTree, IEnumerable<string> paths, + ExplicitPathsOptions explicitPathsOptions) where T : class + { + return Compare<T>(oldTree, newTree, paths, explicitPathsOptions, null); + } + + /// <summary> + /// Show changes between two <see cref="Tree"/>s. + /// </summary> + /// <param name="oldTree">The <see cref="Tree"/> you want to compare from.</param> + /// <param name="newTree">The <see cref="Tree"/> you want to compare to.</param> + /// <param name="paths">The list of paths (either files or directories) that should be compared.</param> + /// <param name="compareOptions">Additional options to define patch generation behavior.</param> + /// <returns>A <see cref="TreeChanges"/> containing the changes between the <paramref name="oldTree"/> and the <paramref name="newTree"/>.</returns> + public virtual T Compare<T>(Tree oldTree, Tree newTree, IEnumerable<string> paths, CompareOptions compareOptions) where T : class + { + return Compare<T>(oldTree, newTree, paths, null, compareOptions); + } + + /// <summary> + /// Show changes between two <see cref="Tree"/>s. + /// </summary> + /// <param name="oldTree">The <see cref="Tree"/> you want to compare from.</param> + /// <param name="newTree">The <see cref="Tree"/> you want to compare to.</param> + /// <param name="compareOptions">Additional options to define patch generation behavior.</param> + /// <returns>A <see cref="TreeChanges"/> containing the changes between the <paramref name="oldTree"/> and the <paramref name="newTree"/>.</returns> + public virtual T Compare<T>(Tree oldTree, Tree newTree, CompareOptions compareOptions) where T : class + { + return Compare<T>(oldTree, newTree, null, null, compareOptions); + } + + /// <summary> + /// Show changes between two <see cref="Tree"/>s. + /// </summary> + /// <param name="oldTree">The <see cref="Tree"/> you want to compare from.</param> + /// <param name="newTree">The <see cref="Tree"/> you want to compare to.</param> /// <param name="paths">The list of paths (either files or directories) that should be compared.</param> /// <param name="explicitPathsOptions"> /// If set, the passed <paramref name="paths"/> will be treated as explicit paths. @@ -129,8 +205,8 @@ namespace LibGit2Sharp /// </param> /// <param name="compareOptions">Additional options to define patch generation behavior.</param> /// <returns>A <see cref="TreeChanges"/> containing the changes between the <paramref name="oldTree"/> and the <paramref name="newTree"/>.</returns> - public virtual T Compare<T>(Tree oldTree, Tree newTree, IEnumerable<string> paths = null, ExplicitPathsOptions explicitPathsOptions = null, - CompareOptions compareOptions = null) where T : class + public virtual T Compare<T>(Tree oldTree, Tree newTree, IEnumerable<string> paths, ExplicitPathsOptions explicitPathsOptions, + CompareOptions compareOptions) where T : class { Func<DiffSafeHandle, object> builder; @@ -173,6 +249,64 @@ namespace LibGit2Sharp /// </summary> /// <param name="oldTree">The <see cref="Tree"/> to compare from.</param> /// <param name="diffTargets">The targets to compare to.</param> + /// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or + /// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam> + /// <returns>A <typeparamref name="T"/> containing the changes between the <see cref="Tree"/> and the selected target.</returns> + public virtual T Compare<T>(Tree oldTree, DiffTargets diffTargets) where T : class + { + return Compare<T>(oldTree, diffTargets, null, null, null); + } + + /// <summary> + /// Show changes between a <see cref="Tree"/> and the Index, the Working Directory, or both. + /// <para> + /// The level of diff performed can be specified by passing either a <see cref="TreeChanges"/> + /// or <see cref="Patch"/> type as the generic parameter. + /// </para> + /// </summary> + /// <param name="oldTree">The <see cref="Tree"/> to compare from.</param> + /// <param name="diffTargets">The targets to compare to.</param> + /// <param name="paths">The list of paths (either files or directories) that should be compared.</param> + /// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or + /// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam> + /// <returns>A <typeparamref name="T"/> containing the changes between the <see cref="Tree"/> and the selected target.</returns> + public virtual T Compare<T>(Tree oldTree, DiffTargets diffTargets, IEnumerable<string> paths) where T : class + { + return Compare<T>(oldTree, diffTargets, paths, null, null); + } + + /// <summary> + /// Show changes between a <see cref="Tree"/> and the Index, the Working Directory, or both. + /// <para> + /// The level of diff performed can be specified by passing either a <see cref="TreeChanges"/> + /// or <see cref="Patch"/> type as the generic parameter. + /// </para> + /// </summary> + /// <param name="oldTree">The <see cref="Tree"/> to compare from.</param> + /// <param name="diffTargets">The targets to compare to.</param> + /// <param name="paths">The list of paths (either files or directories) that should be compared.</param> + /// <param name="explicitPathsOptions"> + /// If set, the passed <paramref name="paths"/> will be treated as explicit paths. + /// Use these options to determine how unmatched explicit paths should be handled. + /// </param> + /// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or + /// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam> + /// <returns>A <typeparamref name="T"/> containing the changes between the <see cref="Tree"/> and the selected target.</returns> + public virtual T Compare<T>(Tree oldTree, DiffTargets diffTargets, IEnumerable<string> paths, + ExplicitPathsOptions explicitPathsOptions) where T : class + { + return Compare<T>(oldTree, diffTargets, paths, explicitPathsOptions, null); + } + + /// <summary> + /// Show changes between a <see cref="Tree"/> and the Index, the Working Directory, or both. + /// <para> + /// The level of diff performed can be specified by passing either a <see cref="TreeChanges"/> + /// or <see cref="Patch"/> type as the generic parameter. + /// </para> + /// </summary> + /// <param name="oldTree">The <see cref="Tree"/> to compare from.</param> + /// <param name="diffTargets">The targets to compare to.</param> /// <param name="paths">The list of paths (either files or directories) that should be compared.</param> /// <param name="explicitPathsOptions"> /// If set, the passed <paramref name="paths"/> will be treated as explicit paths. @@ -182,8 +316,8 @@ namespace LibGit2Sharp /// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or /// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam> /// <returns>A <typeparamref name="T"/> containing the changes between the <see cref="Tree"/> and the selected target.</returns> - public virtual T Compare<T>(Tree oldTree, DiffTargets diffTargets, IEnumerable<string> paths = null, - ExplicitPathsOptions explicitPathsOptions = null, CompareOptions compareOptions = null) where T : class + public virtual T Compare<T>(Tree oldTree, DiffTargets diffTargets, IEnumerable<string> paths, + ExplicitPathsOptions explicitPathsOptions, CompareOptions compareOptions) where T : class { Func<DiffSafeHandle, object> builder; @@ -226,6 +360,76 @@ namespace LibGit2Sharp /// or <see cref="Patch"/> type as the generic parameter. /// </para> /// </summary> + /// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or + /// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam> + /// <returns>A <typeparamref name="T"/> containing the changes between the working directory and the index.</returns> + public virtual T Compare<T>() where T : class + { + return Compare<T>(DiffModifiers.None); + } + + /// <summary> + /// Show changes between the working directory and the index. + /// <para> + /// The level of diff performed can be specified by passing either a <see cref="TreeChanges"/> + /// or <see cref="Patch"/> type as the generic parameter. + /// </para> + /// </summary> + /// <param name="paths">The list of paths (either files or directories) that should be compared.</param> + /// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or + /// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam> + /// <returns>A <typeparamref name="T"/> containing the changes between the working directory and the index.</returns> + public virtual T Compare<T>(IEnumerable<string> paths) where T : class + { + return Compare<T>(DiffModifiers.None, paths); + } + + /// <summary> + /// Show changes between the working directory and the index. + /// <para> + /// The level of diff performed can be specified by passing either a <see cref="TreeChanges"/> + /// or <see cref="Patch"/> type as the generic parameter. + /// </para> + /// </summary> + /// <param name="paths">The list of paths (either files or directories) that should be compared.</param> + /// <param name="includeUntracked">If true, include untracked files from the working dir as additions. Otherwise ignore them.</param> + /// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or + /// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam> + /// <returns>A <typeparamref name="T"/> containing the changes between the working directory and the index.</returns> + public virtual T Compare<T>(IEnumerable<string> paths, bool includeUntracked) where T : class + { + return Compare<T>(includeUntracked ? DiffModifiers.IncludeUntracked : DiffModifiers.None, paths); + } + + /// <summary> + /// Show changes between the working directory and the index. + /// <para> + /// The level of diff performed can be specified by passing either a <see cref="TreeChanges"/> + /// or <see cref="Patch"/> type as the generic parameter. + /// </para> + /// </summary> + /// <param name="paths">The list of paths (either files or directories) that should be compared.</param> + /// <param name="includeUntracked">If true, include untracked files from the working dir as additions. Otherwise ignore them.</param> + /// <param name="explicitPathsOptions"> + /// If set, the passed <paramref name="paths"/> will be treated as explicit paths. + /// Use these options to determine how unmatched explicit paths should be handled. + /// </param> + /// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or + /// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam> + /// <returns>A <typeparamref name="T"/> containing the changes between the working directory and the index.</returns> + public virtual T Compare<T>(IEnumerable<string> paths, bool includeUntracked, + ExplicitPathsOptions explicitPathsOptions) where T : class + { + return Compare<T>(includeUntracked ? DiffModifiers.IncludeUntracked : DiffModifiers.None, paths, explicitPathsOptions); + } + + /// <summary> + /// Show changes between the working directory and the index. + /// <para> + /// The level of diff performed can be specified by passing either a <see cref="TreeChanges"/> + /// or <see cref="Patch"/> type as the generic parameter. + /// </para> + /// </summary> /// <param name="paths">The list of paths (either files or directories) that should be compared.</param> /// <param name="includeUntracked">If true, include untracked files from the working dir as additions. Otherwise ignore them.</param> /// <param name="explicitPathsOptions"> @@ -236,8 +440,8 @@ namespace LibGit2Sharp /// <typeparam name="T">Can be either a <see cref="TreeChanges"/> if you are only interested in the list of files modified, added, ..., or /// a <see cref="Patch"/> if you want the actual patch content for the whole diff and for individual files.</typeparam> /// <returns>A <typeparamref name="T"/> containing the changes between the working directory and the index.</returns> - public virtual T Compare<T>(IEnumerable<string> paths = null, bool includeUntracked = false, ExplicitPathsOptions explicitPathsOptions = null, - CompareOptions compareOptions = null) where T : class + public virtual T Compare<T>(IEnumerable<string> paths, bool includeUntracked, ExplicitPathsOptions explicitPathsOptions, + CompareOptions compareOptions) where T : class { return Compare<T>(includeUntracked ? DiffModifiers.IncludeUntracked : DiffModifiers.None, paths, explicitPathsOptions, compareOptions); } |