Skip to content
Draft
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
3 changes: 3 additions & 0 deletions GVFS/GVFS.Common/Git/GitConfigSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ public class GitConfigSetting
{
public const string CoreVirtualizeObjectsName = "core.virtualizeobjects";
public const string CoreVirtualFileSystemName = "core.virtualfilesystem";
public const string CoreIgnoreCaseName = "core.ignorecase";
public const string CoreSparseCheckoutName = "core.sparsecheckout";
public const string IndexSparseName = "index.sparse";
public const string CredentialUseHttpPath = "credential.\"https://dev.azure.com\".useHttpPath";

public const string HttpSslCert = "http.sslcert";
Expand Down
93 changes: 93 additions & 0 deletions GVFS/GVFS.Common/Git/GitProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,99 @@ public Result Reset(string target, string paths)
return this.InvokeGitInWorkingDirectoryRoot($"reset {target} {paths}", useReadObjectHook: false);
}

/// <summary>
/// Make the sparse-directory entries of the index match the cone file with
/// <c>git sparse-checkout reapply</c>. Git expands each sparse-directory entry that the
/// cone now includes, and collapses each directory that the cone no longer includes.
/// </summary>
/// <remarks>
/// For a mounted enlistment:
/// <list type="bullet">
/// <item>The virtual file system stays on. Git then keeps the skip-worktree bits that
/// the mount reports, and it does not write working-tree files.</item>
/// <item>The hooks path stays as it is, because Git asks the virtual file system hook
/// which paths are present.</item>
/// <item>The read-object hook stays on, because Git can read tree objects that are not
/// local yet when it expands a directory.</item>
/// <item><c>COMMAND_HOOK_LOCK</c> makes Git skip the pre-command and post-command hooks,
/// so this process does not ask for the GVFS lock or for a cone change.</item>
/// <item><c>index.deleteSparseDirectories=false</c> stops Git from deleting the
/// working-tree directories that leave the cone.</item>
/// </list>
/// Git does not do the same with <c>update-index --force-write-index</c>: it does not
/// expand a sparse-directory entry that the cone now includes.
/// </remarks>
public Result ReapplySparseCheckout()
{
return this.InvokeGitImpl(
"-c index.deleteSparseDirectories=false sparse-checkout reapply",
workingDirectory: this.workingDirectoryRoot,
dotGitDirectory: null,
useReadObjectHook: true,
writeStdIn: null,
parseStdOutLine: null,
timeoutMs: -1,
usePreCommandHook: false);
}

/// <summary>
/// List the sparse-directory entries of the index with <c>git ls-files --sparse</c>.
/// </summary>
/// <remarks>
/// <c>ls-files --sparse</c> reads a sparse index without expanding it. The virtual file
/// system stays on, so Git keeps the skip-worktree bits that the mount reports.
/// <c>COMMAND_HOOK_LOCK</c> makes Git skip the pre-command and post-command hooks.
/// </remarks>
public Result ListSparseDirectories(Action<string> onSparseDirectory)
{
ArgumentNullException.ThrowIfNull(onSparseDirectory);

return this.InvokeGitImpl(
"ls-files --sparse -z",
workingDirectory: this.workingDirectoryRoot,
dotGitDirectory: null,
useReadObjectHook: false,
writeStdIn: null,
parseStdOutLine: null,
timeoutMs: -1,
usePreCommandHook: false,
parseStdOutToken: path =>
{
if (path.EndsWith(GVFSConstants.GitPathSeparatorString, StringComparison.Ordinal))
{
onSparseDirectory(path);
}
});
}

/// <summary>Run <c>git version --build-options</c>.</summary>
public Result VersionBuildOptions()
{
return this.InvokeGitOutsideEnlistment("version --build-options");
}

/// <summary>
/// Return true when the output of <c>git version --build-options</c> has a line that is
/// exactly <paramref name="option"/>, apart from white space at the ends.
/// </summary>
internal static bool HasBuildOption(string buildOptionsOutput, string option)
{
if (buildOptionsOutput == null)
{
return false;
}

foreach (string line in buildOptionsOutput.Split('\n'))
{
if (string.Equals(line.Trim(), option, StringComparison.Ordinal))
{
return true;
}
}

return false;
}

public Result Status(bool allowObjectDownloads, bool useStatusCache, bool showUntracked = false)
{
string command = "status";
Expand Down
16 changes: 9 additions & 7 deletions GVFS/GVFS.Common/NamedPipes/ConeManagementNamedPipeMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ public static partial class NamedPipeMessages
/// it added for that command.
/// <para>
/// The hook treats every reply other than <see cref="SuccessResult"/> as "not applied"
/// and lets Git run. This includes <see cref="UnknownRequest"/> from a mount that does
/// not handle these messages, <see cref="MountNotReadyResult"/>, no reply within the
/// and lets Git run. This includes <see cref="FailureResult"/> and
/// <see cref="NotEnabledResult"/>, <see cref="UnknownRequest"/> from an older mount that
/// does not handle these messages, <see cref="MountNotReadyResult"/>, no reply within the
/// wait budget, and no mount. Git then expands the sparse index in memory.
/// </para>
/// <para>
Expand All @@ -28,11 +29,12 @@ public static partial class NamedPipeMessages
/// </para>
/// <para>
/// The mount owns the lifetime of the entries that it adds. A narrow can be missing
/// (the Git process was killed) or late (it timed out). Two Git commands can widen the
/// same directory at the same time, because commands that do not take the GVFS lock
/// (for example <c>git diff -- &lt;path&gt;</c>) also send widen requests. The command id
/// is the Git process id, so the mount can count the commands that need an entry and
/// remove the entries of a process that no longer runs.
/// (the Git process was killed) or late (it timed out). Commands that do not take the
/// GVFS lock (for example <c>git diff -- &lt;path&gt;</c>) also send widen requests. The
/// mount applies a widen only for the Git process that holds the GVFS lock (see
/// <c>AutoSparseIndexConeManager</c>). The command id is the Git process id, so the mount
/// can count the commands that need an entry and remove the entries of a process that
/// no longer runs.
/// </para>
/// <para>
/// A body is a list of fields separated by NUL. The header and the body split on the
Expand Down
Loading
Loading