Inheritance: IComparable
コード例 #1
0
 private static bool eq(TreeEntry t1, GitIndex.Entry e)
 {
     return (Compare(t1, e) == 0);
 }
コード例 #2
0
 private static bool eq(TreeEntry t1, TreeEntry t2)
 {
     return (Compare(t1, t2) == 0);
 }
コード例 #3
0
 private static int Compare(TreeEntry t, GitIndex.Entry i)
 {
     if ((t == null) && (i == null))
     {
         return 0;
     }
     if (t == null)
     {
         return 1;
     }
     if (i == null)
     {
         return -1;
     }
     return Tree.CompareNames(t.FullNameUTF8, i.NameUTF8, TreeEntry.LastChar(t), TreeEntry.LastChar(i));
 }
コード例 #4
0
 private static int Compare(TreeEntry t1, TreeEntry t2)
 {
     if ((((t1 != null) && (t1.Parent == null)) && (t2 != null)) && (t2.Parent == null))
     {
         return 0;
     }
     if ((t1 != null) && (t1.Parent == null))
     {
         return -1;
     }
     if ((t2 != null) && (t2.Parent == null))
     {
         return 1;
     }
     if ((t1 == null) && (t2 == null))
     {
         return 0;
     }
     if (t1 == null)
     {
         return 1;
     }
     if (t2 == null)
     {
         return -1;
     }
     return Tree.CompareNames(t1.FullNameUTF8, t2.FullNameUTF8, TreeEntry.LastChar(t1), TreeEntry.LastChar(t2));
 }
コード例 #5
0
 private void VisitEntry(TreeEntry t1, TreeEntry t2, GitIndex.Entry i)
 {
     Debug.Assert(((t1 != null) || (t2 != null)) || (i != null), "Needs at least one entry");
     Debug.Assert(_root != null, "Needs workdir");
     if ((t1 != null) && (t1.Parent == null))
     {
         t1 = null;
     }
     if ((t2 != null) && (t2.Parent == null))
     {
         t2 = null;
     }
     FileInfo file = null;
     if (i != null)
     {
         file = new FileInfo(Path.Combine(_root.FullName, i.Name));
     }
     else if (t1 != null)
     {
         file = new FileInfo(Path.Combine(_root.FullName, t1.FullName));
     }
     else if (t2 != null)
     {
         file = new FileInfo(Path.Combine(_root.FullName, t2.FullName));
     }
     if (((t1 != null) || (t2 != null)) || (i != null))
     {
         if (_threeTrees)
         {
             _visitor.VisitEntry(t1, t2, i, file);
         }
         else
         {
             _visitor.VisitEntry(t1, i, file);
         }
     }
 }
コード例 #6
0
ファイル: Browser.xaml.cs プロジェクト: ArildF/GitSharp
 private void SelectObject(TreeEntry node)
 {
     if (node.IsBlob)
     {
         //var blob = node as Blob;
         var text = Encoding.UTF8.GetString(m_repository.OpenBlob(node.Id).getBytes()); // TODO: better interface for blobs
         m_object.Document.Blocks.Clear();
         var p = new Paragraph();
         p.Inlines.Add(text);
         m_object.Document.Blocks.Add(p);
         m_object_title.Text = "Content of " + node.FullName;
     }
     else
     {
         m_object.Document.Blocks.Clear();
     }
 }
コード例 #7
0
ファイル: Tree.cs プロジェクト: rzeng/GitSharp
        private static int BinarySearch(TreeEntry[] entries, byte[] nameUTF8, int nameUTF8last, int nameStart, int nameEnd)
        {
            if (entries.Length == 0)
                return -1;
            int high = entries.Length;
            int low = 0;
            do
            {
                int mid = (low + high) / 2;
                int cmp = CompareNames(entries[mid].NameUTF8, nameUTF8,
                    nameStart, nameEnd, GitSharp.TreeEntry.LastChar(entries[mid]), nameUTF8last);

                if (cmp < 0)
                    low = mid + 1;
                else if (cmp == 0)
                    return mid;
                else
                    high = mid;

            } while (low < high);
            return -(low + 1);
        }
コード例 #8
0
 private static bool lt(TreeEntry h, TreeEntry m)
 {
     return (Compare(h, m) < 0);
 }
