views:

854

answers:

6

Is it possible to embed git in the iPhone app? Only in a passive mode, i.e. to be able to read commit messages (with date and user) and diffs given some online git repository in order to present it in some readable table views?

+7  A: 

It would be easier to write a webapp that generated iPhone specific formatted output. Anything is possible on the iPhone (backgrounding not included), but to get an App on it you have to pay the $99 to join the club and then run the gauntlet of the Approval Process. A web app doesn't have to be approved by anyone.

fuzzy lollipop
+5  A: 

It would be possible if you could statically compile the required git functions into your executable. It would require cloning the repository to the device’s disk though.

I’m not sure what your use-case is, but using a hosted website such as GitHub, or making your own web service if that is not possible, would likely be more sensible.

Ciarán Walsh
+2  A: 

Not sure if this github client for iphone would offer any pointers

http://github.com/schacon/igithub/

Surya
+6  A: 

I'm one of the co-authors of cocoagit, which is currently an unfinished implementation of the core git functionality in Objective-C. There has not been much activity in the last 6 months. Unfortunately, it is not far quite far enough along to do everything you need. We can read commits, and have preliminary support for cloning repos, but we can't do diffs yet. Geoff and I would both like to have more time to work on it again, but in the meantime, we would gladly welcome any contributions.

Alternatively, I second the recommendations of previous posters to consider using github, or building your own web service to provide the necessary data.

Brian Chapados
I noticed your implementation is MIT licensed. Since Git itself is GPL, have you taken the appropriate steps to avoid "contamination"?
Colin Barrett
Yes. Most of the code was written without ever looking at the git-core C source. Instead, we used all available documentation on git internals, as well as the source for jgit (java implementation - BSD) and grit (Ruby - MIT) as references for implementation details. I have cracked open the C git code a few times to verify some details about how the internal "plumbing" commands work, but in those cases, I've simply taken some notes well in advance of writing any code for cocoagit.
Brian Chapados
+3  A: 

Git (the command-line client) has been ported to jailbroken iPhones.

chpwn
+1  A: 

You've got a couple options:

1) Get git(1) cross compiling for ARM and the iPhone and then embed them. 2) Use Dulwich and write a small tool you can drive with NSTask that does what you need (don't link your code directly to this or copy their implementation -- it's GPL). This is likely easier than option 1. 3) Write a web server which does what you need and then have your iPhone client access this.

It really depends on what you're doing, why you're doing it, and what infrastructure you've already got set up which option will be the best. For instance, if you already have any sort of server component already (e.g. for push notifications) I would recommend option 3.

Colin Barrett
NSTask on iPhoneOS is unsupported.
chpwn
There are plenty of ways to shell out without using NSTask.
Colin Barrett