Skip to content

Commit 016afe0

Browse files
authored
Fix: Fixed crash that would occur when two paths were entered from the command line (#15640)
1 parent f0fa595 commit 016afe0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Files.App/Utils/Git/GitHelpers.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,16 @@ private set
7878

7979
try
8080
{
81-
return
82-
Repository.IsValid(path)
83-
? path
84-
: GetGitRepositoryPath(PathNormalization.GetParentDir(path), root);
81+
if (Repository.IsValid(path))
82+
return path;
83+
else
84+
{
85+
var parentDir = PathNormalization.GetParentDir(path);
86+
if (parentDir == path)
87+
return null;
88+
else
89+
return GetGitRepositoryPath(parentDir, root);
90+
}
8591
}
8692
catch (Exception ex) when (ex is LibGit2SharpException or EncoderFallbackException)
8793
{

0 commit comments

Comments
 (0)