Skip to content

Commit a8b0b08

Browse files
Merge pull request #122: Use GVFS Helper transport instead of read object hook
See microsoft/git#191 for the Git code regarding the GVFS transport layer. This can work in tandem with the read-object hook, but it _should_ make the read-object hook irrelevant. * Delete all references to the read-object hook in the product code. This unblocks #4 and the [Mount Removal] tasks #15, #132, #133, #135, #136, and possible others. * Delete the Sparse Verb in favor of `git sparse-checkout set`. * Delete the `BlobPrefetcher` and all references to `--files` or `--folders` prefetching. Resolves #6, #7, #36.
2 parents 0305df7 + 89e66d1 commit a8b0b08

62 files changed

Lines changed: 377 additions & 4943 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Readme.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,6 @@ Note that Scalar on Mac is under active development.
152152
git clone https://github.com/microsoft/scalar.git src
153153
```
154154

155-
* Using XCode, open `Scalar/ReadObjectHook/Scalar.ReadObjectHook.Mac.xcodeproj`.
156-
157-
* Select the `Scalar.ReadObjectHook.Mac` project.
158-
* Under "Signing", select your developer certificate, which may be an organization
159-
certificate.
160-
161155
* Run the build and installation scripts:
162156

163157
```

Scalar.Build/Scalar.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<PropertyGroup Label="Parameters">
55
<ScalarVersion>0.2.173.2</ScalarVersion>
6-
<GitPackageVersion>2.20191002.1-sc</GitPackageVersion>
6+
<GitPackageVersion>2.20191003.3-sc</GitPackageVersion>
77
</PropertyGroup>
88

99
<PropertyGroup Label="DefaultSettings">

Scalar.Common/FileSystem/HooksInstaller.cs

Lines changed: 0 additions & 199 deletions
This file was deleted.

