public void scan(string prefix)
            {
                if (ALL.Equals(prefix))
                {
                    scanOne(Constants.HEAD);
                    scanTree(Constants.R_REFS, _refDirectory.refsDir);

                    // If any entries remain, they are deleted, drop them.
                    if (newLoose == null && curIdx < curLoose.size())
                    {
                        newLoose = curLoose.copy(curIdx);
                    }
                }
                else if (prefix.StartsWith(Constants.R_REFS) && prefix.EndsWith("/"))
                {
                    curIdx = -(curLoose.find(prefix) + 1);
                    DirectoryInfo dir = PathUtil.CombineDirectoryPath(_refDirectory.refsDir, prefix.Substring(Constants.R_REFS.Length));
                    scanTree(prefix, dir);

                    // Skip over entries still within the prefix; these have
                    // been removed from the directory.
                    while (curIdx < curLoose.size())
                    {
                        if (!curLoose.get(curIdx).getName().StartsWith(prefix))
                        {
                            break;
                        }
                        if (newLoose == null)
                        {
                            newLoose = curLoose.copy(curIdx);
                        }
                        curIdx++;
                    }

                    // Keep any entries outside of the prefix space, we
                    // do not know anything about their status.
                    if (newLoose != null)
                    {
                        while (curIdx < curLoose.size())
                        {
                            newLoose.add(curLoose.get(curIdx++));
                        }
                    }
                }
            }
Exemple #2
0
        public void testCopyLeadingPrefix()
        {
            RefList <global::GitSharp.Core.Ref> one = toList(REF_A, REF_B, REF_c);
            RefList <global::GitSharp.Core.Ref> two = one.copy(2).toRefList();

            Assert.AreNotSame(one, two);

            Assert.AreEqual(3, one.size());
            Assert.AreSame(REF_A, one.get(0));
            Assert.AreSame(REF_B, one.get(1));
            Assert.AreSame(REF_c, one.get(2));

            Assert.AreEqual(2, two.size());
            Assert.AreSame(REF_A, two.get(0));
            Assert.AreSame(REF_B, two.get(1));
        }