threads / discuss / 13311

Git Library?

Subject: Git Library?

## tl;dr

8 messages between Apr 28, 2008 and Apr 29, 2008.

replies: 7people: 5as markdown or json

Patrick Altman· Apr 28, 2008, 18:55 UTC · lore
I want to write a Mac OSX UI for git.

Is there a documented/undocumented API for interacting with git in process? Or would I be better off "shelling out" to the git command line?

Thanks, Patrick Altman

--- Patrick Altman (615) 300-2930

Johannes Schindelin· Apr 28, 2008, 19:10 UTC · re: Patrick Altman · lore

Re: Git Library?

Hi,
On Mon, 28 Apr 2008, Patrick Altman wrote:
> I want to write a Mac OSX UI for git.
> 
> Is there a documented/undocumented API for interacting with git in process?
> Or would I be better off "shelling out" to the git command line?

There was a mail thread yesterday on exactly the same subject. Bottom line: the recommended way is to fork()&&exec(), because I am sure you do not want to put in the work to make libgit.a reentrant.

Ciao, Dscho

Jakub Narebski· Apr 28, 2008, 21:08 UTC · re: Patrick Altman · lore

Re: Git Library?

Patrick Altman <paltman@gmail.com> writes:
> I want to write a Mac OSX UI for git.
Something like GitNub?
 
> Is there a documented/undocumented API for interacting with git in
> process?  Or would I be better off "shelling out" to the git command
> line?
Take a look how other GUIs does it.
-- 
Jakub Narebski
Poland
ShadeHawk on #git
Patrick Altman· Apr 28, 2008, 21:17 UTC · re: Jakub Narebski · lore

Re: Git Library?

On Apr 28, 2008, at 4:08 PM, Jakub Narebski wrote:
Show 5 quoted lines
> Patrick Altman <paltman@gmail.com> writes:
>
>> I want to write a Mac OSX UI for git.
>
> Something like GitNub?

Not really. GitNub is really an interface for GitHub. I am thinking something more like ZigVersion, http://zigzig.com/, for Git instead of Subversion.

Show 5 quoted lines
>> Is there a documented/undocumented API for interacting with git in
>> process?  Or would I be better off "shelling out" to the git command
>> line?
>
> Take a look how other GUIs does it.

git-gui is written in TCL I believe, which I do not want to use. GitNub is the only other GUI of sorts that i am aware of but like I mentioned above, that really is more of a GitHub interface and less of a git interface.

I think that this point I am just going to use NTask and the like in Cocoa/Objective-C to wrap the command line utilities.

Thanks, Patrick

Jakub Narebski· Apr 28, 2008, 22:01 UTC · re: Patrick Altman · lore

Re: Git Library?

On Mon, 28 Apr 2008, Patrick Altman wrote:
Show 10 quoted lines
> On Apr 28, 2008, at 4:08 PM, Jakub Narebski wrote:
>> Patrick Altman <paltman@gmail.com> writes:
>>
>>> I want to write a Mac OSX UI for git.
>>
>> Something like GitNub?
> 
> Not really.  GitNub is really an interface for GitHub.  I am thinking  
> something more like ZigVersion, http://zigzig.com/, for Git instead of  
> Subversion.
Well, I thought that GitNub is something similar to gitk, i.e. it is
history browser, but in Ruby/Cocoa instead of Tcl/Tk.
 
Show 10 quoted lines
>>> Is there a documented/undocumented API for interacting with git in
>>> process?  Or would I be better off "shelling out" to the git command
>>> line?
>>
>> Take a look how other GUIs does it.
> 
> git-gui is written in Tcl I believe, which I do not want to use.
> GitNub is the only other GUI of sorts that i am aware of but like I  
> mentioned above, that really is more of a GitHub interface and less of  
> a git interface.

Take a look at http://git.or.cz/gitwiki/InterfacesFrontendsAndTools page: there is a list of GUIs there. There is gitk and git-gui, there is QGit and varipus PyQt GUIs, there is Giggle, there is tig.

> I think that this point I am just going to use NTask and the like in  
> Cocoa/Objective-C to wrap the command line utilities.
I think best would be to see how QGit does it...
-- 
Jakub Narebski
Poland
David Symonds· Apr 28, 2008, 22:09 UTC · re: Patrick Altman · lore

Re: Git Library?

On Tue, Apr 29, 2008 at 7:17 AM, Patrick Altman <paltman@gmail.com> wrote:
>  I think that this point I am just going to use NTask and the like in
> Cocoa/Objective-C to wrap the command line utilities.

That's the way I approached it when I started doing a half-hearted attempt at exactly what you're proposing. Clone my (small) rough code from http://git.symonds.id.au/macgit.git

Dave.
David Aguilar· Apr 29, 2008, 06:58 UTC · re: Patrick Altman · lore

Re: Git Library?

On Mon, Apr 28, 2008 at 11:55 AM, Patrick Altman <paltman@gmail.com> wrote:
> I want to write a Mac OSX UI for git.
>

git gui works on OSX. Aside from that, someone's already written one* :-)

    http://repo.or.cz/ugit.git
    http://ugit.sf.net/
>  Is there a documented/undocumented API for interacting with git in process?
> Or would I be better off "shelling out" to the git command line?
Fork/exec.
If you grabbed the ugit modules you could say:
    from ugit import git
    revisions = git.rev_list(all=True).splitlines()
    file = open('msg', 'w')
    file.write("commit message." )
    file.close()
    git.commit(F='msg', s=True)
    etc, etc.

It's pretty much 90%+ of git wrapped in Python. If a libgit.so did appear one day it would be trivial to swap out the meta-functions in git.py and replace them with e.g. swig replacements. Until then, forking out works just fine.

stg also has Python wrapped around git so you could look there too.
-- 
 David


* - okay, I lied. It's PyQt4.  But it does run on OSX and looks just
like any other cocoa app.

← back to recent threads