Skip to content

Commit 81def25

Browse files
author
Ruben Verdoes
committed
Ensure workdirPath is not null in Repo.Clone
1 parent f545299 commit 81def25

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

LibGit2Sharp.Tests/CloneFixture.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,5 +227,12 @@ public void CloningAnUrlWithoutPathThrows()
227227

228228
Assert.Throws<InvalidSpecificationException>(() => Repository.Clone("http://github.com", scd.DirectoryPath));
229229
}
230+
231+
[Theory]
232+
[InlineData("git://github.com/libgit2/TestGitRepository")]
233+
public void CloningWithoutWorkdirPathThrows(string url)
234+
{
235+
Assert.Throws<ArgumentNullException>(() => Repository.Clone(url, null));
236+
}
230237
}
231238
}

LibGit2Sharp/Repository.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,8 @@ public static string Discover(string startingPath)
538538
public static string Clone(string sourceUrl, string workdirPath,
539539
CloneOptions options = null)
540540
{
541+
Ensure.ArgumentNotNull(workdirPath, "workdirPath");
542+
541543
options = options ?? new CloneOptions();
542544

543545
using (GitCheckoutOptsWrapper checkoutOptionsWrapper = new GitCheckoutOptsWrapper(options))

0 commit comments

Comments
 (0)