Skip to content

Commit aec0563

Browse files
committed
Check Since param if SinceGlob is not specified
1 parent b7dc4d3 commit aec0563

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

LibGit2Sharp.Tests/CommitFixture.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public void QueryingTheCommitHistoryWithUnknownShaOrInvalidEntryPointThrows()
9898
{
9999
Assert.Throws<LibGit2SharpException>(() => repo.Commits.QueryBy(new Filter { Since = Constants.UnknownSha }).Count());
100100
Assert.Throws<LibGit2SharpException>(() => repo.Commits.QueryBy(new Filter { Since = "refs/heads/deadbeef" }).Count());
101+
Assert.Throws<ArgumentNullException>(() => repo.Commits.QueryBy(new Filter { Since = null }).Count());
101102
}
102103
}
103104

@@ -119,6 +120,8 @@ public void QueryingTheCommitHistoryWithBadParamsThrows()
119120
{
120121
using (var repo = new Repository(BareTestRepoPath))
121122
{
123+
Assert.Throws<ArgumentException>(() => repo.Commits.QueryBy(new Filter { Since = string.Empty }));
124+
Assert.Throws<ArgumentNullException>(() => repo.Commits.QueryBy(new Filter { Since = null }));
122125
Assert.Throws<ArgumentNullException>(() => repo.Commits.QueryBy(null));
123126
}
124127
}

LibGit2Sharp/CommitLog.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ public virtual ICommitLog QueryBy(Filter filter)
8787
{
8888
Ensure.ArgumentNotNull(filter, "filter");
8989

90+
if(string.IsNullOrEmpty(filter.SinceGlob))
91+
{
92+
Ensure.ArgumentNotNull(filter.Since, "filter.Since");
93+
Ensure.ArgumentNotNullOrEmptyString(filter.Since.ToString(), "filter.Since");
94+
}
95+
9096
return new CommitLog(repo, filter);
9197
}
9298

0 commit comments

Comments
 (0)