示例#1
0
        internal unsafe static IndexEntry FromNative(git_index_entry *nativeEntry)
        {
            Ensure.ArgumentNotNull(nativeEntry, "nativeEntry");
            Ensure.ArgumentConformsTo(() => nativeEntry->dev <= int.MaxValue, "dev", "dev m");

            int stage = (nativeEntry->flags & git_index.GIT_INDEX_ENTRY_STAGEMASK) >> git_index.GIT_INDEX_ENTRY_STAGESHIFT;

            var flags = IndexEntryFlags.None;

            flags |= (nativeEntry->flags & (ushort)git_index_entry_flag_t.GIT_INDEX_ENTRY_VALID) != 0 ? IndexEntryFlags.Valid : 0;
            flags |= (nativeEntry->extended_flags & (ushort)git_index_entry_extended_flag_t.GIT_INDEX_ENTRY_INTENT_TO_ADD) != 0 ? IndexEntryFlags.IntentToAdd : 0;
            flags |= (nativeEntry->extended_flags & (ushort)git_index_entry_extended_flag_t.GIT_INDEX_ENTRY_SKIP_WORKTREE) != 0? IndexEntryFlags.SkipWorktree : 0;

            return(new IndexEntry(
                       path: Utf8Converter.FromNative(nativeEntry->path),
                       mode: (FileMode)nativeEntry->mode,
                       id: ObjectId.FromNative(nativeEntry->id),
                       stage: (IndexEntryStage)stage,
                       flags: flags,
                       changeTime: IndexEntryTime.FromNative(nativeEntry->ctime),
                       modificationTime: IndexEntryTime.FromNative(nativeEntry->mtime),
                       device: nativeEntry->dev,
                       inode: nativeEntry->ino,
                       userId: nativeEntry->uid,
                       groupId: nativeEntry->gid,
                       fileSize: nativeEntry->file_size));
        }
示例#2
0
 private unsafe IndexEntry this[int index]
 {
     get
     {
         git_index_entry *entryHandle = Proxy.git_index_get_byindex(handle, (UIntPtr)index);
         return(IndexEntry.BuildFromPtr(entryHandle));
     }
 }
示例#3
0
        /// <summary>
        /// Gets the <see cref="IndexEntry"/> with the specified relative path.
        /// </summary>
        public virtual unsafe IndexEntry this[string path]
        {
            get
            {
                Ensure.ArgumentNotNullOrEmptyString(path, "path");

                git_index_entry *entry = Proxy.git_index_get_bypath(handle, path, 0);
                return(IndexEntry.BuildFromPtr(entry));
            }
        }
示例#4
0
        public unsafe bool MoveNext()
        {
            git_index_entry *entry = null;
            int ret = Ensure.NativeCall(() => libgit2.git_index_iterator_next(out entry, nativeIterator), this);

            if (ret == (int)git_error_code.GIT_ITEROVER)
            {
                return(false);
            }
            Ensure.NativeSuccess(ret);

            current = IndexEntry.FromNative(entry);
            return(true);
        }
示例#5
0
        /// <summary>
        /// Gets the index entry at the specified path and at the given
        /// stage level.
        ///
        /// <para>
        /// A "stage level" is a construct for handling conflicted files
        /// during a merge; generally, files are in stage level 0
        /// (sometimes called the "main index"); if a file is in conflict
        /// after a merge, there will be no entry at stage level 0, instead
        /// there will be entries at stages 1-3 representing the conflicting
        /// contents of the common ancestor, the file in "our" branch and
        /// the file in "their" branch.
        /// </para>
        /// </summary>
        public unsafe IndexEntry this[string path, int stage]
        {
            get
            {
                Ensure.NotDisposed(nativeIndex, "index");
                Ensure.ArgumentNotNull(path, "path");

                git_index_entry *entry = libgit2.git_index_get_bypath(nativeIndex, path, stage);
                GC.KeepAlive(this);

                if (entry == null)
                {
                    throw new KeyNotFoundException(string.Format("there is no index entry for path {0}", path));
                }

                return(IndexEntry.FromNative(entry));
            }
        }
示例#6
0
        /// <summary>
        /// Gets the index entry at the specified index.
        /// </summary>
        public unsafe IndexEntry this[int position]
        {
            get
            {
                Ensure.NotDisposed(nativeIndex, "index");
                Ensure.ArgumentConformsTo(() => position >= 0, "position", "position must not be negative");

                git_index_entry *entry = libgit2.git_index_get_byindex(nativeIndex, (UIntPtr)position);
                GC.KeepAlive(this);

                if (entry == null)
                {
                    throw new IndexOutOfRangeException(string.Format("there is no index entry at position {0}", position));
                }

                return(IndexEntry.FromNative(entry));
            }
        }
示例#7
0
        internal static unsafe IndexEntry BuildFromPtr(git_index_entry *entry)
        {
            if (entry == null)
            {
                return(null);
            }

            string path = LaxUtf8Marshaler.FromNative(entry->path);

            return(new IndexEntry
            {
                Path = path,
                Id = new ObjectId(entry->id.Id),
                StageLevel = Proxy.git_index_entry_stage(entry),
                Mode = (Mode)entry->mode,
                AssumeUnchanged = (git_index_entry.GIT_IDXENTRY_VALID & entry->flags) == git_index_entry.GIT_IDXENTRY_VALID
            });
        }
示例#8
0
 public static extern unsafe int git_index_iterator_next(out git_index_entry *entry, git_index_iterator *iterator);