Scalar.Common/Git/GitConfigSetting.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ namespace Scalar.Common.Git
44
{
55
public class GitConfigSetting
66
{
7-
public const string CoreVirtualizeObjectsName = "core.virtualizeobjects";
87
public const string CredentialUseHttpPath = "credential.\"https://dev.azure.com\".useHttpPath";
98

109
public const string HttpSslCert = "http.sslcert";

Scalar.Common/Git/GitProcess.cs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static Result Init(Enlistment enlistment)
9090

9191
public static Result SparseCheckoutInit(Enlistment enlistment)
9292
{
93-
return new GitProcess(enlistment).InvokeGitInWorkingDirectoryRoot("sparse-checkout init --cone", useReadObjectHook: false);
93+
return new GitProcess(enlistment).InvokeGitInWorkingDirectoryRoot("sparse-checkout init --cone", fetchMissingObjects: false);
9494
}
9595

9696
public static ConfigResult GetFromGlobalConfig(string gitBinPath, string settingName)
@@ -413,19 +413,19 @@ public Result CreateBranchWithUpstream(string branchToCreate, string upstreamBra
413413

414414
public Result ForceCheckout(string target)
415415
{
416-
return this.InvokeGitInWorkingDirectoryRoot("checkout -f " + target, useReadObjectHook: true);
416+
return this.InvokeGitInWorkingDirectoryRoot("checkout -f " + target, fetchMissingObjects: true);
417417
}
418418

419419
public Result ForceCheckoutAllFiles()
420420
{
421-
return this.InvokeGitInWorkingDirectoryRoot("checkout HEAD -- .", useReadObjectHook: true);
421+
return this.InvokeGitInWorkingDirectoryRoot("checkout HEAD -- .", fetchMissingObjects: true);
422422
}
423423

424424
public Result SparseCheckoutSet(List<string> foldersToSet)
425425
{
426426
return this.InvokeGitInWorkingDirectoryRoot(
427427
$"sparse-checkout set --stdin",
428-
useReadObjectHook: true,
428+
fetchMissingObjects: true,
429429
writeStdIn: writer =>
430430
{
431431
foreach (string path in foldersToSet)
@@ -449,7 +449,7 @@ public Result Status(bool allowObjectDownloads, bool useStatusCache, bool showUn
449449
command += " -uall";
450450
}
451451

452-
return this.InvokeGitInWorkingDirectoryRoot(command, useReadObjectHook: allowObjectDownloads);
452+
return this.InvokeGitInWorkingDirectoryRoot(command, fetchMissingObjects: allowObjectDownloads);
453453
}
454454

455455
public Result UnpackObjects(Stream packFileStream)
@@ -490,7 +490,7 @@ public Result WriteCommitGraph(string objectDir, List<string> packs)
490490
string command = "commit-graph write --stdin-packs --split --size-multiple=4 --object-dir \"" + objectDir + "\"";
491491
return this.InvokeGitInWorkingDirectoryRoot(
492492
command,
493-
useReadObjectHook: true,
493+
fetchMissingObjects: true,
494494
writeStdIn: writer =>
495495
{
496496
foreach (string packIndex in packs)
@@ -506,7 +506,7 @@ public Result WriteCommitGraph(string objectDir, List<string> packs)
506506
public Result VerifyCommitGraph(string objectDir)
507507
{
508508
string command = "commit-graph verify --shallow --object-dir \"" + objectDir + "\"";
509-
return this.InvokeGitInWorkingDirectoryRoot(command, useReadObjectHook: true);
509+
return this.InvokeGitInWorkingDirectoryRoot(command, fetchMissingObjects: true);
510510
}
511511

512512
public Result IndexPack(string packfilePath, string idxOutputPath)
@@ -547,7 +547,7 @@ public Result LsFiles(Action<string> parseStdOutLine)
547547
{
548548
return this.InvokeGitInWorkingDirectoryRoot(
549549
"ls-files -v",
550-
useReadObjectHook: false,
550+
fetchMissingObjects: false,
551551
parseStdOutLine: parseStdOutLine);
552552
}
553553

@@ -588,7 +588,7 @@ public Result MultiPackIndexRepack(string gitObjectDirectory, string batchSize)
588588
return this.InvokeGitAgainstDotGitFolder($"-c pack.threads=1 multi-pack-index repack --object-dir=\"{gitObjectDirectory}\" --batch-size={batchSize}");
589589
}
590590

591-
public Process GetGitProcess(string command, string workingDirectory, string dotGitDirectory, bool useReadObjectHook, bool redirectStandardError, string gitObjectsDirectory)
591+
public Process GetGitProcess(string command, string workingDirectory, string dotGitDirectory, bool fetchMissingObjects, bool redirectStandardError, string gitObjectsDirectory)
592592
{
593593
ProcessStartInfo processInfo = new ProcessStartInfo(this.gitBinPath);
594594
processInfo.WorkingDirectory = workingDirectory;
@@ -632,9 +632,9 @@ public Process GetGitProcess(string command, string workingDirectory, string dot
632632
processInfo.EnvironmentVariables["GIT_OBJECT_DIRECTORY"] = gitObjectsDirectory;
633633
}
634634

635-
if (!useReadObjectHook)
635+
if (!fetchMissingObjects)
636636
{
637-
command = "-c " + GitConfigSetting.CoreVirtualizeObjectsName + "=false " + command;
637+
command = $"-c {ScalarConstants.GitConfig.UseGvfsHelper}=false {command}";
638638
}
639639

640640
if (!string.IsNullOrEmpty(dotGitDirectory))
@@ -654,7 +654,7 @@ protected virtual Result InvokeGitImpl(
654654
string command,
655655
string workingDirectory,
656656
string dotGitDirectory,
657-
bool useReadObjectHook,
657+
bool fetchMissingObjects,
658658
Action<StreamWriter> writeStdIn,
659659
Action<string> parseStdOutLine,
660660
int timeoutMs,
@@ -670,7 +670,13 @@ protected virtual Result InvokeGitImpl(
670670
// From https://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx
671671
// To avoid deadlocks, use asynchronous read operations on at least one of the streams.
672672
// Do not perform a synchronous read to the end of both redirected streams.
673-
using (this.executingProcess = this.GetGitProcess(command, workingDirectory, dotGitDirectory, useReadObjectHook, redirectStandardError: true, gitObjectsDirectory: gitObjectsDirectory))
673+
using (this.executingProcess = this.GetGitProcess(
674+
command,
675+
workingDirectory,
676+
dotGitDirectory,
677+
fetchMissingObjects: fetchMissingObjects,
678+
redirectStandardError: true,
679+
gitObjectsDirectory: gitObjectsDirectory))
674680
{
675681
StringBuilder output = new StringBuilder();
676682
StringBuilder errors = new StringBuilder();
@@ -793,7 +799,7 @@ private Result InvokeGitOutsideEnlistment(
793799
command,
794800
workingDirectory: Environment.SystemDirectory,
795801
dotGitDirectory: null,
796-
useReadObjectHook: false,
802+
fetchMissingObjects: false,
797803
writeStdIn: writeStdIn,
798804
parseStdOutLine: parseStdOutLine,
799805
timeoutMs: timeout);
@@ -804,15 +810,15 @@ private Result InvokeGitOutsideEnlistment(
804810
/// </summary>
805811
private Result InvokeGitInWorkingDirectoryRoot(
806812
string command,
807-
bool useReadObjectHook,
813+
bool fetchMissingObjects,
808814
Action<StreamWriter> writeStdIn = null,
809815
Action<string> parseStdOutLine = null)
810816
{
811817
return this.InvokeGitImpl(
812818
command,
813819
workingDirectory: this.workingDirectoryRoot,
814820
dotGitDirectory: null,
815-
useReadObjectHook: useReadObjectHook,
821+
fetchMissingObjects: fetchMissingObjects,
816822
writeStdIn: writeStdIn,
817823
parseStdOutLine: parseStdOutLine,
818824
timeoutMs: -1);
@@ -840,7 +846,7 @@ private Result InvokeGitAgainstDotGitFolder(
840846
command,
841847
workingDirectory: Environment.SystemDirectory,
842848
dotGitDirectory: this.dotGitRoot,
843-
useReadObjectHook: false,
849+
fetchMissingObjects: false,
844850
writeStdIn: writeStdIn,
845851
parseStdOutLine: parseStdOutLine,
846852
timeoutMs: -1,

0 commit comments

Comments
 (0)