* Newbie questions regarding jgit
@ 2008-11-11 20:44 Farrukh Najmi
2008-11-11 21:12 ` Farrukh Najmi
2008-11-11 21:37 ` Jonas Fonseca
0 siblings, 2 replies; 15+ messages in thread
From: Farrukh Najmi @ 2008-11-11 20:44 UTC (permalink / raw)
To: git
Hi all,
I am git newbie and looking to use jgit in a servlet endpoint.
Where can I find a public maven repo for gjit? It seems there is one
somewhere because of the following file in src tree:
jgit-maven/jgit/pom.xml
For now I have built the jar using /make_jgit.sh and installed the pom
manually using m
mvn install:install-file -DpomFile=jgit-maven/jgit/pom.xml -Dfile=jgit.jar
I have added the following dependency to my maven project's pom.xml:
<dependency>
<groupId>org.spearce</groupId>
<artifactId>jgit</artifactId>
<version>0.4-SNAPSHOT</version>
</dependency>
Now I am wondering where to begin to learn how to do the equivalent of
the following commands via the gjit Java API:
* git add /file/
* git rm /file/
* git mv /file
* Whatever is the git way to get a specific version of a file
I am hoping that there aremore docs, samples, tutorials etc. somewhere
that I am missing. Thanks for any help you can provide. Some pointers or
code fragments would be terrific.
--
Regards,
Farrukh Najmi
Web: http://www.wellfleetsoftware.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Newbie questions regarding jgit
2008-11-11 20:44 Farrukh Najmi
@ 2008-11-11 21:12 ` Farrukh Najmi
2008-11-11 21:37 ` Jonas Fonseca
1 sibling, 0 replies; 15+ messages in thread
From: Farrukh Najmi @ 2008-11-11 21:12 UTC (permalink / raw)
To: git
I should clarify that I am not using eclipse nor am I using any GUI. My
objective is to have Java API access to git from within a servlet using
jgit. At present, all I have to go on is javadoc and its not clear where
to begin if I simply wish to create, read and update files in a git repo
from within the servlet java code.
TIA for your help.
Farrukh Najmi wrote:
>
> Hi all,
>
> I am git newbie and looking to use jgit in a servlet endpoint.
>
> Where can I find a public maven repo for gjit? It seems there is one
> somewhere because of the following file in src tree:
>
> jgit-maven/jgit/pom.xml
>
> For now I have built the jar using /make_jgit.sh and installed the pom
> manually using m
>
> mvn install:install-file -DpomFile=jgit-maven/jgit/pom.xml
> -Dfile=jgit.jar
>
> I have added the following dependency to my maven project's pom.xml:
>
> <dependency>
> <groupId>org.spearce</groupId>
> <artifactId>jgit</artifactId>
> <version>0.4-SNAPSHOT</version>
> </dependency>
>
> Now I am wondering where to begin to learn how to do the equivalent of
> the following commands via the gjit Java API:
>
> * git add /file/
> * git rm /file/
> * git mv /file
> * Whatever is the git way to get a specific version of a file
>
>
> I am hoping that there aremore docs, samples, tutorials etc. somewhere
> that I am missing. Thanks for any help you can provide. Some pointers
> or code fragments would be terrific.
>
--
Regards,
Farrukh Najmi
Web: http://www.wellfleetsoftware.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Newbie questions regarding jgit
2008-11-11 20:44 Farrukh Najmi
2008-11-11 21:12 ` Farrukh Najmi
@ 2008-11-11 21:37 ` Jonas Fonseca
2008-11-11 21:44 ` Shawn O. Pearce
2008-11-12 14:05 ` Farrukh Najmi
1 sibling, 2 replies; 15+ messages in thread
From: Jonas Fonseca @ 2008-11-11 21:37 UTC (permalink / raw)
To: Farrukh Najmi; +Cc: git
On Tue, Nov 11, 2008 at 21:44, Farrukh Najmi
<farrukh@wellfleetsoftware.com> wrote:
> Hi all,
Hello,
> I am git newbie and looking to use jgit in a servlet endpoint.
Sounds interesting. I have been thinking about how hard it would be to
write a very simpe jgitweb kind of thing and am very interested to
hear more about your experiences.
> Where can I find a public maven repo for gjit? It seems there is one
> somewhere because of the following file in src tree:
I would also like to have a public available maven repository for
JGit. If Shawn or Robin acks, I can look into hosting one in the SVN
area of the Google Code project page. Given the lack of a real release
cycle it probably only makes sense to have a snapshot repository.
> Now I am wondering where to begin to learn how to do the equivalent of the
> following commands via the gjit Java API:
>
> * git add /file/
> * git rm /file/
> * git mv /file
> * Whatever is the git way to get a specific version of a file
JGit currently has two APIs for working with the index, which will
allow you to add, remove and move data around in the tree. In nbgit I
ended up using GitIndex, which I found easier to figure out. As I
understand it, in the long run you want to use the DirCache API, but
it is still a work in progress.
> I am hoping that there aremore docs, samples, tutorials etc. somewhere that
> I am missing. Thanks for any help you can provide. Some pointers or code
> fragments would be terrific.
I started working on a tutorial for JGit, but didn't get very far so
it mostly consists of stub pages.
- http://code.google.com/docreader/#p=egit&s=egit&t=JGitTutorial
I have been working on moving the tutorial to maven project before
starting to write the more code heavy topics. This would make it
possible to include code snippets in the tutorial, while also allowing
to compile and test the examples.
--
Jonas Fonseca
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Newbie questions regarding jgit
2008-11-11 21:37 ` Jonas Fonseca
@ 2008-11-11 21:44 ` Shawn O. Pearce
2008-11-11 22:01 ` Jonas Fonseca
2008-11-12 14:05 ` Farrukh Najmi
1 sibling, 1 reply; 15+ messages in thread
From: Shawn O. Pearce @ 2008-11-11 21:44 UTC (permalink / raw)
To: Jonas Fonseca; +Cc: Farrukh Najmi, git
Jonas Fonseca <jonas.fonseca@gmail.com> wrote:
>
> I would also like to have a public available maven repository for
> JGit. If Shawn or Robin acks, I can look into hosting one in the SVN
> area of the Google Code project page. Given the lack of a real release
> cycle it probably only makes sense to have a snapshot repository.
I have an account on kernel.org and was planning on hosting snapshots
there, but I haven't had time to think about setting up a jgit area
and pushing something into it. ;-)
We could also just host it in SVN in Google Code. I can give
you admin rights on the egit project if you want to set it up and
maintain it there. The downside is you need to use svn or git-svn
to upload files to it, right?
--
Shawn.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Newbie questions regarding jgit
2008-11-11 21:44 ` Shawn O. Pearce
@ 2008-11-11 22:01 ` Jonas Fonseca
2008-11-11 23:11 ` Shawn O. Pearce
2008-11-12 12:51 ` Farrukh Najmi
0 siblings, 2 replies; 15+ messages in thread
From: Jonas Fonseca @ 2008-11-11 22:01 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Farrukh Najmi, git
On Tue, Nov 11, 2008 at 22:44, Shawn O. Pearce <spearce@spearce.org> wrote:
> Jonas Fonseca <jonas.fonseca@gmail.com> wrote:
>> I would also like to have a public available maven repository for
>> JGit. If Shawn or Robin acks, I can look into hosting one in the SVN
>> area of the Google Code project page. Given the lack of a real release
>> cycle it probably only makes sense to have a snapshot repository.
>
> I have an account on kernel.org and was planning on hosting snapshots
> there, but I haven't had time to think about setting up a jgit area
> and pushing something into it. ;-)
If you prefer that ...
> We could also just host it in SVN in Google Code. I can give
> you admin rights on the egit project if you want to set it up and
> maintain it there. The downside is you need to use svn or git-svn
> to upload files to it, right?
I don't think admin rights are necessary as long as I have
"commit"/webdav access. And no svn or git-svn interaction should be
needed to upload to the maven repository.
Take a look at the distributionManagement section of the
google-maven-repository:
- http://google-maven-repository.googlecode.com/svn/repository/com/google/google/1/google-1.pom
Looks pretty easy to set up. About maintaining it, I don't mind doing
"mvn deploy" once in a while, but some kind of update policy should
probably be worked out in any case.
--
Jonas Fonseca
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Newbie questions regarding jgit
2008-11-11 22:01 ` Jonas Fonseca
@ 2008-11-11 23:11 ` Shawn O. Pearce
2008-11-12 2:24 ` Imran M Yousuf
2008-11-12 12:51 ` Farrukh Najmi
1 sibling, 1 reply; 15+ messages in thread
From: Shawn O. Pearce @ 2008-11-11 23:11 UTC (permalink / raw)
To: Jonas Fonseca; +Cc: Farrukh Najmi, git
Jonas Fonseca <jonas.fonseca@gmail.com> wrote:
>
> I don't think admin rights are necessary as long as I have
> "commit"/webdav access. And no svn or git-svn interaction should be
> needed to upload to the maven repository.
>
> Take a look at the distributionManagement section of the
> google-maven-repository:
>
> - http://google-maven-repository.googlecode.com/svn/repository/com/google/google/1/google-1.pom
>
> Looks pretty easy to set up. About maintaining it, I don't mind doing
> "mvn deploy" once in a while, but some kind of update policy should
> probably be worked out in any case.
Then have at it. It sounds like it would be worthwhile setting up.
--
Shawn.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Newbie questions regarding jgit
2008-11-11 23:11 ` Shawn O. Pearce
@ 2008-11-12 2:24 ` Imran M Yousuf
0 siblings, 0 replies; 15+ messages in thread
From: Imran M Yousuf @ 2008-11-12 2:24 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Jonas Fonseca, Farrukh Najmi, git
On Wed, Nov 12, 2008 at 5:11 AM, Shawn O. Pearce <spearce@spearce.org> wrote:
> Jonas Fonseca <jonas.fonseca@gmail.com> wrote:
>>
>> I don't think admin rights are necessary as long as I have
>> "commit"/webdav access. And no svn or git-svn interaction should be
>> needed to upload to the maven repository.
>>
>> Take a look at the distributionManagement section of the
>> google-maven-repository:
>>
>> - http://google-maven-repository.googlecode.com/svn/repository/com/google/google/1/google-1.pom
>>
>> Looks pretty easy to set up. About maintaining it, I don't mind doing
>> "mvn deploy" once in a while, but some kind of update policy should
>> probably be worked out in any case.
>
> Then have at it. It sounds like it would be worthwhile setting up.
>
This idea is cool!
> --
> Shawn.
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Imran M Yousuf
Entrepreneur & Software Engineer
Smart IT Engineering
Dhaka, Bangladesh
Email: imran@smartitengineering.com
Blog: http://imyousuf-tech.blogs.smartitengineering.com/
Mobile: +880-1711402557
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Newbie questions regarding jgit
2008-11-11 22:01 ` Jonas Fonseca
2008-11-11 23:11 ` Shawn O. Pearce
@ 2008-11-12 12:51 ` Farrukh Najmi
1 sibling, 0 replies; 15+ messages in thread
From: Farrukh Najmi @ 2008-11-12 12:51 UTC (permalink / raw)
To: git
The jgit team, rocks! You guys are simply awesome in your
responsiveness. Thanks for a great project.
Please let me know if I can help with any maven related issues. Here is
a couple of
links I use to evangelize use of maven in OS projects:
Why Maven Rocks:
<http://farrukhnajmi.blogspot.com/2008/02/why-maven-rocks-in-beginning-there-was.html>
Why Maven - Wiki Page:
<http://ebxmlrr.wiki.sourceforge.net/whymaven>
Here are the main resources I use as reference for maven:
Maven Official Docs:
<http://maven.apache.org/guides/index.html>
Better Builds With Maven:
<http://www.topazproject.org/trac/attachment/wiki/MavenInfo/BetterBuildsWithMaven.pdf?format=raw>
I think it is great that the project supports maven at least partially
today.
I would suggest the project consider maven for all its
build/configuration management at some point in future.
It takes a little learning curve initially (most for dev team members
not users) but pays off handsomely very quickly.
Jonas Fonseca wrote:
...
> On Tue, Nov 11, 2008 at 22:44, Shawn O. Pearce <spearce@spearce.org> wrote:
>
>> Jonas Fonseca <jonas.fonseca@gmail.com> wrote:
>>
>>> I would also like to have a public available maven repository for
>>> JGit. If Shawn or Robin acks, I can look into hosting one in the SVN
>>> area of the Google Code project page. Given the lack of a real release
>>> cycle it probably only makes sense to have a snapshot repository.
>>>
...
--
Regards,
Farrukh Najmi
Web: http://www.wellfleetsoftware.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Newbie questions regarding jgit
2008-11-11 21:37 ` Jonas Fonseca
2008-11-11 21:44 ` Shawn O. Pearce
@ 2008-11-12 14:05 ` Farrukh Najmi
2008-11-12 14:33 ` Farrukh Najmi
1 sibling, 1 reply; 15+ messages in thread
From: Farrukh Najmi @ 2008-11-12 14:05 UTC (permalink / raw)
To: Jonas Fonseca; +Cc: git
Jonas Fonseca wrote:
...
>
>> Now I am wondering where to begin to learn how to do the equivalent of the
>> following commands via the gjit Java API:
>>
>> * git add /file/
>> * git rm /file/
>> * git mv /file
>> * Whatever is the git way to get a specific version of a file
>>
>
> JGit currently has two APIs for working with the index, which will
> allow you to add, remove and move data around in the tree. In nbgit I
> ended up using GitIndex, which I found easier to figure out. As I
> understand it, in the long run you want to use the DirCache API, but
> it is still a work in progress.
>
I am happy to use GitIndex now and switch to DirCache API later when it
is ready.
Can I please get some pseudo-code fragments on how to do the use cases I
identified above?
The javadoc is still not obvious to me.
>
>> I am hoping that there aremore docs, samples, tutorials etc. somewhere that
>> I am missing. Thanks for any help you can provide. Some pointers or code
>> fragments would be terrific.
>>
>
> I started working on a tutorial for JGit, but didn't get very far so
> it mostly consists of stub pages.
>
> - http://code.google.com/docreader/#p=egit&s=egit&t=JGitTutorial
>
> I have been working on moving the tutorial to maven project before
> starting to write the more code heavy topics. This would make it
> possible to include code snippets in the tutorial, while also allowing
> to compile and test the examples.
>
The wiki is an awesome resource even in its current state. Thank you.
I would be glad to help contribute improvements to wiki if you give me
write privilege. What I could do is take the help I get from the list and
then update wiki carefully as appropriate if you want me to help.
Thanks again to all of you for helping get me bootstrapped with gjit and
git.
--
Regards,
Farrukh Najmi
Web: http://www.wellfleetsoftware.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Newbie questions regarding jgit
2008-11-12 14:05 ` Farrukh Najmi
@ 2008-11-12 14:33 ` Farrukh Najmi
2008-11-12 17:56 ` Farrukh Najmi
0 siblings, 1 reply; 15+ messages in thread
From: Farrukh Najmi @ 2008-11-12 14:33 UTC (permalink / raw)
To: Jonas Fonseca; +Cc: git
BTW, the context for what I am doing is as follows. I am implementing
OASIS ebXML Registry/Repository (RegRep) 4 specs:
<http://www.oasis-open.org/committees/download.php/29972>
I would like to use git for the Repository part of the RegRep while a
relational database will hold the registry part which contains extensive
metadata about repository files. Later I will also evaluate if I can
somehow use git for the Registry part so I can leverage versioning
features of git. I would still need to have the Registry content
duplicated in relational database to support querying of the metadata.
The standard eventually needs to support CheckIn/Checkout and I think a
distributed VCS like git would be very helpful in an implementation.
For those unfamiliar with RegRep as a technology think of it as
providing added value on top of a generic VCS, database or Content
Management system.
For my immediate needs, I need to implement a GitRepository class with
two methods using gjit as shown below. I would appreciate any guidance
and pseudo-code examples on how to implement these methods. Please keep
in mind that I am just getting to know git itself and gjit was key to my
considering git over Mercurial and other distributed VCSs.
public class GitRepositoryManager {
Repository gitRepo;
...
/**
* Gets the content of specified file in git Repo.
*
* @parameter relativePath the relative path in jitRepo for desired
file to get
* @parameter versionName the versionName for the desired file. It
will be unmarshalled from String to ObjectId.
* @return the content of the desired file version packaged as a
DataHandler.
*/
public DataHandler get(String relativePath, String versionName)
throws RepositoryException {
DataHandler dh = null;
...
return dh;
}
/**
* Creates a new version of specified version of file in git Repo.
*
* @parameter relativePath the relative path in jitRepo for desired
file to get
* @parameter versionName the versionName for the desired file. It
will be unmarshalled from String to ObjectId.
* @parameter content the content of the new version for specified
file packaged as a DataHandler.
*/
public void update(String relativePath, String versionName,
DataHandler content) throws RepositoryException {
...
}
}
Farrukh Najmi wrote:
> Jonas Fonseca wrote:
> ...
>>
>>> Now I am wondering where to begin to learn how to do the equivalent
>>> of the
>>> following commands via the gjit Java API:
>>>
>>> * git add /file/
>>> * git rm /file/
>>> * git mv /file
>>> * Whatever is the git way to get a specific version of a file
>>>
>>
>> JGit currently has two APIs for working with the index, which will
>> allow you to add, remove and move data around in the tree. In nbgit I
>> ended up using GitIndex, which I found easier to figure out. As I
>> understand it, in the long run you want to use the DirCache API, but
>> it is still a work in progress.
>>
>
> I am happy to use GitIndex now and switch to DirCache API later when
> it is ready.
> Can I please get some pseudo-code fragments on how to do the use cases
> I identified above?
> The javadoc is still not obvious to me.
>>
>>> I am hoping that there aremore docs, samples, tutorials etc.
>>> somewhere that
>>> I am missing. Thanks for any help you can provide. Some pointers or
>>> code
>>> fragments would be terrific.
>>>
>>
>> I started working on a tutorial for JGit, but didn't get very far so
>> it mostly consists of stub pages.
>>
>> - http://code.google.com/docreader/#p=egit&s=egit&t=JGitTutorial
>>
>> I have been working on moving the tutorial to maven project before
>> starting to write the more code heavy topics. This would make it
>> possible to include code snippets in the tutorial, while also allowing
>> to compile and test the examples.
>>
>
> The wiki is an awesome resource even in its current state. Thank you.
> I would be glad to help contribute improvements to wiki if you give me
> write privilege. What I could do is take the help I get from the list and
> then update wiki carefully as appropriate if you want me to help.
>
> Thanks again to all of you for helping get me bootstrapped with gjit
> and git.
>
--
Regards,
Farrukh Najmi
Web: http://www.wellfleetsoftware.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Newbie questions regarding jgit
2008-11-12 14:33 ` Farrukh Najmi
@ 2008-11-12 17:56 ` Farrukh Najmi
2008-11-12 18:30 ` Jonas Fonseca
2008-11-12 19:29 ` Shawn O. Pearce
0 siblings, 2 replies; 15+ messages in thread
From: Farrukh Najmi @ 2008-11-12 17:56 UTC (permalink / raw)
To: git
So far I have figured out how to get the treeWalk for the path filter as
shown below.
Now I am lost as to how to get the blob associated with the treeWalk.
TIA for your help.
/**
* Gets the content of specified file in git Repo.
*
* @parameter relativePath the relative path in jitRepo for desired
file to get
* @parameter versionName the versionName for the desired file. It
will be unmarshalled from String to ObjectId.
* @return the content of the desired file version packaged as a
DataHandler.
*/
public DataHandler get(String relativePath, String versionName)
throws RepositoryException {
ObjectId retrieveStart = repository.resolve(versionName);
RevWalk revWalk = new RevWalk(repository);
RevCommit entry = revWalk.parseCommit(retrieveStart);
RevTree revTree = entry.getTree();
TreeWalk treeWalk = TreeWalk.forPath(repository,
relativePath, revTree);
//Not sure how to get the blob next
}
Farrukh Najmi wrote:
....
> For my immediate needs, I need to implement a GitRepository class with
> two methods using gjit as shown below. I would appreciate any guidance
> and pseudo-code examples on how to implement these methods. Please
> keep in mind that I am just getting to know git itself and gjit was
> key to my considering git over Mercurial and other distributed VCSs.
>
> public class GitRepositoryManager {
>
> Repository gitRepo;
>
> ...
>
> /**
> * Gets the content of specified file in git Repo.
> *
> * @parameter relativePath the relative path in jitRepo for
> desired file to get
> * @parameter versionName the versionName for the desired file. It
> will be unmarshalled from String to ObjectId.
> * @return the content of the desired file version packaged as a
> DataHandler.
> */
> public DataHandler get(String relativePath, String versionName)
> throws RepositoryException {
> DataHandler dh = null;
>
> ...
> return dh;
> }
>
> /**
> * Creates a new version of specified version of file in git Repo.
> *
> * @parameter relativePath the relative path in jitRepo for
> desired file to get
> * @parameter versionName the versionName for the desired file. It
> will be unmarshalled from String to ObjectId.
> * @parameter content the content of the new version for specified
> file packaged as a DataHandler.
> */
> public void update(String relativePath, String versionName,
> DataHandler content) throws RepositoryException {
> ...
> }
>
> }
>
> Farrukh Najmi wrote:
>> Jonas Fonseca wrote:
>> ...
>>>
>>>> Now I am wondering where to begin to learn how to do the equivalent
>>>> of the
>>>> following commands via the gjit Java API:
>>>>
>>>> * git add /file/
>>>> * git rm /file/
>>>> * git mv /file
>>>> * Whatever is the git way to get a specific version of a file
>>>>
>>>
>>> JGit currently has two APIs for working with the index, which will
>>> allow you to add, remove and move data around in the tree. In nbgit I
>>> ended up using GitIndex, which I found easier to figure out. As I
>>> understand it, in the long run you want to use the DirCache API, but
>>> it is still a work in progress.
>>>
>>
>> I am happy to use GitIndex now and switch to DirCache API later when
>> it is ready.
>> Can I please get some pseudo-code fragments on how to do the use
>> cases I identified above?
>> The javadoc is still not obvious to me.
>>>
>>>> I am hoping that there aremore docs, samples, tutorials etc.
>>>> somewhere that
>>>> I am missing. Thanks for any help you can provide. Some pointers or
>>>> code
>>>> fragments would be terrific.
>>>>
>>>
>>> I started working on a tutorial for JGit, but didn't get very far so
>>> it mostly consists of stub pages.
>>>
>>> - http://code.google.com/docreader/#p=egit&s=egit&t=JGitTutorial
>>>
>>> I have been working on moving the tutorial to maven project before
>>> starting to write the more code heavy topics. This would make it
>>> possible to include code snippets in the tutorial, while also allowing
>>> to compile and test the examples.
>>>
>>
>> The wiki is an awesome resource even in its current state. Thank you.
>> I would be glad to help contribute improvements to wiki if you give me
>> write privilege. What I could do is take the help I get from the list
>> and
>> then update wiki carefully as appropriate if you want me to help.
>>
>> Thanks again to all of you for helping get me bootstrapped with gjit
>> and git.
>>
>
>
--
Regards,
Farrukh Najmi
Web: http://www.wellfleetsoftware.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Newbie questions regarding jgit
2008-11-12 17:56 ` Farrukh Najmi
@ 2008-11-12 18:30 ` Jonas Fonseca
2008-11-12 19:29 ` Shawn O. Pearce
1 sibling, 0 replies; 15+ messages in thread
From: Jonas Fonseca @ 2008-11-12 18:30 UTC (permalink / raw)
To: Farrukh Najmi; +Cc: git
On Wed, Nov 12, 2008 at 18:56, Farrukh Najmi
<farrukh@wellfleetsoftware.com> wrote:
> So far I have figured out how to get the treeWalk for the path filter as
> shown below.
> Now I am lost as to how to get the blob associated with the treeWalk. TIA
> for your help.
For ideas take a look at how the NetBeans git plugin accomplishes some
of the most common git tasks take a look at the GitCommand.java file.
It contains code for adding and removing files, committing updates to
the index. There is also some code trying to get "git-status"
information, but it is not very smart or clean. Something equivalent
to "git cat-file" (getting the blob data) can be seen at line 120:
- http://github.com/myabc/nbgit/tree/master/src/org/nbgit/util/GitCommand.java#L120
Sorry, I should have suggested this earlier.
--
Jonas Fonseca
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Newbie questions regarding jgit
2008-11-12 17:56 ` Farrukh Najmi
2008-11-12 18:30 ` Jonas Fonseca
@ 2008-11-12 19:29 ` Shawn O. Pearce
1 sibling, 0 replies; 15+ messages in thread
From: Shawn O. Pearce @ 2008-11-12 19:29 UTC (permalink / raw)
To: Farrukh Najmi; +Cc: git
Farrukh Najmi <farrukh@wellfleetsoftware.com> wrote:
>
> So far I have figured out how to get the treeWalk for the path filter as
> shown below.
> Now I am lost as to how to get the blob associated with the treeWalk.
> TIA for your help.
>
> /**
> * Gets the content of specified file in git Repo.
> *
> * @parameter relativePath the relative path in jitRepo for desired
> file to get
> * @parameter versionName the versionName for the desired file. It
> will be unmarshalled from String to ObjectId.
> * @return the content of the desired file version packaged as a
> DataHandler.
> */
> public DataHandler get(String relativePath, String versionName) throws
> RepositoryException {
> ObjectId retrieveStart = repository.resolve(versionName);
> RevWalk revWalk = new RevWalk(repository);
> RevCommit entry = revWalk.parseCommit(retrieveStart);
> RevTree revTree = entry.getTree();
>
> TreeWalk treeWalk = TreeWalk.forPath(repository,
> relativePath, revTree);
>
> //Not sure how to get the blob next
if (treeWalk.next()) {
// Path exists
if (treeWalk.getFileMode(0).getObjectType() == Constants.OBJ_BLOB) {
ObjectId blob = treeWalk.getObjectId(0);
} else {
// Not a blob, its something else (tree, gitlink)
}
} else {
// Path not found
}
--
Shawn.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Newbie questions regarding jgit
@ 2008-11-12 22:36 Robin Rosenberg
0 siblings, 0 replies; 15+ messages in thread
From: Robin Rosenberg @ 2008-11-12 22:36 UTC (permalink / raw)
To: Farrukh Najmi; +Cc: git
(resend without HTML)
tisdag 11 november 2008 22:12:58 skrev Farrukh Najmi:
>
> I should clarify that I am not using eclipse nor am I using any GUI. My
> objective is to have Java API access to git from within a servlet using
> jgit. At present, all I have to go on is javadoc and its not clear where
> to begin if I simply wish to create, read and update files in a git repo
> from within the servlet java code.
>
We do not have a tutorial. The JUnit tests are the best examples on
how to use the API today. I did some experiement wit J2EE and created
some jsp tags, but that's for JSP only and mostly experimental. To
comply with the JEE spec one should create a resource manager for
Git to deal with scalability when many users try to access repos.
> > I am git newbie and looking to use jgit in a servlet endpoint.
> >
> > Where can I find a public maven repo for gjit? It seems there is one
> > somewhere because of the following file in src tree:
> >
> > jgit-maven/jgit/pom.xml
We do not use maven ourselves right now, though that might change, so
there is not public maven repository for jgit just yet. What do I need to
do to set it up?
> >
> > For now I have built the jar using /make_jgit.sh and installed the pom
> > manually using m
> >
> > mvn install:install-file -DpomFile=jgit-maven/jgit/pom.xml
> > -Dfile=jgit.jar
The pom.xml works for building jgit. cd to the mave dir and type mvn
and watch it build (and run unit tests if you ask it to).
-- robin
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Newbie questions regarding jgit
@ 2008-11-12 22:37 Robin Rosenberg
0 siblings, 0 replies; 15+ messages in thread
From: Robin Rosenberg @ 2008-11-12 22:37 UTC (permalink / raw)
To: Jonas Fonseca; +Cc: Farrukh Najmi, git
(resend without HTML)
tisdag 11 november 2008 22:37:40 skrev Jonas Fonseca:
> On Tue, Nov 11, 2008 at 21:44, Farrukh Najmi
> <farrukh@wellfleetsoftware.com> wrote:
> > Hi all,
>
> Hello,
>
> > I am git newbie and looking to use jgit in a servlet endpoint.
>
> Sounds interesting. I have been thinking about how hard it would be to
> write a very simpe jgitweb kind of thing and am very interested to
> hear more about your experiences.
Consider this:
http://www.jgit.org/cgi-bin/gitweb/gitweb.cgi?p=EGIT-jee.git;a=shortlog;h=rr/jeegitweb
It's an toy experiment with taglibs. Unfortunately the JSP doesn't even compile (!) anymore,
maybe someone can spot the error. Something very close to this did work a while ago.
The example jsp is here:
http://www.jgit.org/cgi-bin/gitweb/gitweb.cgi?p=EGIT-jee.git;a=blob;f=org.spearce.jeegit web/WebContent/index.jsp;h=d065d9f5a725a161a640e58e3be4d5b3a0666b5e;hb=fabffb50f0a020ff9b1653c090675bbd56dcc80a
-- robin
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2008-11-12 22:39 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-12 22:36 Newbie questions regarding jgit Robin Rosenberg
-- strict thread matches above, loose matches on Subject: below --
2008-11-12 22:37 Robin Rosenberg
2008-11-11 20:44 Farrukh Najmi
2008-11-11 21:12 ` Farrukh Najmi
2008-11-11 21:37 ` Jonas Fonseca
2008-11-11 21:44 ` Shawn O. Pearce
2008-11-11 22:01 ` Jonas Fonseca
2008-11-11 23:11 ` Shawn O. Pearce
2008-11-12 2:24 ` Imran M Yousuf
2008-11-12 12:51 ` Farrukh Najmi
2008-11-12 14:05 ` Farrukh Najmi
2008-11-12 14:33 ` Farrukh Najmi
2008-11-12 17:56 ` Farrukh Najmi
2008-11-12 18:30 ` Jonas Fonseca
2008-11-12 19:29 ` Shawn O. Pearce
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).