Ejemplo n.º 1
0
        internal unsafe RepositoryStatus(Repository repo, StatusOptions options)
        {
            statusEntries = new List <StatusEntry>();

            using (GitStatusOptions coreOptions = CreateStatusOptions(options ?? new StatusOptions()))
                using (StatusListHandle list = Proxy.git_status_list_new(repo.Handle, coreOptions))
                {
                    int count = Proxy.git_status_list_entrycount(list);

                    for (int i = 0; i < count; i++)
                    {
                        git_status_entry *entry = Proxy.git_status_byindex(list, i);
                        AddStatusEntryForDelta(entry->status, entry->head_to_index, entry->index_to_workdir);
                    }

                    isDirty = statusEntries.Any(entry => entry.State != FileStatus.Ignored && entry.State != FileStatus.Unaltered);
                }
        }
Ejemplo n.º 2
0
        private static GitStatusOptions CreateStatusOptions(StatusOptions options)
        {
            var coreOptions = new GitStatusOptions
            {
                Version = 1,
                Show    = (GitStatusShow)options.Show,
            };

            if (options.IncludeIgnored)
            {
                coreOptions.Flags |= GitStatusOptionFlags.IncludeIgnored;
            }

            if (options.IncludeUntracked)
            {
                coreOptions.Flags |= GitStatusOptionFlags.IncludeUntracked;
            }

            if (options.DetectRenamesInIndex)
            {
                coreOptions.Flags |=
                    GitStatusOptionFlags.RenamesHeadToIndex |
                    GitStatusOptionFlags.RenamesFromRewrites;
            }

            if (options.DetectRenamesInWorkDir)
            {
                coreOptions.Flags |=
                    GitStatusOptionFlags.RenamesIndexToWorkDir |
                    GitStatusOptionFlags.RenamesFromRewrites;
            }

            if (options.ExcludeSubmodules)
            {
                coreOptions.Flags |=
                    GitStatusOptionFlags.ExcludeSubmodules;
            }

            if (options.RecurseIgnoredDirs)
            {
                coreOptions.Flags |=
                    GitStatusOptionFlags.RecurseIgnoredDirs;
            }

            if (options.RecurseUntrackedDirs)
            {
                coreOptions.Flags |=
                    GitStatusOptionFlags.RecurseUntrackedDirs;
            }

            if (options.PathSpec != null)
            {
                coreOptions.PathSpec = GitStrArrayManaged.BuildFrom(options.PathSpec);
            }

            if (options.DisablePathSpecMatch)
            {
                coreOptions.Flags |=
                    GitStatusOptionFlags.DisablePathspecMatch;
            }

            if (options.IncludeUnaltered)
            {
                coreOptions.Flags |=
                    GitStatusOptionFlags.IncludeUnmodified;
            }

            return(coreOptions);
        }