Skip to content

Commit

Permalink
Remove the optional parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
zentron committed Dec 2, 2021
1 parent a8b1d51 commit ee97bbf
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions LibGit2Sharp/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,30 @@ private void Dispose(bool disposing)
/// <returns>The path to the created repository.</returns>
public static string Init(string path)
{
return Init(path, false);
return Init(path, false, new InitOptions());
}

/// <summary>
/// Initialize a repository at the specified <paramref name="path"/>.
/// </summary>
/// <param name="path">The path to the working folder when initializing a standard ".git" repository. Otherwise, when initializing a bare repository, the path to the expected location of this later.</param>
/// <param name="isBare">true to initialize a bare repository. False otherwise, to initialize a standard ".git" repository.</param>
/// <returns>The path to the created repository.</returns>
public static string Init(string path, bool isBare)
{
return Init(path, isBare, new InitOptions());
}


/// <summary>
/// Initialize a repository by explictly setting the path to both the working directory and the git directory.
/// </summary>
/// <param name="workingDirectoryPath">The path to the working directory.</param>
/// <param name="gitDirectoryPath">The path to the git repository to be created.</param>
/// <returns>The path to the created repository.</returns>
public static string Init(string workingDirectoryPath, string gitDirectoryPath)
{
return Init(workingDirectoryPath, gitDirectoryPath, new InitOptions());
}

/// <summary>
Expand All @@ -492,11 +515,11 @@ public static string Init(string path)
/// <param name="isBare">true to initialize a bare repository. False otherwise, to initialize a standard ".git" repository.</param>
/// <param name="options">Additional optional parameters to be passed to the Init invocation</param>
/// <returns>The path to the created repository.</returns>
public static string Init(string path, bool isBare, InitOptions options = null)
public static string Init(string path, bool isBare, InitOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(path, "path");

using (RepositoryHandle repo = Proxy.git_repository_init_ext(null, path, isBare, options?.InitialHead))
using (RepositoryHandle repo = Proxy.git_repository_init_ext(null, path, isBare, options.InitialHead))
{
FilePath repoPath = Proxy.git_repository_path(repo);
return repoPath.Native;
Expand All @@ -510,7 +533,7 @@ public static string Init(string path, bool isBare, InitOptions options = null)
/// <param name="gitDirectoryPath">The path to the git repository to be created.</param>
/// <param name="options">Additional optional parameters to be passed to the Init invocation</param>
/// <returns>The path to the created repository.</returns>
public static string Init(string workingDirectoryPath, string gitDirectoryPath, InitOptions options = null)
public static string Init(string workingDirectoryPath, string gitDirectoryPath, InitOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(workingDirectoryPath, "workingDirectoryPath");
Ensure.ArgumentNotNullOrEmptyString(gitDirectoryPath, "gitDirectoryPath");
Expand All @@ -522,7 +545,7 @@ public static string Init(string workingDirectoryPath, string gitDirectoryPath,

// TODO: Shouldn't we ensure that the working folder isn't under the gitDir?

using (RepositoryHandle repo = Proxy.git_repository_init_ext(wd, gitDirectoryPath, false, options?.InitialHead))
using (RepositoryHandle repo = Proxy.git_repository_init_ext(wd, gitDirectoryPath, false, options.InitialHead))
{
FilePath repoPath = Proxy.git_repository_path(repo);
return repoPath.Native;
Expand Down

0 comments on commit ee97bbf

Please sign in to comment.