From 18186f22e319b638cbda27a87312c6fd60ec64f1 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Wed, 28 Aug 2019 15:01:10 -0400 Subject: [PATCH 1/3] Always use read-object hook during checkout Signed-off-by: Derrick Stolee --- Scalar.Common/Git/GitProcess.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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() From 7fda079603ccdc0a5130cb452c84b2f45bb384e6 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Wed, 28 Aug 2019 15:41:23 -0400 Subject: [PATCH 2/3] CloneVerb: add more logging around checkout failures Signed-off-by: Derrick Stolee --- Scalar/CommandLine/CloneVerb.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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"); } From 85615a5c62f519b80017279c2813854e7a5e7aea Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Wed, 28 Aug 2019 15:50:59 -0400 Subject: [PATCH 3/3] CloneTests: test a sparse clone with no prefetch and a local cache Signed-off-by: Derrick Stolee --- .../Tests/EnlistmentPerFixture/CloneTests.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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)]