/// <summary> /// Return a list of those objects in the index which differ from whats in /// HEAD /// </summary> /// <returns>a set of ObjectIds of changed objects in the index</returns> /// <exception cref="System.IO.IOException">System.IO.IOException</exception> /// <exception cref="NGit.Errors.CorruptObjectException">NGit.Errors.CorruptObjectException /// </exception> /// <exception cref="NGit.Errors.NoWorkTreeException">NGit.Errors.NoWorkTreeException /// </exception> private ICollection <ObjectId> ListNonHEADIndexObjects() { RevWalk revWalk = null; try { if (repo.GetIndexFile() == null) { return(Sharpen.Collections.EmptySet <ObjectId>()); } } catch (NoWorkTreeException) { return(Sharpen.Collections.EmptySet <ObjectId>()); } TreeWalk treeWalk = new TreeWalk(repo); try { treeWalk.AddTree(new DirCacheIterator(repo.ReadDirCache())); ObjectId headID = repo.Resolve(Constants.HEAD); if (headID != null) { revWalk = new RevWalk(repo); treeWalk.AddTree(revWalk.ParseTree(headID)); revWalk.Dispose(); revWalk = null; } treeWalk.Filter = TreeFilter.ANY_DIFF; treeWalk.Recursive = true; ICollection <ObjectId> ret = new HashSet <ObjectId>(); while (treeWalk.Next()) { ObjectId objectId = treeWalk.GetObjectId(0); switch (treeWalk.GetRawMode(0) & FileMode.TYPE_MASK) { case FileMode.TYPE_MISSING: case FileMode.TYPE_GITLINK: { continue; goto case FileMode.TYPE_TREE; } case FileMode.TYPE_TREE: case FileMode.TYPE_FILE: case FileMode.TYPE_SYMLINK: { ret.AddItem(objectId); continue; goto default; } default: { throw new IOException(MessageFormat.Format(JGitText.Get().corruptObjectInvalidMode3 , string.Format("%o", Sharpen.Extensions.ValueOf(treeWalk.GetRawMode(0)), (objectId == null) ? "null" : objectId.Name, treeWalk.PathString, repo.GetIndexFile()))); } } } return(ret); } finally { if (revWalk != null) { revWalk.Dispose(); } treeWalk.Release(); } }