コード例 #9
0
ファイル: Tree.cs プロジェクト: rzeng/GitSharp
        public void AddEntry(TreeEntry e)
        {
            int p;

            EnsureLoaded();
            p = BinarySearch(_contents, e.NameUTF8, GitSharp.TreeEntry.LastChar(e), 0, e.NameUTF8.Length);
            if (p < 0)
            {
                e.AttachParent(this);
                InsertEntry(p, e);
            }
            else
            {
                throw new EntryExistsException(e.Name);
            }
        }
コード例 #10
0
ファイル: Tree.cs プロジェクト: rzeng/GitSharp
 internal void RemoveEntry(TreeEntry e)
 {
     TreeEntry[] c = _contents;
     int p = BinarySearch(c, e.NameUTF8, GitSharp.TreeEntry.LastChar(e), 0, e.NameUTF8.Length);
     if (p >= 0)
     {
         TreeEntry[] n = new TreeEntry[c.Length - 1];
         for (int k = c.Length - 1; k > p; k--)
             n[k - 1] = c[k];
         for (int k = p - 1; k >= 0; k--)
             n[k] = c[k];
         _contents = n;
         SetModified();
     }
 }
コード例 #11
0
ファイル: RepositoryStatus.cs プロジェクト: dev218/GitSharp
        /// <summary>
        /// 
        /// </summary>
        /// <param name="treeEntry"></param>
        /// <param name="wdirEntry">Note: wdirEntry is the non-ignored working directory entry.</param>
        /// <param name="indexEntry"></param>
        /// <param name="file">Note: gitignore patterns do not influence this parameter</param>
        private void OnVisitEntry(TreeEntry treeEntry, TreeEntry wdirEntry, GitIndex.Entry indexEntry, FileInfo file)
        {
            //Console.WriteLine(" ----------- ");
            //if (treeEntry != null)
            //   Console.WriteLine("tree: " + treeEntry.Name);
            //if (wdirEntry != null)
            //   Console.WriteLine("w-dir: " + wdirEntry.Name);
            //if (indexEntry != null)
            //   Console.WriteLine("index: " + indexEntry.Name);
            //Console.WriteLine("file: " + file.Name);

            string subdir_prefix = !string.IsNullOrEmpty (_root_path) ? _root_path + "/" : null;

            PathStatus path_status = null;
            if (indexEntry != null)
            {
                if (subdir_prefix != null && !indexEntry.Name.StartsWith (subdir_prefix))
                    return; // File outside the directory

                if (treeEntry == null)
                {
                    path_status = OnAdded(indexEntry.Name, path_status);
                }
                if (treeEntry != null && !treeEntry.Id.Equals(indexEntry.ObjectId))
                {
                    Debug.Assert(treeEntry.FullName == indexEntry.Name);
                    path_status = OnStaged(indexEntry.Name, path_status);
                }
                if (!file.Exists)
                {
                    path_status = OnMissing(indexEntry.Name, path_status);
                }
                if (file.Exists && indexEntry.IsModified(new DirectoryInfo(Repository.WorkingDirectory), Options.ForceContentCheck))
                {
                    path_status = OnModified(indexEntry.Name, path_status);
                }
                if (indexEntry.Stage != 0)
                {
                    path_status = OnMergeConflict(indexEntry.Name, path_status);
                }
            }
            else // <-- index entry == null
            {
                if (treeEntry != null && subdir_prefix != null && !treeEntry.FullName.StartsWith (subdir_prefix))
                    return; // File outside the directory

                if (treeEntry != null && !(treeEntry is Core.Tree))
                {
                    path_status = OnRemoved(treeEntry.FullName, path_status);
                }
                if (wdirEntry != null) // actually, we should enforce (treeEntry == null ) here too but original git does not, may be a bug.
                    path_status = OnUntracked(wdirEntry.FullName, path_status);
            }
            if (Options.PerPathNotificationCallback != null && path_status != null)
                Options.PerPathNotificationCallback(path_status);
        }
コード例 #12
0
 void IndexTreeVisitor.VisitEntry(TreeEntry treeEntry, GitIndex.Entry indexEntry, FileInfo file)
 {
     VisitEntryDelegate handler = VisitEntry;
     if (handler != null)
     {
         handler(treeEntry, indexEntry, file);
     }
 }
