public override NGit.Api.Status Call ()
		{
			if (iter == null)
				iter = new FileTreeIterator(repo);
			
			IndexDiff diff = new IndexDiff(repo, Constants.HEAD, iter);
			if (Files != null) {
				var filters = Files.Where (f => f != ".").ToArray ();
				if (filters.Length > 0)
					diff.SetFilter (PathFilterGroup.CreateFromStrings (filters));
			}
			
			diff.Diff ();
			return new NGit.Api.Status(diff);
		}
Пример #2
0
		public override NGit.Api.Status Call ()
		{
			if (iter == null)
				iter = new FileTreeIterator(repo);
			
			IndexDiff diff = new IndexDiff(repo, Constants.HEAD, iter);
			if (Files != null) {
				var filters = Files.Select (PathFilter.Create).ToArray ();
				if (filters.Length > 1)
					diff.SetFilter (OrTreeFilter.Create (filters));
				else
					diff.SetFilter (filters [0]);
			}
			
			diff.Diff ();
			return new NGit.Api.Status(diff);
		}
        public GitFileStatus GetFileStatusNoCache(string fileName)
        {
            //Debug.WriteLine(string.Format("===+ GetFileStatusNoCache {0}", fileName));

            var fileNameRel = GetRelativeFileNameForGit(fileName);

            IndexDiff indexDiff = new IndexDiff(repository, Constants.HEAD, new FileTreeIterator(repository));
            indexDiff.SetFilter(PathFilterGroup.CreateFromStrings(fileNameRel));
            indexDiff.Diff();

            if (indexDiff.GetModified().Count > 0)
                return GitFileStatus.Modified;

            if (indexDiff.GetConflicting().Count > 0)
                return GitFileStatus.Conflict;

            if (indexDiff.GetUntracked().Count > 0 || indexDiff.GetUntrackedFolders().Count > 0)
            {
                if (File.Exists(fileName))
                    return GitFileStatus.New;

                return GitFileStatus.NotControlled;
            }

            if (indexDiff.GetAdded().Count > 0)
                return GitFileStatus.Added;

            if (!File.Exists(fileName))
            {
                if (indexDiff.GetMissing().Count > 0)
                    return GitFileStatus.Removed;

                return GitFileStatus.Deleted;
            }

            if (indexDiff.GetChanged().Count > 0)
                return GitFileStatus.Staged;

            if (indexDiff.GetIgnoredNotInIndex().Count > 0)
                return GitFileStatus.Ignored;

            return GitFileStatus.Tracked;
        }