Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] jgit problems with Github and Amazon S3

Sorry if this is not the right place to communicate but I couldn't find an obviously better alternative.

I have started developing a small application that uses jgit to store some data in a git repository and have had a couple of problems (which took a great deal of investigation and debugging) which I eventually found resolutions to but which I thought I would communicate to you so that you either can make some changes or someone else may happen upon this email archive in a google search and be helped.

Firstly I would suggest a few more examples in the user guide. jgit does not seem to always default unspecified values in the same way git does so it took me a bit of trial and error to figure out which setters to call eg git push has default of "master" but jgit requires a call to setRefSpecs() to specify "master" ie git.push().setRefSpecs(new RefSpec("master")).call()

Secondly, when jgit is used in a standalone manner (ie outside egit) there is no CredentialsProvider in the distributed jgit jar that supports a connection to GitHub that uses an encrypted ssh private key (which I think is the standard way of working with Github).   The git source code repositories for jgit include a few more packages (eg org.eclipse.jgit.console and org.eclipse.jgit.ui) that are not in the distributed jars and these provided the example I needed (ie ConsoleCredentialsProvider) to get a push working to github.  Once I provided my own CredentialsProvider that provided a get() method that supported CredentialItem.StringType and returned the passphrase that was encrypting the private key then I was able to get a push to github working: ie git.push().setRemote("githubrepo").setRefSpecs(new RefSpec("master")).setCredentialsProvider(new MyCredentialsProvider()).call().   So I would suggest a EncryptedPrivateKeySshCredentialsProvider with an abstract getPassphrase() be put into org.eclipse.jgit.transport along with a small example in the users guide.

Thirdly I found what I think is a bug introduced in jgit 0.11.x that causes the initial push to an Amazon S3 "repository" to be incomplete (ie only the refs and info directories are created).  jgit 0.10.1 works properly but jgit 0.11.3 does not.  My investigation narrowed this down to PackWriter.getObjectsNumber().  In 0.11.3 it has been changed to use stats.totalObjects but when PackWriter.getObjectsNumber() is called in WalkPushConnection.sendpack() the stats.totalObjects value hasn't been set yet (it only seems to get set in PackWriter.writePack())

Keep up the good work.  Without jgit I would have to have an installation of git as a dependency on my application so I appreciate what you have achieved so far and your efforts to continuously improve it.

Bryan.

Back to the top