diff --git a/GVFS/GVFS.FunctionalTests/Tests/EnlistmentPerFixture/HealthTests.cs b/GVFS/GVFS.FunctionalTests/Tests/EnlistmentPerFixture/HealthTests.cs index 3e4d7ec84..e46999175 100644 --- a/GVFS/GVFS.FunctionalTests/Tests/EnlistmentPerFixture/HealthTests.cs +++ b/GVFS/GVFS.FunctionalTests/Tests/EnlistmentPerFixture/HealthTests.cs @@ -262,9 +262,10 @@ private void ValidateSubDirectoryHealth(List outputLines, List s private void ValidateEnlistmentStatus(string outputLine, string statusMessage) { - // Regex to extract the status message for the enlistment - // "Repository status: " - Match lineMatch = Regex.Match(outputLine, @"^Repository status:\s*(.*)$"); + // Regex to extract the status message for the enlistment. The verb prints + // "Repository status: " when the calculation covers the whole enlistment, + // and "Directory status (): " when scoped to a subdirectory. + Match lineMatch = Regex.Match(outputLine, @"^(?:Repository status|Directory status \([^)]*\)):\s*(.*)$"); string outputtedStatusMessage = lineMatch.Groups[1].Value; diff --git a/GVFS/GVFS/CommandLine/HealthVerb.cs b/GVFS/GVFS/CommandLine/HealthVerb.cs index 9f9ed2109..8bb453ac9 100644 --- a/GVFS/GVFS/CommandLine/HealthVerb.cs +++ b/GVFS/GVFS/CommandLine/HealthVerb.cs @@ -208,7 +208,23 @@ private void PrintOutput(EnlistmentHealthData enlistmentHealthData) bool healthyRepo = (enlistmentHealthData.PlaceholderPercentage + enlistmentHealthData.ModifiedPathsPercentage) < MaximumHealthyHydration; - this.Output.WriteLine("\nRepository status: " + (healthyRepo ? "OK" : "Highly Hydrated")); + // Only label the summary as "Repository status" when the calculation actually covered + // the whole enlistment. When the user scoped the check to a subdirectory (via -d or by + // running from a subdirectory of the enlistment) the number describes only that subtree, + // so label it accordingly to avoid falsely reporting the repository as highly hydrated. + bool isWholeRepo = string.IsNullOrEmpty(enlistmentHealthData.TargetDirectory) + || enlistmentHealthData.TargetDirectory == GVFSConstants.GitPathSeparatorString; + + string statusLabel = isWholeRepo + ? "Repository status" + : "Directory status (" + enlistmentHealthData.TargetDirectory.TrimEnd(GVFSConstants.GitPathSeparator) + ")"; + + this.Output.WriteLine("\n" + statusLabel + ": " + (healthyRepo ? "OK" : "Highly Hydrated")); + + if (!isWholeRepo) + { + this.Output.WriteLine("To see the full repository status, switch to the root of the repository and re-run 'gvfs health'."); + } } ///