Skip to content

Commit

Permalink
Merge pull request microsoft#27 Remove GVFSLock.Shared.cs and AllowAl…
Browse files Browse the repository at this point in the history
…lLocksNamedPipeServer

Remove GVFSLock.Shared.cs and AllowAllLocksNamedPipeServer
  • Loading branch information
wilbaker authored Aug 8, 2019
2 parents 5b6a1cf + 72d71a9 commit 3f0732c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 295 deletions.
177 changes: 0 additions & 177 deletions GVFS/GVFS.Common/GVFSLock.Shared.cs

This file was deleted.

48 changes: 0 additions & 48 deletions GVFS/GVFS.Common/NamedPipes/AllowAllLocksNamedPipeServer.cs

This file was deleted.

103 changes: 40 additions & 63 deletions GVFS/GVFS/CommandLine/CloneVerb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,85 +322,62 @@ private Result TryClone(
ServerGVFSConfig serverGVFSConfig,
string resolvedLocalCacheRoot)
{
Result pipeResult;
using (NamedPipeServer pipeServer = this.StartNamedPipe(tracer, enlistment, out pipeResult))
using (GitObjectsHttpRequestor objectRequestor = new GitObjectsHttpRequestor(tracer, enlistment, cacheServer, retryConfig))
{
if (!pipeResult.Success)
GitRefs refs = objectRequestor.QueryInfoRefs(this.SingleBranch ? this.Branch : null);

if (refs == null)
{
return pipeResult;
return new Result("Could not query info/refs from: " + Uri.EscapeUriString(enlistment.RepoUrl));
}

using (GitObjectsHttpRequestor objectRequestor = new GitObjectsHttpRequestor(tracer, enlistment, cacheServer, retryConfig))
if (this.Branch == null)
{
GitRefs refs = objectRequestor.QueryInfoRefs(this.SingleBranch ? this.Branch : null);
this.Branch = refs.GetDefaultBranch();

if (refs == null)
{
return new Result("Could not query info/refs from: " + Uri.EscapeUriString(enlistment.RepoUrl));
}

if (this.Branch == null)
EventMetadata metadata = new EventMetadata();
metadata.Add("Branch", this.Branch);
tracer.RelatedEvent(EventLevel.Informational, "CloneDefaultRemoteBranch", metadata);
}
else
{
if (!refs.HasBranch(this.Branch))
{
this.Branch = refs.GetDefaultBranch();

EventMetadata metadata = new EventMetadata();
metadata.Add("Branch", this.Branch);
tracer.RelatedEvent(EventLevel.Informational, "CloneDefaultRemoteBranch", metadata);
}
else
{
if (!refs.HasBranch(this.Branch))
{
EventMetadata metadata = new EventMetadata();
metadata.Add("Branch", this.Branch);
tracer.RelatedEvent(EventLevel.Warning, "CloneBranchDoesNotExist", metadata);

string errorMessage = string.Format("Remote branch {0} not found in upstream origin", this.Branch);
return new Result(errorMessage);
}
}

if (!enlistment.TryCreateEnlistmentFolders())
{
string error = "Could not create enlistment directory";
tracer.RelatedError(error);
return new Result(error);
}
tracer.RelatedEvent(EventLevel.Warning, "CloneBranchDoesNotExist", metadata);

if (!GVFSPlatform.Instance.FileSystem.IsFileSystemSupported(enlistment.EnlistmentRoot, out string fsError))
{
string error = $"FileSystem unsupported: {fsError}";
tracer.RelatedError(error);
return new Result(error);
string errorMessage = string.Format("Remote branch {0} not found in upstream origin", this.Branch);
return new Result(errorMessage);
}
}

string localCacheError;
if (!this.TryDetermineLocalCacheAndInitializePaths(tracer, enlistment, serverGVFSConfig, cacheServer, resolvedLocalCacheRoot, out localCacheError))
{
tracer.RelatedError(localCacheError);
return new Result(localCacheError);
}
if (!enlistment.TryCreateEnlistmentFolders())
{
string error = "Could not create enlistment directory";
tracer.RelatedError(error);
return new Result(error);
}

Directory.CreateDirectory(enlistment.GitObjectsRoot);
Directory.CreateDirectory(enlistment.GitPackRoot);
Directory.CreateDirectory(enlistment.BlobSizesRoot);
if (!GVFSPlatform.Instance.FileSystem.IsFileSystemSupported(enlistment.EnlistmentRoot, out string fsError))
{
string error = $"FileSystem unsupported: {fsError}";
tracer.RelatedError(error);
return new Result(error);
}

return this.CreateClone(tracer, enlistment, objectRequestor, refs, this.Branch);
string localCacheError;
if (!this.TryDetermineLocalCacheAndInitializePaths(tracer, enlistment, serverGVFSConfig, cacheServer, resolvedLocalCacheRoot, out localCacheError))
{
tracer.RelatedError(localCacheError);
return new Result(localCacheError);
}
}
}

private NamedPipeServer StartNamedPipe(ITracer tracer, GVFSEnlistment enlistment, out Result errorResult)
{
try
{
errorResult = new Result(true);
return AllowAllLocksNamedPipeServer.Create(tracer, enlistment);
}
catch (PipeNameLengthException)
{
errorResult = new Result("Failed to clone. Path exceeds the maximum number of allowed characters");
return null;
Directory.CreateDirectory(enlistment.GitObjectsRoot);
Directory.CreateDirectory(enlistment.GitPackRoot);
Directory.CreateDirectory(enlistment.BlobSizesRoot);

return this.CreateClone(tracer, enlistment, objectRequestor, refs, this.Branch);
}
}

Expand Down
11 changes: 4 additions & 7 deletions GVFS/GVFS/CommandLine/DehydrateVerb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,14 +401,11 @@ private bool TryRecreateIndex(ITracer tracer, GVFSEnlistment enlistment)
() =>
{
// Create a new index based on the new minimal modified paths
using (NamedPipeServer pipeServer = AllowAllLocksNamedPipeServer.Create(tracer, enlistment))
{
GitProcess git = new GitProcess(enlistment);
GitProcess.Result checkoutResult = git.ForceCheckout("HEAD");
GitProcess git = new GitProcess(enlistment);
GitProcess.Result checkoutResult = git.ForceCheckout("HEAD");
errorMessage = checkoutResult.Errors;
return checkoutResult.ExitCodeIsSuccess;
}
errorMessage = checkoutResult.Errors;
return checkoutResult.ExitCodeIsSuccess;
},
"Recreating git index",
suppressGvfsLogMessage: true))
Expand Down

0 comments on commit 3f0732c

Please sign in to comment.