Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Comparing two Tree/FileTreeEntry for getting theirs equality


> I'm wondering is there any way to compare two Tree or FileTreeEntry
> for getting theirs equality. While implementing Synchronize View
> integration I have two use cases when such feature would be useful.

I do some tree comparison in the DirCacheCheckout [1]. When comparing
two trees I think the situation is easy. When two trees are equal then they
will have the same Id. (you can also assume the opposite: two trees having
same Id -> they are equal). So if you compare current HEAD against some other
branch comparing Id's is sufficient. (And it's much faster than
content comparison)

More complicated is the case when you compare a tree to the index or to
a folder in the working-tree. There is a thread [2] between Shawn and me
where I ask similar questions as you do. Problem is that especially for
the index we may not have the Ids for trees computed. If you are comparing
trees against the Working-Tree you may want to you WorkingTreeIterator which
allows you to compute Ids for subfolders. Then you can compare this Ids against
the Ids in the tree and you save reading the content from the tree.

Hope this helps.



Back to the top