Skip to content

Commit 7b12406

Browse files
committed
fix commit range validation
1 parent bfbd0d7 commit 7b12406

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

GitContentSearch/GitContentSearcher.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,16 @@ public void SearchContent(string filePath, string searchString, string earliestC
6565

6666
_progress?.Report(0.25); // Commits retrieved
6767

68-
if (commits.FindIndex(c => c.CommitHash == earliestCommit) > commits.FindIndex(c => c.CommitHash == latestCommit))
68+
if (!string.IsNullOrEmpty(earliestCommit) && !string.IsNullOrEmpty(latestCommit))
6969
{
70-
_logWriter.WriteLine("Error: The earliest commit is more recent than the latest commit.");
71-
_progress?.Report(1.0);
72-
return;
70+
var earliestIndex = commits.FindIndex(c => c.CommitHash == earliestCommit);
71+
var latestIndex = commits.FindIndex(c => c.CommitHash == latestCommit);
72+
if (earliestIndex > latestIndex)
73+
{
74+
_logWriter.WriteLine("Error: The earliest commit is more recent than the latest commit.");
75+
_progress?.Report(1.0);
76+
return;
77+
}
7378
}
7479

7580
// Calculate total possible commits to search

0 commit comments

Comments
 (0)