From 3cb5290388fca055f796e8f3eee60244e3e6793f Mon Sep 17 00:00:00 2001 From: Tyrie Vella Date: Thu, 11 Dec 2025 12:54:18 -0800 Subject: [PATCH] Fix GetHeadTreeId to only read head commit The previous implementation of GetHeadTreeId called "git show -s". "-s" suppresses the diff from the output, but it turns out git still performs the diff operation internally. The inefficiency isn't necessarily an issue, but we are running git.exe with the virtualization hook off so if the objects required for the diff are not already downloaded the command will fail. The new implementation produces the same output, but doesn't try to do a diff at all. --- GVFS/GVFS.Common/Git/GitProcess.cs | 2 +- GVFS/GVFS.UnitTests/Common/EnlistmentHydrationSummaryTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/GVFS/GVFS.Common/Git/GitProcess.cs b/GVFS/GVFS.Common/Git/GitProcess.cs index 616d0ec22..a86b6131a 100644 --- a/GVFS/GVFS.Common/Git/GitProcess.cs +++ b/GVFS/GVFS.Common/Git/GitProcess.cs @@ -684,7 +684,7 @@ public Result MultiPackIndexRepack(string gitObjectDirectory, string batchSize) public Result GetHeadTreeId() { - return this.InvokeGitAgainstDotGitFolder("show -s --format=%T HEAD", usePreCommandHook: false); + return this.InvokeGitAgainstDotGitFolder("rev-parse \"HEAD^{tree}\"", usePreCommandHook: false); } public Process GetGitProcess(string command, string workingDirectory, string dotGitDirectory, bool useReadObjectHook, bool redirectStandardError, string gitObjectsDirectory, bool usePreCommandHook) diff --git a/GVFS/GVFS.UnitTests/Common/EnlistmentHydrationSummaryTests.cs b/GVFS/GVFS.UnitTests/Common/EnlistmentHydrationSummaryTests.cs index 53591de8a..2623dc4bd 100644 --- a/GVFS/GVFS.UnitTests/Common/EnlistmentHydrationSummaryTests.cs +++ b/GVFS/GVFS.UnitTests/Common/EnlistmentHydrationSummaryTests.cs @@ -100,7 +100,7 @@ public void HeadTreeCountCacheTests((string CachePrecontents, string ExpectedCac this.enlistmentDirectory.CreateFile(totalPathCountPath, args.CachePrecontents, createDirectories: true); } - this.gitProcess.SetExpectedCommandResult("show -s --format=%T HEAD", + this.gitProcess.SetExpectedCommandResult("rev-parse \"HEAD^{tree}\"", () => new GitProcess.Result(HeadTreeId, "", 0)); this.gitProcess.SetExpectedCommandResult("ls-tree -r -d HEAD", () => new GitProcess.Result(