コード例 #13
0
        private void ProcessEntry(TreeEntry h, TreeEntry m, GitIndex.Entry i)
        {
            ObjectId iId = (i == null ? null : i.ObjectId);
            ObjectId mId = (m == null ? null : m.Id);
            ObjectId hId = (h == null ? null : h.Id);

            string name = (i != null ? i.Name : (h != null ? h.FullName : m.FullName));

            if (i == null)
            {
                //
                //				    I (index)                H        M        Result
                //			        -------------------------------------------------------
                //			        0 nothing             nothing  nothing  (does not happen)
                //			        1 nothing             nothing  exists   use M
                //			        2 nothing             exists   nothing  remove path from index
                //			        3 nothing             exists   exists   use M

                if (h == null)
                {
                    _updated.Add(name, mId);
                }
                else if (m == null)
                {
                    Removed.Add(name);
                }
                else
                {
                    _updated.Add(name, mId);
                }
            }
            else if (h == null)
            {
                //
                //					  clean I==H  I==M       H        M        Result
                //			         -----------------------------------------------------
                //			        4 yes   N/A   N/A     nothing  nothing  keep index
                //			        5 no    N/A   N/A     nothing  nothing  keep index
                //
                //			        6 yes   N/A   yes     nothing  exists   keep index
                //			        7 no    N/A   yes     nothing  exists   keep index
                //			        8 yes   N/A   no      nothing  exists   fail
                //			        9 no    N/A   no      nothing  exists   fail

                if (m == null || mId.Equals(iId))
                {
                    if (HasParentBlob(_merge, name))
                    {
                        if (i.IsModified(_root, true))
                        {
                            Conflicts.Add(name);
                        }
                        else
                        {
                            Removed.Add(name);
                        }
                    }
                }
                else
                {
                    Conflicts.Add(name);
                }
            }
            else if (m == null)
            {
                //
                //					10 yes   yes   N/A     exists   nothing  remove path from index
                //			        11 no    yes   N/A     exists   nothing  fail
                //			        12 yes   no    N/A     exists   nothing  fail
                //			        13 no    no    N/A     exists   nothing  fail
                //

                if (hId.Equals(iId))
                {
                    if (i.IsModified(_root, true))
                    {
                        Conflicts.Add(name);
                    }
                    else
                    {
                        Removed.Add(name);
                    }
                }
                else
                {
                    Conflicts.Add(name);
                }
            }
            else
            {
                if (!hId.Equals(mId) && !hId.Equals(iId) && !mId.Equals(iId))
                {
                    Conflicts.Add(name);
                }
                else if (hId.Equals(iId) && !mId.Equals(iId))
                {
                    if (i.IsModified(_root, true))
                    {
                        Conflicts.Add(name);
                    }
                    else
                    {
                        _updated.Add(name, mId);
                    }
                }
            }
        }
コード例 #14
0
 private static bool lt(GitIndex.Entry i, TreeEntry t)
 {
     return (Compare(t, i) > 0);
 }
コード例 #15
0
ファイル: Tree.cs プロジェクト: rzeng/GitSharp
 private void InsertEntry(int p, TreeEntry e)
 {
     TreeEntry[] c = _contents;
     TreeEntry[] n = new TreeEntry[c.Length + 1];
     p = -(p + 1);
     for (int k = c.Length - 1; k >= p; k--)
         n[k + 1] = c[k];
     n[p] = e;
     for (int k = p - 1; k >= 0; k--)
         n[k] = c[k];
     _contents = n;
     SetModified();
 }
コード例 #16
0
 private static bool lt(TreeEntry h, GitIndex.Entry i)
 {
     return (Compare(h, i) < 0);
 }
