diff --git a/Scalar.Common/Git/GitProcess.cs b/Scalar.Common/Git/GitProcess.cs index 278b318203..52bb1a95f8 100644 --- a/Scalar.Common/Git/GitProcess.cs +++ b/Scalar.Common/Git/GitProcess.cs @@ -413,7 +413,7 @@ public Result CreateBranchWithUpstream(string branchToCreate, string upstreamBra public Result ForceCheckout(string target) { - return this.InvokeGitInWorkingDirectoryRoot("checkout -f " + target, useReadObjectHook: false); + return this.InvokeGitInWorkingDirectoryRoot("checkout -f " + target, useReadObjectHook: true); } public Result ForceCheckoutAllFiles() diff --git a/Scalar.FunctionalTests/Tests/EnlistmentPerFixture/CloneTests.cs b/Scalar.FunctionalTests/Tests/EnlistmentPerFixture/CloneTests.cs index 3c10c01aa1..c04e12ff3c 100644 --- a/Scalar.FunctionalTests/Tests/EnlistmentPerFixture/CloneTests.cs +++ b/Scalar.FunctionalTests/Tests/EnlistmentPerFixture/CloneTests.cs @@ -46,6 +46,24 @@ public void CloneWithLocalCachePathWithinSrc() result.Output.ShouldContain("'--local-cache-path' cannot be inside the src folder"); } + [TestCase] + public void SparseCloneWithNoPrefetchSucceeds() + { + ScalarFunctionalTestEnlistment enlistment = null; + + try + { + enlistment = ScalarFunctionalTestEnlistment.CloneAndMountWithPerRepoCache(ScalarTestConfig.PathToScalar, skipPrefetch: true); + + ProcessResult result = GitProcess.InvokeProcess(enlistment.RepoRoot, "status"); + result.ExitCode.ShouldEqual(0, result.Errors); + } + finally + { + enlistment?.UnmountAndDeleteAll(); + } + } + [TestCase] [Category(Categories.MacOnly)] [Category(Categories.NeedsUpdatesForNonVirtualizedMode)] diff --git a/Scalar/CommandLine/CloneVerb.cs b/Scalar/CommandLine/CloneVerb.cs index b4ccccbef1..58aed295be 100644 --- a/Scalar/CommandLine/CloneVerb.cs +++ b/Scalar/CommandLine/CloneVerb.cs @@ -624,8 +624,13 @@ private Result CheckoutRepo() } } - if (this.git.ForceCheckout(this.Branch).ExitCodeIsFailure) + GitProcess.Result result = this.git.ForceCheckout(this.Branch); + if (result.ExitCodeIsFailure) { + EventMetadata metadata = new EventMetadata(); + metadata["git-output"] = result.Output; + metadata["git-errors"] = result.Errors; + this.tracer.RelatedError(metadata, "Failed to checkout repo"); return new Result("Failed to checkout repo"); }