Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » JGit question
JGit question [message #490306] Thu, 08 October 2009 10:19 Go to next message
Eclipse UserFriend
Originally posted by: hillner.informatik.uni-leipzig.de

Hello,

can I post questions on JGit in this newsgroup?
If not, does anyone know where to get support?

Thanks!
Re: JGit question [message #490336 is a reply to message #490306] Thu, 08 October 2009 12:03 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1212
Registered: July 2009
Senior Member
Yes this is the right place to ask questions about JGit. It moved from Google Code to the Eclipse EGit project recently.

You may also have a look at the EGit developer mailing list http://dev.eclipse.org/mhonarc/lists/egit-dev/maillist.html.
On the generic cGit mailing list http://news.gmane.org/gmane.comp.version-control.git you may also find JGit development discussions.

--
Matthias

[Updated on: Thu, 08 October 2009 12:05]

Report message to a moderator

Re: JGit question [message #490348 is a reply to message #490336] Thu, 08 October 2009 12:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hillner.informatik.uni-leipzig.de

OK, then I will just post my question here:

My problem is to get all revisions of a file in an existing repository.
I figured out how to get the content of that file if I have the commit in
which that file was changed.
Now the problem is about getting the right commits.
Here is my code:

AnyObjectId headID = local.resolve(Constants.HEAD);
RevWalk walk = new RevWalk(local);
walk.markStart(walk.parseCommit(headID));

TreeWalk fileWalker = new TreeWalk(local);
fileWalker.setRecursive(true);
walk.setTreeFilter(TreeFilter.ALL);
fileWalker.setFilter(TreeFilter.ALL);

RevCommitList<RevCommit> list = new RevCommitList<RevCommit>();
list.source(walk);

This I figured out in the egit plugin.
But when I execute that code the RevCommitList is always empty.
What can be wrong?

"Matthias Sohn" <matthias.sohn@sap.com> schrieb im Newsbeitrag
news:hakke0$ae9$1@build.eclipse.org...
> Yes this is the right place to ask questions about JGit. It moved from
> Google Code to the Eclipse EGit project recently.
> You may also have a look at the EGit developer mailing list
> http://dev.eclipse.org/mhonarc/lists/egit-dev/maillist.html or the generic
> cGit mailing list http://news.gmane.org/gmane.comp.version-control.git
> where JGit development topics were discussed prior to the move to Eclipse.
>
> --
> Matthias
Re: JGit question [message #490403 is a reply to message #490348] Thu, 08 October 2009 14:41 Go to previous messageGo to next message
Shawn O. Pearce is currently offline Shawn O. PearceFriend
Messages: 82
Registered: July 2009
Member
Stanley Hillner wrote:
> My problem is to get all revisions of a file in an existing repository.
> I figured out how to get the content of that file if I have the commit
> in which that file was changed.
> Now the problem is about getting the right commits.
> Here is my code:
>
> AnyObjectId headID = local.resolve(Constants.HEAD);
> RevWalk walk = new RevWalk(local);
> walk.markStart(walk.parseCommit(headID));
>
> TreeWalk fileWalker = new TreeWalk(local);
> fileWalker.setRecursive(true);
> walk.setTreeFilter(TreeFilter.ALL);
> fileWalker.setFilter(TreeFilter.ALL);
>
> RevCommitList<RevCommit> list = new RevCommitList<RevCommit>();
> list.source(walk);
>
> This I figured out in the egit plugin.
> But when I execute that code the RevCommitList is always empty.
> What can be wrong?

You didn't invoke list.fillTo(n), where n is the minimum number of
commits you need at this point in time. This trick works in the UI
world because the UI might only be able to show n rows at once.

In more batch oriented applications its more typical to just pump the
RevWalk yourself to populate the list:

for (RevCommit c : walk)
list.add(c)

Also, your RevWalk instance is configured to capture all commits in the
project history, but your first paragraph seems to indicate you want
only those commits which affected a particular file path. To limit the
results to only one path you actually need:

walk.setTreeFilter(AndTreeFilter.create(
PathFilter.create("a/file/path"),
TreeFilter.ANY_DIFF));

I'm not sure why you need a TreeWalk here, except to extract the file
contents once you identify a commit.
Re: JGit question [message #490414 is a reply to message #490403] Thu, 08 October 2009 15:07 Go to previous message
Eclipse UserFriend
Originally posted by: hillner.informatik.uni-leipzig.de

First thank you very much, it works fine.
The TreeWalk code is just left from preious attempts.
Also thank you for the filter hint, I've already defined one but then the
problem with the empty list arised.


"Shawn Pearce" <spearce@spearce.org> schrieb im Newsbeitrag
news:haktnh$igu$1@build.eclipse.org...
> Stanley Hillner wrote:
>> My problem is to get all revisions of a file in an existing repository.
>> I figured out how to get the content of that file if I have the commit in
>> which that file was changed.
>> Now the problem is about getting the right commits.
>> Here is my code:
>>
>> AnyObjectId headID = local.resolve(Constants.HEAD);
>> RevWalk walk = new RevWalk(local);
>> walk.markStart(walk.parseCommit(headID));
>>
>> TreeWalk fileWalker = new TreeWalk(local);
>> fileWalker.setRecursive(true);
>> walk.setTreeFilter(TreeFilter.ALL);
>> fileWalker.setFilter(TreeFilter.ALL);
>>
>> RevCommitList<RevCommit> list = new RevCommitList<RevCommit>();
>> list.source(walk);
>>
>> This I figured out in the egit plugin.
>> But when I execute that code the RevCommitList is always empty.
>> What can be wrong?
>
> You didn't invoke list.fillTo(n), where n is the minimum number of commits
> you need at this point in time. This trick works in the UI
> world because the UI might only be able to show n rows at once.
>
> In more batch oriented applications its more typical to just pump the
> RevWalk yourself to populate the list:
>
> for (RevCommit c : walk)
> list.add(c)
>
> Also, your RevWalk instance is configured to capture all commits in the
> project history, but your first paragraph seems to indicate you want only
> those commits which affected a particular file path. To limit the results
> to only one path you actually need:
>
> walk.setTreeFilter(AndTreeFilter.create(
> PathFilter.create("a/file/path"),
> TreeFilter.ANY_DIFF));
>
> I'm not sure why you need a TreeWalk here, except to extract the file
> contents once you identify a commit.
Re: JGit question [message #574485 is a reply to message #490306] Thu, 08 October 2009 12:03 Go to previous message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1212
Registered: July 2009
Senior Member
Yes this is the right place to ask questions about JGit. It moved from Google Code to the Eclipse EGit project recently.

You may also have a look at the EGit developer mailing list http://dev.eclipse.org/mhonarc/lists/egit-dev/maillist.html or the generic cGit mailing list http://news.gmane.org/gmane.comp.version-control.git where JGit development topics were discussed prior to the move to Eclipse.

--
Matthias
Re: JGit question [message #574533 is a reply to message #574485] Thu, 08 October 2009 12:20 Go to previous message
Eclipse UserFriend
Originally posted by: hillner.informatik.uni-leipzig.de

OK, then I will just post my question here:

My problem is to get all revisions of a file in an existing repository.
I figured out how to get the content of that file if I have the commit in
which that file was changed.
Now the problem is about getting the right commits.
Here is my code:

AnyObjectId headID = local.resolve(Constants.HEAD);
RevWalk walk = new RevWalk(local);
walk.markStart(walk.parseCommit(headID));

TreeWalk fileWalker = new TreeWalk(local);
fileWalker.setRecursive(true);
walk.setTreeFilter(TreeFilter.ALL);
fileWalker.setFilter(TreeFilter.ALL);

RevCommitList<RevCommit> list = new RevCommitList<RevCommit>();
list.source(walk);

This I figured out in the egit plugin.
But when I execute that code the RevCommitList is always empty.
What can be wrong?

"Matthias Sohn" <matthias.sohn@sap.com> schrieb im Newsbeitrag
news:hakke0$ae9$1@build.eclipse.org...
> Yes this is the right place to ask questions about JGit. It moved from
> Google Code to the Eclipse EGit project recently.
> You may also have a look at the EGit developer mailing list
> http://dev.eclipse.org/mhonarc/lists/egit-dev/maillist.html or the generic
> cGit mailing list http://news.gmane.org/gmane.comp.version-control.git
> where JGit development topics were discussed prior to the move to Eclipse.
>
> --
> Matthias
Re: JGit question [message #574553 is a reply to message #490348] Thu, 08 October 2009 14:41 Go to previous message
Shawn O. Pearce is currently offline Shawn O. PearceFriend
Messages: 82
Registered: July 2009
Member
Stanley Hillner wrote:
> My problem is to get all revisions of a file in an existing repository.
> I figured out how to get the content of that file if I have the commit
> in which that file was changed.
> Now the problem is about getting the right commits.
> Here is my code:
>
> AnyObjectId headID = local.resolve(Constants.HEAD);
> RevWalk walk = new RevWalk(local);
> walk.markStart(walk.parseCommit(headID));
>
> TreeWalk fileWalker = new TreeWalk(local);
> fileWalker.setRecursive(true);
> walk.setTreeFilter(TreeFilter.ALL);
> fileWalker.setFilter(TreeFilter.ALL);
>
> RevCommitList<RevCommit> list = new RevCommitList<RevCommit>();
> list.source(walk);
>
> This I figured out in the egit plugin.
> But when I execute that code the RevCommitList is always empty.
> What can be wrong?

You didn't invoke list.fillTo(n), where n is the minimum number of
commits you need at this point in time. This trick works in the UI
world because the UI might only be able to show n rows at once.

In more batch oriented applications its more typical to just pump the
RevWalk yourself to populate the list:

for (RevCommit c : walk)
list.add(c)

Also, your RevWalk instance is configured to capture all commits in the
project history, but your first paragraph seems to indicate you want
only those commits which affected a particular file path. To limit the
results to only one path you actually need:

walk.setTreeFilter(AndTreeFilter.create(
PathFilter.create("a/file/path"),
TreeFilter.ANY_DIFF));

I'm not sure why you need a TreeWalk here, except to extract the file
contents once you identify a commit.
Re: JGit question [message #574592 is a reply to message #490403] Thu, 08 October 2009 15:07 Go to previous message
Eclipse UserFriend
Originally posted by: hillner.informatik.uni-leipzig.de

First thank you very much, it works fine.
The TreeWalk code is just left from preious attempts.
Also thank you for the filter hint, I've already defined one but then the
problem with the empty list arised.


"Shawn Pearce" <spearce@spearce.org> schrieb im Newsbeitrag
news:haktnh$igu$1@build.eclipse.org...
> Stanley Hillner wrote:
>> My problem is to get all revisions of a file in an existing repository.
>> I figured out how to get the content of that file if I have the commit in
>> which that file was changed.
>> Now the problem is about getting the right commits.
>> Here is my code:
>>
>> AnyObjectId headID = local.resolve(Constants.HEAD);
>> RevWalk walk = new RevWalk(local);
>> walk.markStart(walk.parseCommit(headID));
>>
>> TreeWalk fileWalker = new TreeWalk(local);
>> fileWalker.setRecursive(true);
>> walk.setTreeFilter(TreeFilter.ALL);
>> fileWalker.setFilter(TreeFilter.ALL);
>>
>> RevCommitList<RevCommit> list = new RevCommitList<RevCommit>();
>> list.source(walk);
>>
>> This I figured out in the egit plugin.
>> But when I execute that code the RevCommitList is always empty.
>> What can be wrong?
>
> You didn't invoke list.fillTo(n), where n is the minimum number of commits
> you need at this point in time. This trick works in the UI
> world because the UI might only be able to show n rows at once.
>
> In more batch oriented applications its more typical to just pump the
> RevWalk yourself to populate the list:
>
> for (RevCommit c : walk)
> list.add(c)
>
> Also, your RevWalk instance is configured to capture all commits in the
> project history, but your first paragraph seems to indicate you want only
> those commits which affected a particular file path. To limit the results
> to only one path you actually need:
>
> walk.setTreeFilter(AndTreeFilter.create(
> PathFilter.create("a/file/path"),
> TreeFilter.ANY_DIFF));
>
> I'm not sure why you need a TreeWalk here, except to extract the file
> contents once you identify a commit.
Previous Topic:JGit question
Next Topic:java.io.FileNotFoundException when checking out a branch
Goto Forum:
  


Current Time: Tue Aug 16 08:21:10 GMT 2022

Powered by FUDForum. Page generated in 0.02617 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top