Skip to content
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
13 changes: 13 additions & 0 deletions GVFS/GVFS.Common/Enlistment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,18 @@ public virtual GitProcess CreateGitProcess()
{
return new GitProcess(this);
}

public bool GetTrustPackIndexesConfig()
{
var gitProcess = this.CreateGitProcess();
bool trustPackIndexes = true;
if (gitProcess.TryGetFromConfig(GVFSConstants.GitConfig.TrustPackIndexes, forceOutsideEnlistment: false, out var valueString)
&& bool.TryParse(valueString, out var trustPackIndexesConfig))
{
trustPackIndexes = trustPackIndexesConfig;
}

return trustPackIndexes;
}
}
}
7 changes: 1 addition & 6 deletions GVFS/GVFS.Common/Git/GitObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,7 @@ public virtual bool TryDownloadPrefetchPacks(GitProcess gitProcess, long latestT
* pack file and an index file that do not match.
* Eventually we will make this the default, but it has a high performance cost for the first prefetch after
* cloning a large repository, so it must be explicitly enabled for now. */
bool trustPackIndexes = true;
if (gitProcess.TryGetFromConfig(GVFSConstants.GitConfig.TrustPackIndexes, forceOutsideEnlistment: false, out var valueString)
&& bool.TryParse(valueString, out var trustPackIndexesConfig))
{
trustPackIndexes = trustPackIndexesConfig;
}
bool trustPackIndexes = this.Enlistment.GetTrustPackIndexesConfig();
metadata.Add("trustPackIndexes", trustPackIndexes);

long requestId = HttpRequestor.GetNewRequestId();
Expand Down
44 changes: 32 additions & 12 deletions GVFS/GVFS/CommandLine/CloneVerb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,20 +215,40 @@ public override void Execute()
{
if (!this.NoPrefetch)
{
ReturnCode result = this.Execute<PrefetchVerb>(
enlistment,
verb =>
bool trustPackIndexes = enlistment.GetTrustPackIndexesConfig();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that this is already being loaded in the prefetch command, so we don't pass this as an option to the prefetch command as a CLI argument. That took me a tiny bit to figure out, so I thought it worth mentioning.

/* If pack indexes are not trusted, the prefetch can take a long time.
* We will run the prefetch command in the background.
*/
if (trustPackIndexes)
{
ReturnCode result = this.Execute<PrefetchVerb>(
enlistment,
verb =>
{
verb.Commits = true;
verb.SkipVersionCheck = true;
verb.ResolvedCacheServer = cacheServer;
verb.ServerGVFSConfig = serverGVFSConfig;
});

if (result != ReturnCode.Success)
{
verb.Commits = true;
verb.SkipVersionCheck = true;
verb.ResolvedCacheServer = cacheServer;
verb.ServerGVFSConfig = serverGVFSConfig;
});
this.Output.WriteLine("\r\nError during prefetch @ {0}", fullEnlistmentRootPathParameter);
exitCode = (int)result;
}
}

if (result != ReturnCode.Success)
else
{
this.Output.WriteLine("\r\nError during prefetch @ {0}", fullEnlistmentRootPathParameter);
exitCode = (int)result;
Process.Start(new ProcessStartInfo(
fileName: "gvfs",
arguments: "prefetch --commits")
{
UseShellExecute = true,
WindowStyle = ProcessWindowStyle.Hidden,
WorkingDirectory = enlistment.EnlistmentRoot
});
this.Output.WriteLine("\r\nPrefetch of commit graph has been started as a background process. Git operations involving history may be slower until prefetch has completed.\r\n");
}
}

Expand All @@ -247,7 +267,7 @@ public override void Execute()
verb.SkipVersionCheck = true;
verb.ResolvedCacheServer = cacheServer;
verb.DownloadedGVFSConfig = serverGVFSConfig;
});
});
}
}
else
Expand Down
Loading