コード例 #17
0
ファイル: Tree.cs プロジェクト: rzeng/GitSharp
        private void ReadTree(byte[] raw)
        {
            int rawSize = raw.Length;
            int rawPtr = 0;
            TreeEntry[] temp;
            int nextIndex = 0;

            while (rawPtr < rawSize)
            {
                while (rawPtr < rawSize && raw[rawPtr] != 0)
                    rawPtr++;
                rawPtr++;
                rawPtr += ObjectId.ObjectIdLength;
                nextIndex++;
            }

            temp = new TreeEntry[nextIndex];
            rawPtr = 0;
            nextIndex = 0;
            while (rawPtr < rawSize)
            {
                int c = raw[rawPtr++];
                if (c < '0' || c > '7')
                    throw new CorruptObjectException(this.Id, "invalid entry mode");
                int mode = c - '0';
                for (; ; )
                {
                    c = raw[rawPtr++];
                    if (' ' == c)
                        break;
                    else if (c < '0' || c > '7')
                        throw new CorruptObjectException(this.Id, "invalid mode");
                    mode <<= 3;
                    mode += c - '0';
                }

                int nameLen = 0;
                while (raw[rawPtr + nameLen] != 0)
                    nameLen++;
                byte[] name = new byte[nameLen];
                Array.Copy(raw, rawPtr, name, 0, nameLen);
                rawPtr += nameLen + 1;

                ObjectId id = ObjectId.FromRaw(raw, rawPtr);
                rawPtr += ObjectId.ObjectIdLength;

                TreeEntry ent;
                if (FileMode.RegularFile.Equals(mode))
                    ent = new FileTreeEntry(this, id, name, false);
                else if (FileMode.ExecutableFile.Equals(mode))
                    ent = new FileTreeEntry(this, id, name, true);
                else if (FileMode.Tree.Equals(mode))
                {
                    ent = new Tree(this, id, name);
                }
                else if (FileMode.Symlink.Equals(mode))
                    ent = new SymlinkTreeEntry(this, id, name);
                else
                    throw new CorruptObjectException(this.Id, "Invalid mode: "
                            + Convert.ToString(mode, 8));
                temp[nextIndex++] = ent;
            }

            _contents = temp;
        }
コード例 #18
0
        private void FinishVisitTree(TreeEntry t1, TreeEntry t2, int curIndexPos)
        {
            Debug.Assert((t1 != null) || (t2 != null), "Needs at least one entry");
            Debug.Assert(_root != null, "Needs workdir");

            if ((t1 != null) && (t1.Parent == null))
            {
                t1 = null;
            }
            if ((t2 != null) && (t2.Parent == null))
            {
                t2 = null;
            }

            FileInfo file = null;
            string fileName = null;
            if (t1 != null)
            {
                fileName = t1.FullName;
                file = new FileInfo(Path.Combine(_root.FullName, fileName));
            }
            else if (t2 != null)
            {
                fileName = t2.FullName;
                file = new FileInfo(Path.Combine(_root.FullName, fileName));
            }

            if (t1 is Tree || t2 is Tree)
            {
                if (_threeTrees)
                    _visitor.FinishVisitTree((Tree)t1, (Tree)t2, fileName);
                else
                    _visitor.FinishVisitTree((Tree)t1, IndexCounter - curIndexPos, fileName);
            }
            else if (t1 != null || t2 != null)
            {
                if (_threeTrees)
                    _visitor.VisitEntry(t1, t2, null, file);
                else
                    _visitor.VisitEntry(t1, null, file);
            }
        }
コード例 #19
0
 void IndexTreeVisitor.VisitEntry(TreeEntry treeEntry, TreeEntry auxEntry, GitIndex.Entry indexEntry, FileInfo file)
 {
     VisitEntryAuxDelegate handler = this.VisitEntryAux;
     if (handler != null)
         handler(treeEntry,auxEntry, indexEntry, file);    
 }
コード例 #20
0
ファイル: TreeEntry.cs プロジェクト: ArildF/GitSharp
 public static int LastChar(TreeEntry treeEntry)
 {
     if (treeEntry is FileTreeEntry)
         return '\0';
     else
         return '/';
 }
コード例 #21
0
ファイル: Tree.cs プロジェクト: drothmaler/GitSharp
        private void InsertEntry(int p, TreeEntry e)
        {
            TreeEntry[] c = _contents;
            var n = new TreeEntry[c.Length + 1];

            p = -(p + 1);
            for (int k = c.Length - 1; k >= p; k--)
            {
                n[k + 1] = c[k];
            }

            n[p] = e;
            for (int k = p - 1; k >= 0; k--)
            {
                n[k] = c[k];
            }

            _contents = n;

            Id = null;
        }