librelist archives

« back to archive

go-git: first commit after init

go-git: first commit after init

From:
Mike Rosset
Date:
2011-05-17 @ 06:12
Hello all,

I've been slowing hacking away  on go-git "go language bindings". So
far I've made good progress.

But I can not figure out how to make an initial commit without using
git-git proper. If someone knows of some example code or possible
point me to some code in the test framework, it would be quite
helpful.

Regards,

Mike

Re: [libgit2] go-git: first commit after init

From:
Carlos Martín Nieto
Date:
2011-05-17 @ 10:44
On Mon, May 16, 2011 at 11:12:00PM -0700, Mike Rosset wrote:
> Hello all,
> 
> I've been slowing hacking away  on go-git "go language bindings". So
> far I've made good progress.
> 
> But I can not figure out how to make an initial commit without using
> git-git proper. If someone knows of some example code or possible
> point me to some code in the test framework, it would be quite
> helpful.

If you're using the 0.12.0 release and HEAD points to your as-of-yet
non-existant branch, you can pass "HEAD" to git_commit_create (the
update_ref parameter). Creating the branch passed as update_ref is not
supported currently, so if you don't want to update HEAD or have to
use an earlier version, you'd have to "just" create the commit (pass
NULL as update_ref) and you can then create an OID ref which points to
that commit.

In tests/t04-commit.c there is a test for that.

Cheers,
   cmn