[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] Diff between working directory and commit

Hi

I've been trying to find a way to build a diff between the current
working directory (unstaged items) and a certain commit.

In git this seems trivial by adding just saying which commit, but in
jgit i'm lost. This is what I have:

// diff of working directory with last commit
ByteArrayOutputStream out = new ByteArrayOutputStream();
DiffFormatter df = new DiffFormatter(out);
df.setRepository(repository);
DirCacheIterator oldTree = new
    DirCacheIterator(repository.readDirCache());
FileTreeIterator newTree = new FileTreeIterator(repository);
df.format(oldTree, newTree);
df.flush();
df.release();
System.out.println("Diff:\n" + out.toString() + "\n\n");

and building a diff when i have two objectIds is trivial.

What am I mising?

Kind regards
-- 
Robert von Burg <eitch@xxxxxxxxxxx>
dipl. Informatiker in Softwareentwicklung HF / pBac-Eng ODEC
software development
system & network administration

http://eitchnet.ch
http://gsinet.ch