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"

Do you work on windows? If yes switch to your repo and try "git config core.filemode false". Then run your test again.

Ciao
  Chris

On Wed, Sep 17, 2014 at 4:39 PM, Zach Oakes <zsoakes@xxxxxxxxx> wrote:
I think it may be related to the fact that my repos are stored on an external drive (EXFAT format, if that matters). When I run my code with CanonicalTreeParser, I get diffs for every file that look like this:

diff --git a/README.md b/README.md
old mode 100644
new mode 100755

So I think something about being stored on an external drive is making it detect a file mode change. I'm still not sure why it appears here, but not with "git diff", but it's at least reassuring that this is probably specific to my setup.

Zach

On Wed, Sep 17, 2014 at 9:48 AM, Robin Stocker <robin@xxxxxxxxx> wrote:
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 :).


_______________________________________________
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