Skip to content

Commit ee97bbf

Browse files
committed
Remove the optional parameters
1 parent a8b1d51 commit ee97bbf

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

LibGit2Sharp/Repository.cs

+28-5
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,30 @@ private void Dispose(bool disposing)
482482
/// <returns>The path to the created repository.</returns>
483483
public static string Init(string path)
484484
{
485-
return Init(path, false);
485+
return Init(path, false, new InitOptions());
486+
}
487+
488+
/// <summary>
489+
/// Initialize a repository at the specified <paramref name="path"/>.
490+
/// </summary>
491+
/// <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>
492+
/// <param name="isBare">true to initialize a bare repository. False otherwise, to initialize a standard ".git" repository.</param>
493+
/// <returns>The path to the created repository.</returns>
494+
public static string Init(string path, bool isBare)
495+
{
496+
return Init(path, isBare, new InitOptions());
497+
}
498+
499+
500+
/// <summary>
501+
/// Initialize a repository by explictly setting the path to both the working directory and the git directory.
502+
/// </summary>
503+
/// <param name="workingDirectoryPath">The path to the working directory.</param>
504+
/// <param name="gitDirectoryPath">The path to the git repository to be created.</param>
505+
/// <returns>The path to the created repository.</returns>
506+
public static string Init(string workingDirectoryPath, string gitDirectoryPath)
507+
{
508+
return Init(workingDirectoryPath, gitDirectoryPath, new InitOptions());
486509
}
487510

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

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

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

525-
using (RepositoryHandle repo = Proxy.git_repository_init_ext(wd, gitDirectoryPath, false, options?.InitialHead))
548+
using (RepositoryHandle repo = Proxy.git_repository_init_ext(wd, gitDirectoryPath, false, options.InitialHead))
526549
{
527550
FilePath repoPath = Proxy.git_repository_path(repo);
528551
return repoPath.Native;

0 commit comments

Comments
 (0)