diff --git a/Protocol.md b/Protocol.md index 5ac8fc4558..3a5a1bf161 100644 --- a/Protocol.md +++ b/Protocol.md @@ -1,237 +1 @@ -# The Scalar Protocol (v1) - -The Scalar network protocol consists of four operations on three endpoints. In summary: -* `GET /scalar/objects/{objectId}` - * Provides a single object in loose-object format -* `POST /scalar/objects` - * Provides one or more objects in packfile or streaming loose object format -* `GET /scalar/prefetch[?lastPackTimestamp={secondsSinceEpoch}]` - * Provides one or more packfiles of non-blobs and optionally packfile indexes in a streaming format -* `POST /scalar/sizes` - * Provides the uncompressed, undeltified size of one or more objects -* `GET /scalar/config` - * Provides server-set client configuration options - -# `GET /scalar/objects/{objectId}` -Will return a single object in compressed loose object format, which can be directly -written to `.git/xx/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy` if desired. The request/response looks -similar to the "Dumb Protocol" as described [here](https://git-scm.com/book/en/v2/Git-Internals-Transfer-Protocols). - -# `POST /scalar/objects` -Will return multiple objects, possibly more than the client requested based on request parameters. - -The request consists of a JSON body with the following format: -``` -{ - "objectIds" : [ {JSON array of SHA-1 object IDs, as strings} ], - "commitDepth" : {positive integer} -} -``` - -For example, -``` -{ - "objectIds" : [ - "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" - ], - "commitDepth" : 1 -} -``` - -## `Accept: application/x-git-packfile` (the default) - -If -* An `Accept` header of `application/x-git-packfile` is specified, or -* No `Accept` header is specified - -then a git packfile, indexable via `index-pack`, will be returned to the client. - -If `objectIds` includes a `commit`, then all `tree`s recursively referenced by that commit are also returned. -If any other object type is requested (`tree`, `blob`, or `tag`), then only that object will be returned. - -`commitDepth` - if the requested object is a `commit`, all parents up to `n` levels deep will be returned, along -with all their trees as previously described. Does not include any `blob`s. - -## `Accept: application/x-scalar-loose-objects` - -**NOTE**: This format is currently only supposed by the cache server, not by VSTS. - -To enable scenarios where multiple objects are required, but less overhead would be incurred by using pre-existing -loose objects (e.g. on a caching proxy), an alternative, packfile-like response format that contains loose objects -is also supported. - -To receive objects in this format, the client **MUST** supply an `Accept` header of `application/x-scalar-loose-objects` -to the `POST /scalar/objects` endpoint. Otherwise, the response format will be `application/x-git-packfile`. - -This format will **NOT** perform any `commit` to `tree` expansion, and will return an error if a `commitDepth` -greater than `1` is supplied. Said another way, this `Accept`/return type has no concept of "implicitly-requested" -objects. - -### Version 1 -* Integers are signed and little-endian, unless otherwise specified -* Byte offset 0 is the first byte in the file -* Index offset 0 is the first byte in the first element of an array -* `num_objects` represents the variable number of objects in the file/response - -``` -Count Size (bytes) Chunk Description - -HEADER - +-------------------------------------------------------------------------------+ -1 | 5 | UTF-8 encoded 'Scalar ' | - | 1 | Unsigned byte version number. Currently, 1. | - +-------------------------------------------------------------------------------+ - -OBJECT CONTENT - +-------------------------------------------------------------------------------+ -num_objects | 20 | SHA-1 ID of the object. | - | 8 | Signed-long length of the object. | - | variable | Compressed, raw loose object content. | - +-------------------------------------------------------------------------------+ - -TRAILER - +-------------------------------------------------------------------------------+ -1 | 20 | Zero bytes | - +-------------------------------------------------------------------------------+ -``` - -# `GET /scalar/prefetch[?lastPackTimestamp={secondsSinceEpoch}]` - -To enable the reuse of already-existing packfiles and indexes, a custom format for transmitting these files -is supported. The `prefetch` endpoint will return one or more packfiles of **non-blob** objects. - -If the optional `lastPackTimestamp` query parameter is supplied, only packs created by the server -after the specific Unix epoch time (approximately, ±10 minutes or so) will be returned. Generally, these packs -will contain only objects introduced to the repository after that UTC-based timestamp, but will not contain -**all** objects introduced after that timestamp. - -A media-type of `application/x-scalar-timestamped-packfiles-indexes` will be returned from this endpoint. - -## Response format - -* Integers are signed and little-endian, unless otherwise specified -* Byte offset 0 is the first byte in the file -* Index offset 0 is the first byte in the first element of an array -* `num_packs` represents the variable number of packs in the file/response - -### Version 1 - -``` -Count Size (bytes) Chunk Description - -HEADER - +-------------------------------------------------------------------------------+ -1 | 5 | UTF-8 encoded 'GPRE ' | - | 1 | Unsigned byte version number. Currently, 1. | - +-------------------------------------------------------------------------------+ - -CONTENT - - +-------------------------------------------------------------------------------+ -1 | 2 | Unsigned short number of packs. `num_packs`. | - +-------------------------------------------------------------------------------+ - - +-------------------------------------------------------------------------------+ -num_packs | 8 | Signed-long pack timestamp in seconds since UTC epoch. | - | 8 | Signed-long length of the pack. | - | 8 | Signed-long length of the pack index. -1 indicates no index. | - | variable | Pack contents. | - | variable | Pack index contents. | - +-------------------------------------------------------------------------------+ -``` - -Packs **MUST** be sent in increasing `timestamp` order. In the case of a failed connection, this allows the -client to keep the packs it received successfully and "resume" by sending the highest completed timestamp. - -# `POST /scalar/sizes` -Will return the uncompressed, undeltified length of the requested objects in JSON format. - -The request consists of a JSON body with the following format: -``` -[ {JSON array of SHA-1 object IDs, as strings} ] -``` - -For example, a request of: -``` -[ - "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" -] -``` - -will result in a a response like: -``` -[ - { - "Id" : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "Size" : 123 - }, - { - "Id" : "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", - "Size" : 456 - } -] -``` - -# `GET /scalar/config` -This optional endpoint will return all server-set Scalar client configuration options. It currently -provides: - -* A set of allowed Scalar client version ranges, in order to block older clients from running in -certain scenarios. For example, a data corruption bug may be found and encouraging clients to -avoid that version is desirable. -* A list of available cache servers, each describing their url and default-ness with a friendly name -that users can use to inform which cache server to use. Note that the names "None" and "User Defined" -are reserved by Scalar. Any caches with these names may cause undefined behavior in the Scalar client. - -An example response is provided below. Note that the `null` `"Max"` value is only allowed for the last -(or greatest) range, since it logically excludes greater version numbers from having an effect. -``` -{ - "AllowedGvfsClientVersions": [{ - "Max": { - "Major": 0, - "Minor": 4, - "Build": 0, - "Revision": 0 - }, - "Min": { - "Major": 0, - "Minor": 2, - "Build": 0, - "Revision": 0 - } - }, { - "Max": { - "Major": 0, - "Minor": 5, - "Build": 0, - "Revision": 0 - }, - "Min": { - "Major": 0, - "Minor": 4, - "Build": 17009, - "Revision": 1 - } - }, { - "Max": null, - "Min": { - "Major": 0, - "Minor": 5, - "Build": 16326, - "Revision": 1 - } - }], - "CacheServers": [{ - "Url": "https://redmond-cache-machine/repo-id", - "Name": "Redmond", - "GlobalDefault": true - }, { - "Url": "https://dublin-cache-machine/repo-id", - "Name": "Dublin", - "GlobalDefault": false - }] -} -``` +See Protocol.md in microsoft/vfsforgit. \ No newline at end of file diff --git a/Scalar.Build/GenerateG4WNugetReference.cs b/Scalar.Build/GenerateG4WNugetReference.cs index 218635de70..fd2bd402a5 100644 --- a/Scalar.Build/GenerateG4WNugetReference.cs +++ b/Scalar.Build/GenerateG4WNugetReference.cs @@ -20,8 +20,8 @@ public override bool Execute() @" - - + + ", this.GitPackageVersion)); diff --git a/Scalar.Build/GenerateGitVersionConstants.cs b/Scalar.Build/GenerateGitVersionConstants.cs index 65b2ae1058..aad5e796e0 100644 --- a/Scalar.Build/GenerateGitVersionConstants.cs +++ b/Scalar.Build/GenerateGitVersionConstants.cs @@ -29,7 +29,7 @@ public override bool Execute() string installerDirectory = Path.Combine( this.PackagesPath, - "GitForWindows.Scalar.Installer." + this.GitPackageVersion, + "GitForWindows.GVFS.Installer." + this.GitPackageVersion, "tools"); if (!Directory.Exists(installerDirectory)) diff --git a/Scalar.Build/GenerateScalarInstallersNuspec.cs b/Scalar.Build/GenerateScalarInstallersNuspec.cs index 6449ed1e4a..9b8c6671da 100644 --- a/Scalar.Build/GenerateScalarInstallersNuspec.cs +++ b/Scalar.Build/GenerateScalarInstallersNuspec.cs @@ -39,8 +39,8 @@ public override bool Execute() - - + + ", this.ScalarSetupPath, diff --git a/Scalar.Build/GenerateVersionInfo.cs b/Scalar.Build/GenerateVersionInfo.cs index 86642694fa..215bed7e14 100644 --- a/Scalar.Build/GenerateVersionInfo.cs +++ b/Scalar.Build/GenerateVersionInfo.cs @@ -39,10 +39,10 @@ public override bool Execute() this.VersionHeader, string.Format( @" -#define Scalar_FILE_VERSION {0} -#define Scalar_FILE_VERSION_STRING ""{1}"" -#define Scalar_PRODUCT_VERSION {0} -#define Scalar_PRODUCT_VERSION_STRING ""{1}"" +#define GVFS_FILE_VERSION {0} +#define GVFS_FILE_VERSION_STRING ""{1}"" +#define GVFS_PRODUCT_VERSION {0} +#define GVFS_PRODUCT_VERSION_STRING ""{1}"" ", commaDelimetedVersion, this.Version)); diff --git a/Scalar.Common/Http/CacheServerInfo.cs b/Scalar.Common/Http/CacheServerInfo.cs index 05363837b9..8a38440090 100644 --- a/Scalar.Common/Http/CacheServerInfo.cs +++ b/Scalar.Common/Http/CacheServerInfo.cs @@ -5,9 +5,9 @@ namespace Scalar.Common.Http { public class CacheServerInfo { - private const string ObjectsEndpointSuffix = "/scalar/objects"; - private const string PrefetchEndpointSuffix = "/scalar/prefetch"; - private const string SizesEndpointSuffix = "/scalar/sizes"; + private const string ObjectsEndpointSuffix = "/gvfs/objects"; + private const string PrefetchEndpointSuffix = "/gvfs/prefetch"; + private const string SizesEndpointSuffix = "/gvfs/sizes"; [JsonConstructor] public CacheServerInfo(string url, string name, bool globalDefault = false) diff --git a/Scalar.Common/ScalarConstants.cs b/Scalar.Common/ScalarConstants.cs index 2ec06f5fb3..3782d54b8a 100644 --- a/Scalar.Common/ScalarConstants.cs +++ b/Scalar.Common/ScalarConstants.cs @@ -16,8 +16,8 @@ public static partial class ScalarConstants public const string ScalarEtwProviderName = "Microsoft.Git.Scalar"; public const string WorkingDirectoryRootName = "src"; - public const string UnattendedEnvironmentVariable = "Scalar_UNATTENDED"; - + public const string UnattendedEnvironmentVariable = "Scalar_UNATTENDED"; + public const string DefaultScalarCacheFolderName = ".scalarCache"; public const string GitIsNotInstalledError = "Could not find git.exe. Ensure that Git is installed."; @@ -55,18 +55,18 @@ public static class Service public static class MediaTypes { - public const string PrefetchPackFilesAndIndexesMediaType = "application/x-scalar-timestamped-packfiles-indexes"; + public const string PrefetchPackFilesAndIndexesMediaType = "application/x-gvfs-timestamped-packfiles-indexes"; public const string LooseObjectMediaType = "application/x-git-loose-object"; - public const string CustomLooseObjectsMediaType = "application/x-scalar-loose-objects"; + public const string CustomLooseObjectsMediaType = "application/x-gvfs-loose-objects"; public const string PackFileMediaType = "application/x-git-packfile"; } public static class Endpoints { - public const string ScalarConfig = "/scalar/config"; - public const string ScalarObjects = "/scalar/objects"; - public const string ScalarPrefetch = "/scalar/prefetch"; - public const string ScalarSizes = "/scalar/sizes"; + public const string ScalarConfig = "/gvfs/config"; + public const string ScalarObjects = "/gvfs/objects"; + public const string ScalarPrefetch = "/gvfs/prefetch"; + public const string ScalarSizes = "/gvfs/sizes"; public const string InfoRefs = "/info/refs?service=git-upload-pack"; } diff --git a/Scalar.FunctionalTests/Settings.cs b/Scalar.FunctionalTests/Settings.cs index c82250ed55..9ed6c970d4 100644 --- a/Scalar.FunctionalTests/Settings.cs +++ b/Scalar.FunctionalTests/Settings.cs @@ -34,7 +34,7 @@ public static void Initialize() { CurrentDirectory = Path.GetFullPath(Path.GetDirectoryName(Environment.GetCommandLineArgs()[0])); - RepoToClone = @"https://scalar.visualstudio.com/ci/_git/ForTests"; + RepoToClone = @"https://gvfs.visualstudio.com/ci/_git/ForTests"; Commitish = @"FunctionalTests/20180214"; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) diff --git a/Scalar.Installer.Mac/CreateMacInstaller.sh b/Scalar.Installer.Mac/CreateMacInstaller.sh index 5f86a18246..1d8f998b91 100755 --- a/Scalar.Installer.Mac/CreateMacInstaller.sh +++ b/Scalar.Installer.Mac/CreateMacInstaller.sh @@ -164,7 +164,7 @@ function CreateScalarDistribution() function CreateMetaDistribution() { GITVERSION="$($Scalar_SCRIPTDIR/GetGitVersionNumber.sh)" - GITINSTALLERPKGPATH="$(find $Scalar_PACKAGESDIR/gitformac.scalar.installer/$GITVERSION -type f -name *.pkg)" || exit 1 + GITINSTALLERPKGPATH="$(find $Scalar_PACKAGESDIR/gitformac.gvfs.installer/$GITVERSION -type f -name *.pkg)" || exit 1 GITPKGNAME="${GITINSTALLERPKGPATH##*/}" GITINSTALLERPKGNAME="${GITPKGNAME%.pkg}" diff --git a/Scalar.Installer.Windows/Setup.iss b/Scalar.Installer.Windows/Setup.iss index 531ba88997..abed555d9e 100644 --- a/Scalar.Installer.Windows/Setup.iss +++ b/Scalar.Installer.Windows/Setup.iss @@ -3,7 +3,7 @@ ; General documentation on how to use InnoSetup scripts: http://www.jrsoftware.org/ishelp/index.php -#define VCRuntimeDir PackagesDir + "\Scalar.VCRuntime.0.2.0-build\lib\x64" +#define VCRuntimeDir PackagesDir + "\GVFS.VCRuntime.0.2.0-build\lib\x64" #define ScalarDir BuildOutputDir + "\Scalar.Windows\bin\" + PlatformAndConfiguration #define ScalarCommonDir BuildOutputDir + "\Scalar.Common\bin\" + PlatformAndConfiguration + "\netstandard2.0" #define ServiceDir BuildOutputDir + "\Scalar.Service.Windows\bin\" + PlatformAndConfiguration diff --git a/Scalar.UnitTests/Common/SHA1UtilTests.cs b/Scalar.UnitTests/Common/SHA1UtilTests.cs index b35e35a5df..5ab82f60fa 100644 --- a/Scalar.UnitTests/Common/SHA1UtilTests.cs +++ b/Scalar.UnitTests/Common/SHA1UtilTests.cs @@ -8,7 +8,7 @@ namespace Scalar.UnitTests.Common [TestFixture] public class SHA1UtilTests { - private const string TestString = "c:\\Repos\\Scalar\\src\\.gittattributes"; + private const string TestString = "c:\\Repos\\GVFS\\src\\.gittattributes"; private const string TestResultSha1 = "ced5ad9680c1a05e9100680c2b3432de23bb7d6d"; private const string TestResultHex = "633a5c5265706f735c475646535c7372635c2e6769747461747472696275746573"; diff --git a/Scalar/CommandLine/ScalarVerb.cs b/Scalar/CommandLine/ScalarVerb.cs index ea3aa32166..cd8783a3ef 100644 --- a/Scalar/CommandLine/ScalarVerb.cs +++ b/Scalar/CommandLine/ScalarVerb.cs @@ -334,7 +334,7 @@ protected ServerScalarConfig QueryScalarConfig(ITracer tracer, ScalarEnlistment "Querying remote for config", suppressGvfsLogMessage: true)) { - this.ReportErrorAndExit(tracer, "Unable to query /scalar/config" + Environment.NewLine + errorMessage); + this.ReportErrorAndExit(tracer, "Unable to query /gvfs/config" + Environment.NewLine + errorMessage); } return serverScalarConfig; diff --git a/Scalar/packages.config b/Scalar/packages.config index f09ef60a47..3a637b3962 100644 --- a/Scalar/packages.config +++ b/Scalar/packages.config @@ -1,7 +1,7 @@  - + @@ -24,4 +24,4 @@ - + diff --git a/Scripts/Mac/BuildScalarForMac.sh b/Scripts/Mac/BuildScalarForMac.sh index 9eb83d2fdb..1c2b966f9c 100755 --- a/Scripts/Mac/BuildScalarForMac.sh +++ b/Scripts/Mac/BuildScalarForMac.sh @@ -29,7 +29,7 @@ fi echo 'Downloading a Scalar-enabled version of Git...' $Scalar_SCRIPTDIR/DownloadScalarGit.sh || exit 1 GITVERSION="$($Scalar_SCRIPTDIR/GetGitVersionNumber.sh)" -GITPATH="$(find $Scalar_PACKAGESDIR/gitformac.scalar.installer/$GITVERSION -type f -name *.dmg)" || exit 1 +GITPATH="$(find $Scalar_PACKAGESDIR/gitformac.gvfs.installer/$GITVERSION -type f -name *.dmg)" || exit 1 echo "Downloaded Git $GITVERSION" # Now that we have a path containing the version number, generate ScalarConstants.GitVersion.cs $Scalar_SCRIPTDIR/GenerateGitVersionConstants.sh "$GITPATH" $BUILDDIR || exit 1 diff --git a/Scripts/Mac/Common-Functions.ps1 b/Scripts/Mac/Common-Functions.ps1 index e036a0fb8c..2261c1ce80 100644 --- a/Scripts/Mac/Common-Functions.ps1 +++ b/Scripts/Mac/Common-Functions.ps1 @@ -108,8 +108,8 @@ function Get-GitVersionFromNuGetPackage ) # Find the git version number (looking through packages directory) - $gitInstallerPath = $NuGetPackagesDir + "/gitformac.scalar.installer/" + $GitPackageVersion + "/tools" - $toolsContents = Get-ChildItem -Path ($NuGetPackagesDir + "/gitformac.scalar.installer/" + $GitPackageVersion + "/tools") -Include *.pkg + $gitInstallerPath = $NuGetPackagesDir + "/gitformac.gvfs.installer/" + $GitPackageVersion + "/tools" + $toolsContents = Get-ChildItem -Path ($NuGetPackagesDir + "/gitformac.gvfs.installer/" + $GitPackageVersion + "/tools") -Include *.pkg $gitInstallerPkgName = $toolsContents[0].Name return $gitInstallerPkgName diff --git a/Scripts/Mac/DownloadScalarGit.sh b/Scripts/Mac/DownloadScalarGit.sh index 4436f48bd8..f077456425 100755 --- a/Scripts/Mac/DownloadScalarGit.sh +++ b/Scripts/Mac/DownloadScalarGit.sh @@ -4,4 +4,4 @@ BUILDDIR=$Scalar_OUTPUTDIR/Scalar.Build GITVERSION="$($Scalar_SCRIPTDIR/GetGitVersionNumber.sh)" cp $Scalar_SRCDIR/nuget.config $BUILDDIR dotnet new classlib -n Restore.GitInstaller -o $BUILDDIR --force -dotnet add $BUILDDIR/Restore.GitInstaller.csproj package --package-directory $Scalar_PACKAGESDIR GitForMac.Scalar.Installer --version $GITVERSION +dotnet add $BUILDDIR/Restore.GitInstaller.csproj package --package-directory $Scalar_PACKAGESDIR gitformac.gvfs.Installer --version $GITVERSION diff --git a/nuget.config b/nuget.config index 02b90010c8..91b9aaac5d 100644 --- a/nuget.config +++ b/nuget.config @@ -5,7 +5,7 @@ - +