JGit question [message #490306] |
Thu, 08 October 2009 10:19 |
Eclipse User |
|
|
|
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 #490348 is a reply to message #490336] |
Thu, 08 October 2009 12:20 |
Eclipse User |
|
|
|
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 #490414 is a reply to message #490403] |
Thu, 08 October 2009 15:07 |
Eclipse User |
|
|
|
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 #574533 is a reply to message #574485] |
Thu, 08 October 2009 12:20 |
Eclipse User |
|
|
|
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 #574592 is a reply to message #490403] |
Thu, 08 October 2009 15:07 |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.07141 seconds