2 * Copyright (C) 2007 David Watson <dwatson@mimvista.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License, version 2.1, as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18 package org
.spearce
.jgit
.lib
;
20 import java
.io
.IOException
;
21 import java
.util
.HashSet
;
23 import org
.spearce
.jgit
.lib
.GitIndex
.Entry
;
25 public class IndexDiff
{
26 private GitIndex index
;
29 public IndexDiff(Tree tree
, GitIndex index
) {
34 public void diff() throws IOException
{
35 for (Entry entry
: index
.getMembers()) {
36 String filename
= entry
.getName();
37 // if (checked.contains(filename))
40 TreeEntry treeBlob
= tree
.findBlobMember(filename
);
41 if (treeBlob
== null) {
43 } else if (entry
.getObjectId() != null && !entry
.getObjectId().equals(treeBlob
.getId())) {
44 changed
.add(filename
);
47 checked
.add(filename
);
50 tree
.accept(new TreeVisitor() {
52 public void visitSymlink(SymlinkTreeEntry s
) throws IOException
{
55 public void visitFile(FileTreeEntry f
) throws IOException
{
56 if (checked
.contains(f
.getFullName()))
58 removed
.add(f
.getFullName());
61 public void startVisitTree(Tree t
) throws IOException
{
62 // TODO Auto-generated method stub
66 public void endVisitTree(Tree t
) throws IOException
{
67 // TODO Auto-generated method stub
74 private HashSet
<String
> checked
= new HashSet
<String
>();
75 private HashSet
<String
> added
= new HashSet
<String
>();
76 private HashSet
<String
> changed
= new HashSet
<String
>();
77 private HashSet
<String
> removed
= new HashSet
<String
>();
79 public HashSet
<String
> getAdded() {
83 public HashSet
<String
> getChanged() {
87 public HashSet
<String
> getRemoved() {