Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Creating the equivalent of "git diff"

If you look at the implementation of DiffFilter#getDiffTreeFilterFor, it looks like you need to pass it a WorkingTreeIterator to get it to use a NotIgnoredFilter.

I suppose if you must use a DirCacheIterator it's a missing feature to read .gitignore from the index.

On Sun, Sep 14, 2014 at 9:50 PM, Zach Oakes <zsoakes@xxxxxxxxx> wrote:
I'm trying to make an exact equivalent to the plain "git diff" command programmatically. The only remaining issue is that it doesn't seem to be respecting the repository's gitignore file. I am getting numerous diffs for files in a build directory, which do not appear when I run it on the command line. I would appreciate help if anyone can provide it.

DirCacheIterator dci = new DirCacheIterator(repo.readDirCache());
FileTreeIterator fti = new FileTreeIterator(repo);
ByteArrayOutputStream out = new ByteArrayOutputStream();
DiffFormatter df = new DiffFormatter(out);
df.setRepository(repo);
List<DiffEntry> entries = df.scan(dci, fti);

_______________________________________________
jgit-dev mailing list
jgit-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jgit-dev


Back to the top