예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReflogEntry"/> class.
 /// </summary>
 /// <param name="entryHandle">a <see cref="SafeHandle"/> to the reflog entry</param>
 internal unsafe ReflogEntry(git_reflog_entry *entryHandle)
 {
     _from      = Proxy.git_reflog_entry_id_old(entryHandle);
     _to        = Proxy.git_reflog_entry_id_new(entryHandle);
     _committer = Proxy.git_reflog_entry_committer(entryHandle);
     message    = Proxy.git_reflog_entry_message(entryHandle);
 }
예제 #2
0
        /// <summary>
        /// Returns an enumerator that iterates through the collection.
        /// <para>
        ///   The enumerator returns the <see cref="ReflogEntry"/> by descending order (last reflog entry is returned first).
        /// </para>
        /// </summary>
        /// <returns>An <see cref="IEnumerator{T}"/> object that can be used to iterate through the collection.</returns>
        public virtual unsafe IEnumerator <ReflogEntry> GetEnumerator()
        {
            var entries = new List <ReflogEntry>();

            using (ReflogHandle reflog = Proxy.git_reflog_read(repo.Handle, canonicalName))
            {
                var entriesCount = Proxy.git_reflog_entrycount(reflog);

                for (int i = 0; i < entriesCount; i++)
                {
                    git_reflog_entry *handle = Proxy.git_reflog_entry_byindex(reflog, i);
                    entries.Add(new ReflogEntry(handle));
                }
            }

            return(entries.GetEnumerator());
        }