Skip to content

Commit eb6cd02

Browse files
committed
diagnose: avoid poluting stderr stream in Git diagnostic
Avoid poluting the standard error stream with a 'fatal' Git error message during the Git diagnostic run as part of the `diagnose` command. When checking if we are inside of a Git repo we should be using an explicit check for `IGit::IsInsideRepository` rather than trying to get the current repo path and checking for null.
1 parent 47d2e56 commit eb6cd02

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/shared/Core/Diagnostics/GitDiagnostic.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,16 @@ protected override Task<bool> RunInternalAsync(StringBuilder log, IList<string>
1919
log.AppendLine($"Git version is '{gitVersion.OriginalString}'");
2020

2121
log.Append("Locating current repository...");
22-
string thisRepo =CommandContext.Git.GetCurrentRepository();
22+
if (!CommandContext.Git.IsInsideRepository())
23+
{
24+
log.AppendLine("Not inside a Git repository.");
25+
}
26+
else
27+
{
28+
string thisRepo = CommandContext.Git.GetCurrentRepository();
29+
log.AppendLine($"Git repository at '{thisRepo}'");
30+
}
2331
log.AppendLine(" OK");
24-
log.AppendLine(thisRepo is null ? "Not inside a Git repository." : $"Git repository at '{thisRepo}'");
2532

2633
log.Append("Listing all Git configuration...");
2734
ChildProcess configProc = CommandContext.Git.CreateProcess("config --list --show-origin");

0 commit comments

Comments
 (0)