From 635c7ce81bbe4c782d6170aa2015d824531e537d Mon Sep 17 00:00:00 2001 From: Tyrie Vella Date: Tue, 18 Nov 2025 12:17:14 -0800 Subject: [PATCH] Exit early for full dehydrate in src directory --- GVFS/GVFS/CommandLine/DehydrateVerb.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/GVFS/GVFS/CommandLine/DehydrateVerb.cs b/GVFS/GVFS/CommandLine/DehydrateVerb.cs index f3d5224f5e..b739b9b2df 100644 --- a/GVFS/GVFS/CommandLine/DehydrateVerb.cs +++ b/GVFS/GVFS/CommandLine/DehydrateVerb.cs @@ -117,7 +117,7 @@ protected override void Execute(GVFSEnlistment enlistment) if (!this.Confirmed && fullDehydrate) { this.Output.WriteLine( -@"WARNING: THIS IS AN EXPERIMENTAL FEATURE +$@"WARNING: THIS IS AN EXPERIMENTAL FEATURE Dehydrate will back up your src folder, and then create a new, empty src folder with a fresh virtualization of the repo. All of your downloaded objects, branches, @@ -130,8 +130,7 @@ any of your uncommitted changes. in the backup folder, but it will be harder to find them because 'git status' will not work in the backup. -To actually execute the dehydrate, run 'gvfs dehydrate --confirm' from the parent -of your enlistment's src folder. +To actually execute the dehydrate, run 'gvfs dehydrate --confirm' from {enlistment.EnlistmentRoot}. "); return; @@ -155,6 +154,13 @@ from a parent of the folders list. return; } + if (fullDehydrate && Environment.CurrentDirectory.StartsWith(enlistment.WorkingDirectoryBackingRoot)) + { + /* If running from /src, the dehydrate would fail because of the handle we are holding on it. */ + this.Output.WriteLine($"Dehydrate must be run from {enlistment.EnlistmentRoot}"); + return; + } + if (this.NoStatus && !fullDehydrate) { this.ReportErrorAndExit(tracer, "Dehydrate --no-status not valid with --folders");