Пример #1
0
        /// <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);
        }
Пример #2
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);
                    }
                }
            }
        }