Ejemplo n.º 1
0
        public void LoadOrCreate()
        {
            foreach (string line in this.sparseCheckoutSerializer.ReadAll())
            {
                string sanitizedFileLine;
                if (GitConfigHelper.TrySanitizeConfigFileLine(line, out sanitizedFileLine))
                {
                    this.sparseCheckoutEntries.Add(sanitizedFileLine);
                }
            }

            this.sparseCheckoutSerializer.Close();
        }
Ejemplo n.º 2
0
        public void LoadOrCreate()
        {
            foreach (string line in this.fileSerializer.ReadAll())
            {
                string sanitizedFileLine;
                if (GitConfigHelper.TrySanitizeConfigFileLine(line, out sanitizedFileLine))
                {
                    this.entries.Add(sanitizedFileLine);
                }
            }

            // Ensure the default entry is always in the always_exclude file
            if (this.entries.Add(DefaultEntry))
            {
                this.fileSerializer.AppendLine(DefaultEntry);
                this.fileSerializer.Close();
            }
        }
Ejemplo n.º 3
0
        public void TrimTrailingComment()
        {
            string outputString;

            GitConfigHelper.TrySanitizeConfigFileLine(" // # Trailing comment!", out outputString).ShouldEqual(true);
            outputString.ShouldEqual("//");

            GitConfigHelper.TrySanitizeConfigFileLine(" /* # Trailing comment!", out outputString).ShouldEqual(true);
            outputString.ShouldEqual("/*");

            GitConfigHelper.TrySanitizeConfigFileLine(" /A # Trailing comment!", out outputString).ShouldEqual(true);
            outputString.ShouldEqual("/A");

            GitConfigHelper.TrySanitizeConfigFileLine("\t /A \t # Trailing comment! \t", out outputString).ShouldEqual(true);
            outputString.ShouldEqual("/A");

            GitConfigHelper.TrySanitizeConfigFileLine("  \t /A   \t # Trailing comment!", out outputString).ShouldEqual(true);
            outputString.ShouldEqual("/A");
        }
Ejemplo n.º 4
0
        public void TrimWhitspace()
        {
            string outputString;

            GitConfigHelper.TrySanitizeConfigFileLine(" // ", out outputString).ShouldEqual(true);
            outputString.ShouldEqual("//");

            GitConfigHelper.TrySanitizeConfigFileLine(" /* ", out outputString).ShouldEqual(true);
            outputString.ShouldEqual("/*");

            GitConfigHelper.TrySanitizeConfigFileLine(" /A ", out outputString).ShouldEqual(true);
            outputString.ShouldEqual("/A");

            GitConfigHelper.TrySanitizeConfigFileLine("\t /A \t", out outputString).ShouldEqual(true);
            outputString.ShouldEqual("/A");

            GitConfigHelper.TrySanitizeConfigFileLine("  \t /A   \t", out outputString).ShouldEqual(true);
            outputString.ShouldEqual("/A");
        }
Ejemplo n.º 5
0
        public void GetSettingsTest()
        {
            string fileContents = @"
[core]
    gvfs = true
[gc]
    auto = 0
[section]
    key1 = 1
    key2 = 2
    key3 = 3
[notsection]
    keyN1 = N1
    keyN2 = N2
    keyN3 = N3
[section]
[section]
    key4 = 4
    key5 = 5
[section]
    key6 = 6
    key7 =
         = emptyKey";
            string filename     = Guid.NewGuid().ToString();

            File.WriteAllText(filename, fileContents);

            Dictionary <string, GitConfigSetting> result = GitConfigHelper.GetSettings(filename, "Section");

            int expectedCount = 7; // empty keys will not be included.

            result.Count.ShouldEqual(expectedCount);

            // Verify keyN = N
            for (int i = 1; i <= expectedCount - 1; i++)
            {
                result["key" + i.ToString()].Values.ShouldContain(v => v == i.ToString());
            }

            // Verify empty value
            result["key7"].Values.Single().ShouldEqual(string.Empty);
        }
Ejemplo n.º 6
0
        private static void VerifyRenameDetectionSettings(string[] args)
        {
            string srcRoot = Path.Combine(enlistmentRoot, GVFSConstants.WorkingDirectoryRootName);

            if (File.Exists(Path.Combine(srcRoot, GVFSConstants.DotGit.MergeHead)) ||
                File.Exists(Path.Combine(srcRoot, GVFSConstants.DotGit.RevertHead)))
            {
                // If no-renames and no-breaks are specified, avoid reading config.
                if (!args.Contains("--no-renames") || !args.Contains("--no-breaks"))
                {
                    Dictionary <string, GitConfigSetting> statusConfig = GitConfigHelper.GetSettings(
                        File.ReadAllLines(Path.Combine(srcRoot, GVFSConstants.DotGit.Config)),
                        "status");

                    if (!IsRunningWithParamOrSetting(args, statusConfig, "--no-renames", "renames") ||
                        !IsRunningWithParamOrSetting(args, statusConfig, "--no-breaks", "breaks"))
                    {
                        ExitWithError(
                            "git status requires rename detection to be disabled during a merge or revert conflict.",
                            "Run 'git status --no-renames --no-breaks'");
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public void SanitizeEmptyString()
        {
            string outputString;

            GitConfigHelper.TrySanitizeConfigFileLine(string.Empty, out outputString).ShouldEqual(false);
        }