Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] JGit sample client - starter

On 11 Mar 2010, at 10:17, Karthik K wrote:

On 03/11/2010 02:12 AM, Alex Blewitt wrote:
On 11 Mar 2010, at 10:03, Karthik K wrote:

  
Hi -
 I am trying to use JGit for one of the sample applications - where I am trying to use jgit to connect to a http uri , say  - git://github.com/apache/hbase.git , and retrieve the contents of the same.
Can you help let me know a sample snippet using the jgit library , that I can take as a reference and go through the source tree , to get more. I am looking under org.eclipse.jgit as a starting point, but more pointers  / help related to that would be appreciated. Thanks.
    
There are number of tests that check out a repository. Would any of those help?
Sure - Anything in particular , that does along the lines of retrieving the tree / listing branches and printing it , that you would suggest as a starting point ?

Well, the Http tests might have an example you can use. There's also the org.eclipse.jgit.pgm.Clone command. For example:

final URIish uri = new URIish(sourceUri);
db = new Repository(new File(localName, Constants.DOT_GIT));
db.create();
db.getConfig().setBoolean("core", null, "bare", false);
db.getConfig().save();
saveRemote(uri);
final FetchResult r = runFetch();
final Ref branch = guessHEAD(r);
doCheckout(branch);

By the way, the git:// protocol is different from the http:// protocol, so whilst it's a URI, it's not an HTTP URI.

Oops Sorry . My bad - I meant to type - http://github.com/apache/hbase.git , when  I was referring to the uri.

Also - when you mention about the URI being different,  if a client were to access a http uri to clone a git repository, would it be sufficient to have port 80 open, from the client to access the same. Or - is there a different protocol / port that refers to the same.

The git protocol uses port 9418; http uses 80. Of course these are both defaults, and can be changed. But the git protocol is (generally) more efficient than the Http case.

Having said that, Shawn did some excellent work on the Http protocol to make it almost as fast (if not as fast) as the Git protocol. The problem is that requires the server is running git-http-backend in order to punt the data out. It's still possible to serve over a 'dumb' http server, but it's slower, and it requires that the git-hook 'update-server-info' is run on the remote server.

Alex



Back to the top