コード例 #1
0
        private static bool ShouldLock(string[] args)
        {
            string gitCommand = GetGitCommand(args);

            switch (gitCommand)
            {
            // Keep these alphabetically sorted
            case "blame":
            case "branch":
            case "cat-file":
            case "check-attr":
            case "check-ignore":
            case "check-mailmap":
            case "commit-graph":
            case "config":
            case "credential":
            case "diff":
            case "diff-files":
            case "diff-index":
            case "diff-tree":
            case "difftool":
            case "fetch":
            case "for-each-ref":
            case "help":
            case "hash-object":
            case "index-pack":
            case "log":
            case "ls-files":
            case "ls-tree":
            case "merge-base":
            case "multi-pack-index":
            case "name-rev":
            case "push":
            case "remote":
            case "rev-list":
            case "rev-parse":
            case "show":
            case "show-ref":
            case "symbolic-ref":
            case "tag":
            case "unpack-objects":
            case "update-ref":
            case "version":
            case "web--browse":
                return(false);
            }

            if (gitCommand == "reset" && args.Contains("--soft"))
            {
                return(false);
            }

            if (!KnownGitCommands.Contains(gitCommand) &&
                IsAlias(gitCommand))
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: UnforeseenOcean/GVFS
        private static bool ShouldLock(string[] args)
        {
            string gitCommand = GetGitCommand(args);

            switch (gitCommand)
            {
            // Keep these alphabetically sorted
            case "cat-file":
            case "check-attr":
            case "config":
            case "credential":
            case "diff":
            case "diff-files":
            case "diff-tree":
            case "difftool":
            case "for-each-ref":
            case "help":
            case "index-pack":
            case "log":
            case "ls-tree":
            case "merge-base":
            case "mv":
            case "name-rev":
            case "push":
            case "remote":
            case "rev-list":
            case "rev-parse":
            case "show":
            case "symbolic-ref":
            case "unpack-objects":
            case "update-ref":
            case "version":
            case "web--browse":
                return(false);
            }

            if (gitCommand == "reset" && args.Contains("--soft"))
            {
                return(false);
            }

            // Don't acquire the lock if we've been explicitly asked not to. This enables tools, such as the VS Git
            // integration, to provide a "best effort" status without writing to the index. We assume that any such
            // tools will be constantly polling in the background, so missing a file once isn't a problem.
            if (gitCommand == "status" &&
                args.Contains("--no-lock-index"))
            {
                return(false);
            }

            if (!KnownGitCommands.Contains(gitCommand) &&
                IsAlias(gitCommand))
            {
                return(false);
            }

            return(true);
        }
コード例 #3
0
        private static bool ShouldLock(string[] args)
        {
            string gitCommand = GetGitCommand(args);

            switch (gitCommand)
            {
            // Keep these alphabetically sorted
            case "blame":
            case "branch":
            case "cat-file":
            case "check-attr":
            case "check-ignore":
            case "check-mailmap":
            case "commit-graph":
            case "config":
            case "credential":
            case "diff":
            case "diff-files":
            case "diff-index":
            case "diff-tree":
            case "difftool":
            case "fetch":
            case "for-each-ref":
            case "help":
            case "hash-object":
            case "index-pack":
            case "log":
            case "ls-files":
            case "ls-tree":
            case "merge-base":
            case "multi-pack-index":
            case "name-rev":
            case "pack-objects":
            case "push":
            case "remote":
            case "rev-list":
            case "rev-parse":
            case "show":
            case "show-ref":
            case "symbolic-ref":
            case "tag":
            case "unpack-objects":
            case "update-ref":
            case "version":
            case "web--browse":
                return(false);

            /*
             * There are several git commands that are "unsupported" in virtualized (VFS4G)
             * enlistments that are blocked by git. Usually, these are blocked before they acquire
             * a GVFSLock, but the submodule command is different, and is blocked after acquiring the
             * GVFS lock. This can cause issues if another action is attempting to create placeholders.
             * As we know the submodule command is a no-op, allow it to proceed without acquiring the
             * GVFSLock. I have filed issue #1164 to track having git block all unsupported commands
             * before calling the pre-command hook.
             */
            case "submodule":
                return(false);
            }

            if (gitCommand == "reset" && args.Contains("--soft"))
            {
                return(false);
            }

            if (!KnownGitCommands.Contains(gitCommand) &&
                IsAlias(gitCommand))
            {
                return(false);
            }

            return(true);
        }
コード例 #4
0
        private static bool ShouldLock(string[] args)
        {
            string gitCommand = GetGitCommand(args);

            switch (gitCommand)
            {
            // Keep these alphabetically sorted
            case "blame":
            case "branch":
            case "cat-file":
            case "check-attr":
            case "config":
            case "credential":
            case "diff":
            case "diff-files":
            case "diff-index":
            case "diff-tree":
            case "difftool":
            case "fetch":
            case "for-each-ref":
            case "help":
            case "index-pack":
            case "log":
            case "ls-files":
            case "ls-tree":
            case "merge-base":
            case "name-rev":
            case "push":
            case "remote":
            case "rev-list":
            case "rev-parse":
            case "show":
            case "show-ref":
            case "symbolic-ref":
            case "tag":
            case "unpack-objects":
            case "update-ref":
            case "version":
            case "web--browse":
                return(false);
            }

            if (gitCommand == "reset" && args.Contains("--soft"))
            {
                return(false);
            }

            try
            {
                // Don't acquire the lock if we've been explicitly asked not to. This enables tools, such as the VS Git
                // integration, to provide a "best effort" status without writing to the index. We assume that any such
                // tools will be constantly polling in the background, so missing a file once isn't a problem.
                // The git argument "--no-optional-locks" results in a 'negative' value GIT_OPTIONAL_LOCKS environment variable.
                if (gitCommand == "status" && (args.Contains("--no-lock-index") || IsGitEnvVarDisabled("GIT_OPTIONAL_LOCKS")))
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                ExitWithError("Failed to check if GVFS should lock: " + e.ToString());
            }

            if (!KnownGitCommands.Contains(gitCommand) &&
                IsAlias(gitCommand))
            {
                return(false);
            }

            return(true);
        }