// Modified version of GitSharp's Commit class
 private Change[] GetChanges(Repository repository, ObjectId id1, ObjectId id2)
 {
     var list = new List<Change>();
     TreeWalk walk = new TreeWalk(repository);
     walk.Reset(id1, id2);
     walk.Recursive = true;
     walk.Filter = TreeFilter.ANY_DIFF;
     while (walk.Next())
     {
         int m0 = walk.GetRawMode(0);
         if (walk.TreeCount == 2)
         {
             int m1 = walk.GetRawMode(1);
             var change = new Change
             {
                 Name = walk.PathString,
             };
             if (m0 != 0 && m1 == 0)
             {
                 change.ChangeType = ChangeType.Added;
             }
             else if (m0 == 0 && m1 != 0)
             {
                 change.ChangeType = ChangeType.Deleted;
             }
             else if (m0 != m1 && walk.IdEqual(0, 1))
             {
                 change.ChangeType = ChangeType.TypeChanged;
             }
             else
             {
                 change.ChangeType = ChangeType.Modified;
             }
             list.Add(change);
         }
         else
         {
             var raw_modes = new int[walk.TreeCount - 1];
             for (int i = 0; i < walk.TreeCount - 1; i++)
                 raw_modes[i] = walk.GetRawMode(i + 1);
             var change = new Change
             {
                 Name = walk.PathString,
             };
             if (m0 != 0 && raw_modes.All(m1 => m1 == 0))
             {
                 change.ChangeType = ChangeType.Added;
                 list.Add(change);
             }
             else if (m0 == 0 && raw_modes.Any(m1 => m1 != 0))
             {
                 change.ChangeType = ChangeType.Deleted;
                 list.Add(change);
             }
             else if (raw_modes.Select((m1, i) => new { Mode = m1, Index = i + 1 }).All(x => !walk.IdEqual(0, x.Index))) // TODO: not sure if this condition suffices in some special cases.
             {
                 change.ChangeType = ChangeType.Modified;
                 list.Add(change);
             }
             else if (raw_modes.Select((m1, i) => new { Mode = m1, Index = i + 1 }).Any(x => m0 != x.Mode && walk.IdEqual(0, x.Index)))
             {
                 change.ChangeType = ChangeType.TypeChanged;
                 list.Add(change);
             }
         }
     }
     return list.ToArray();
 }
 private Change BuildChange(PatchEntryChanges change)
 {
     var fileChange = new Change();
     fileChange.Name = change.Path;
     switch (change.Status)
     {
         case ChangeKind.Added:
             fileChange.ChangeType = ChangeType.Added;
             break;
         case ChangeKind.Copied:
             fileChange.ChangeType =ChangeType.Copied;
             break;
         case ChangeKind.Deleted:
             fileChange.ChangeType =ChangeType.Deleted;
             break;
         case ChangeKind.Modified:
             fileChange.ChangeType =ChangeType.Modified;
             break;
         case ChangeKind.Renamed:
             fileChange.ChangeType =ChangeType.Renamed;
             break;
         case ChangeKind.TypeChanged:
             fileChange.ChangeType =ChangeType.TypeChanged;
             break;
         case ChangeKind.Unmodified:
             fileChange.ChangeType =ChangeType.Unmerged;
             break;
     }
     return fileChange;
 }
        // Modified version of GitSharp's Commit class
        private Change[] GetChanges(Repository repository, ObjectId id1, ObjectId id2)
        {
            var      list = new List <Change>();
            TreeWalk walk = new TreeWalk(repository);

            walk.Reset(id1, id2);
            walk.Recursive = true;
            walk.Filter    = TreeFilter.ANY_DIFF;
            while (walk.Next())
            {
                int m0 = walk.GetRawMode(0);
                if (walk.TreeCount == 2)
                {
                    int m1     = walk.GetRawMode(1);
                    var change = new Change
                    {
                        Name = walk.PathString,
                    };
                    if (m0 != 0 && m1 == 0)
                    {
                        change.ChangeType = ChangeType.Added;
                    }
                    else if (m0 == 0 && m1 != 0)
                    {
                        change.ChangeType = ChangeType.Deleted;
                    }
                    else if (m0 != m1 && walk.IdEqual(0, 1))
                    {
                        change.ChangeType = ChangeType.TypeChanged;
                    }
                    else
                    {
                        change.ChangeType = ChangeType.Modified;
                    }
                    list.Add(change);
                }
                else
                {
                    var raw_modes = new int[walk.TreeCount - 1];
                    for (int i = 0; i < walk.TreeCount - 1; i++)
                    {
                        raw_modes[i] = walk.GetRawMode(i + 1);
                    }
                    var change = new Change
                    {
                        Name = walk.PathString,
                    };
                    if (m0 != 0 && raw_modes.All(m1 => m1 == 0))
                    {
                        change.ChangeType = ChangeType.Added;
                        list.Add(change);
                    }
                    else if (m0 == 0 && raw_modes.Any(m1 => m1 != 0))
                    {
                        change.ChangeType = ChangeType.Deleted;
                        list.Add(change);
                    }
                    else if (raw_modes.Select((m1, i) => new { Mode = m1, Index = i + 1 }).All(x => !walk.IdEqual(0, x.Index))) // TODO: not sure if this condition suffices in some special cases.
                    {
                        change.ChangeType = ChangeType.Modified;
                        list.Add(change);
                    }
                    else if (raw_modes.Select((m1, i) => new { Mode = m1, Index = i + 1 }).Any(x => m0 != x.Mode && walk.IdEqual(0, x.Index)))
                    {
                        change.ChangeType = ChangeType.TypeChanged;
                        list.Add(change);
                    }
                }
            }
            return(list.ToArray());
        }