[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [jgit-dev] Diff between working directory and commit
- From: Tomasz Zarna <tzarna@xxxxxxxxx>
- Date: Mon, 13 Feb 2012 15:22:23 +0100
- Delivered-to: firstname.lastname@example.org
DirCacheIterator represents index (stage area), so your code shows
diffs between working tree (unstaged files) and the index (staged
files), ie what "git diff" with no params does.
Have a look at org.eclipse.egit.core.op.CreatePatchOperation.execute(IProgressMonitor)
from EGit where diffs for commits and working tree/index are
generated. It should give you an idea how to proceed. If not feel free
to drop me a line.
On Tue, Feb 7, 2012 at 23:22, Robert von Burg <eitch@xxxxxxxxxxx> wrote:
> 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);
> DirCacheIterator oldTree = new
> Â ÂDirCacheIterator(repository.readDirCache());
> FileTreeIterator newTree = new FileTreeIterator(repository);
> df.format(oldTree, newTree);
> 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
> jgit-dev mailing list