Example #1
0
 private PathStatus OnUntracked(string path, PathStatus status)
 {
     if (Options.PerPathNotificationCallback != null)
     {
         if (status == null)
         {
             status = new PathStatus(Repository, path);
         }
         status.WorkingPathStatus = WorkingPathStatus.Untracked;
     }
     Untracked.Add(path);
     AnyDifferences = true;
     return(status);
 }
Example #2
0
 private PathStatus OnRemoved(string path, PathStatus status)
 {
     if (Options.PerPathNotificationCallback != null)
     {
         if (status == null)
         {
             status = new PathStatus(Repository, path);
         }
         status.IndexPathStatus = IndexPathStatus.Removed;
     }
     Removed.Add(path);
     AnyDifferences = true;
     return(status);
 }
Example #3
0
 private PathStatus OnMergeConflict(string path, PathStatus status)
 {
     if (Options.PerPathNotificationCallback != null)
     {
         if (status == null)
         {
             status = new PathStatus(Repository, path);
         }
         status.IndexPathStatus = IndexPathStatus.MergeConflict;
     }
     MergeConflict.Add(path);
     AnyDifferences = true;
     return(status);
 }
Example #4
0
 private PathStatus OnUntracked(string path, PathStatus status)
 {
     if (Options.PerPathNotificationCallback != null)
     {
         if (status == null)
             status = new PathStatus(Repository, path);
         status.WorkingPathStatus = WorkingPathStatus.Untracked;
     }
     Untracked.Add(path);
     AnyDifferences = true;
     return status;
 }
Example #5
0
 private PathStatus OnStaged(string path, PathStatus status)
 {
     if (Options.PerPathNotificationCallback != null)
     {
         if (status == null)
             status = new PathStatus(Repository, path);
         status.IndexPathStatus = IndexPathStatus.Staged;
     }
     Staged.Add(path);
     AnyDifferences = true;
     return status;
 }
Example #6
0
 private PathStatus OnMergeConflict(string path, PathStatus status)
 {
     if (Options.PerPathNotificationCallback != null)
     {
         if (status == null)
             status = new PathStatus(Repository, path);
         status.IndexPathStatus = IndexPathStatus.MergeConflict;
     }
     MergeConflict.Add(path);
     AnyDifferences = true;
     return status;
 }
Example #7
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);
            }
        }