git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Using git from Python

From
David Aguilar <davvid@gmail.com>
Date
May 8, 2008, 04:23 UTC
Message-ID
<402731c90805072123g764a3d56ia30035381c0950dd@mail.gmail.com>
In-Reply-To
<87lk2l4fj5.fsf@offby1.atm01.sea.blarg.net>
On Wed, May 7, 2008 at 8:54 PM, Eric Hanchrow <offby1@blarg.net> wrote:
Show 13 quoted lines
>     Asheesh> That's fine ... but since I figured others may have done
>     Asheesh> this also
>
>  As far as I can tell, there is exactly no downside to simply forking a
>  subprocess.  Why are you trying to avoid that?
>
>     Asheesh> raises Exceptions when the git commands fail for some
>     Asheesh> reason.
>
>  If Popen doesn't already raise an exception when the child process
>  fails, then it's surely a simple matter to check the exit code, and
>  raise the exception yourself.
>

There have been many questions about this lately. For the impatient, grab git.py from the python-git directory of the ugit project:

http://repo.or.cz/w/ugit.git?a=tree;f=python-git;h=1ef75cef116ce750b5bdf5dd38a4cf1ab2c1ce79;hb=b393c428cf156a7c5c75b18379676dbb534a76d8
http://repo.or.cz/w/ugit.git

I will work on making git.py a separate python-git project, upload it to pypi, and create a separate repo for it very soon.

The interface is blazingly simple. It is a 1:1 correspondance to the git command line interface. e.g. git.commit(F='/some/path.txt', s=True)

There are many examples in the t/ directory and within the ugit project itself. Let me know offline if you have any questions. The documentation could probably use some work.

-- 
 David
Previous: Eric HanchrowNext: Dill
Message 3 of 7 in “Using git from Python”
  1. Asheesh LaroiaMay 8, 2008
  2. Eric HanchrowMay 8, 2008
  3. David AguilarMay 8, 2008
  4. DillMay 10, 2008
  5. Asheesh LaroiaMay 12, 2008
  6. Steve FrécinauxMay 13, 2008
  7. Steve FrécinauxMay 14, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.