Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always use read-object hook during checkout #92

Merged
merged 3 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Scalar.Common/Git/GitProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
18 changes: 18 additions & 0 deletions Scalar.FunctionalTests/Tests/EnlistmentPerFixture/CloneTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
7 changes: 6 additions & 1 deletion Scalar/CommandLine/CloneVerb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down