Skip to content

Commit

Permalink
CloneVerb: force checkout won't fail this way after mount
Browse files Browse the repository at this point in the history
Signed-off-by: Derrick Stolee <stolee@gmail.com>
  • Loading branch information
derrickstolee committed Aug 26, 2019
1 parent d6b1baa commit 8f3e639
Showing 1 changed file with 3 additions and 26 deletions.
29 changes: 3 additions & 26 deletions Scalar/CommandLine/CloneVerb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -621,32 +621,9 @@ private Result CheckoutRepo()
hydratedFileCount: out int _);
}

GitProcess.Result forceCheckoutResult = this.git.ForceCheckout(this.Branch);
if (forceCheckoutResult.ExitCodeIsFailure && forceCheckoutResult.Errors.IndexOf("unable to read tree") > 0)
{
// It is possible to have the above TryDownloadCommit() fail because we
// already have the commit and root tree we intend to check out, but
// don't have a tree further down the working directory. If we fail
// checkout here, its' because we don't have these trees and the
// read-object hook is not available yet. Force downloading the commit
// again and retry the checkout.

if (!this.TryDownloadCommit(
this.refs.GetTipCommitId(this.Branch),
this.enlistment,
this.objectRequestor,
this.gitObjects,
this.gitRepo,
out string errorMessage,
checkLocalObjectCache: false))
{
return new Result(errorMessage);
}

if (this.git.ForceCheckout(this.Branch).ExitCodeIsFailure)
{
return new Result("Failed to checkout repo");
}
if (this.git.ForceCheckout(this.Branch).ExitCodeIsFailure)
{
return new Result("Failed to checkout repo");
}

return new Result(true);
Expand Down

0 comments on commit 8f3e639

Please sign in to comment.