[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jgit-dev] Creating the equivalent of "git diff"
|
Yes. Just tried your code here and it works as expected. So it
sounds like your problem may be specific to your repository or
configuration.
Are you able to share your repository?
Can you share the output of `git config --list` when executed
in your repository?
You mentioned at the beginning that files that should be ignored
are included, could you share your .gitignore files?
By the way, the most straightforward way to do "git diff" using
the API is this:
Git git = Git.wrap(repo);
List<DiffEntry> entries = git.diff().call();
(Unfortunately, doing "git diff HEAD" isn't as straighforward,
something we should fix. I filed a bug for that [1].)
Regards,
Robin
[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=444363
Zach Oakes wrote:
> That sounds like what I'm looking to do. Is it correct to use
> CanonicalTreeParser the way I did to accomplish this?
> On Sep 16, 2014 1:43 PM, "Dave Borowitz" <dborowitz@xxxxxxxxxx>
> wrote:
>
> > My mistake, "git diff" diffs the work tree against the index. I
> > don't have
> > it in front of me but I'll bet if you look at the implementation,
> > that's
> > what pgm.Diff is doing :)
> >
> > On Mon, Sep 15, 2014 at 10:16 PM, Robin Stocker <robin@xxxxxxxxx>
> > wrote:
> >
> >> Dave Borowitz wrote:
> >> > "git diff" is the same as "git diff HEAD".
> >>
> >> That's not correct in general:
> >>
> >> $ mkdir git-diff-test && cd git-diff-test && git init -q
> >> $ echo "a" > file.txt
> >> $ git add file.txt
> >> $ git commit -qm "Initial"
> >> $ echo "b" >> file.txt
> >> $ git add file.txt
> >> $ echo "c" >> file.txt
> >> $ git diff
> >> diff --git a/file.txt b/file.txt
> >> index 422c2b7..de98044 100644
> >> --- a/file.txt
> >> +++ b/file.txt
> >> @@ -1,2 +1,3 @@
> >> a
> >> b
> >> +c
> >> $ git diff HEAD
> >> diff --git a/file.txt b/file.txt
> >> index 7898192..de98044 100644
> >> --- a/file.txt
> >> +++ b/file.txt
> >> @@ -1 +1,3 @@
> >> a
> >> +b
> >> +c
> >>
> >>
> >> It's only the same if there are no changes between index and HEAD.
> >>
> >> Having said that, I don't know which one Zach actually wants :).