Permalink
Browse files

Add a clone function for Repository

clone options not supported
  • Loading branch information...
sa1 committed Sep 8, 2013
1 parent 7a4adbd commit eb5c5a29d62ce098c597ef9ebd842bfcb009ab76
Showing with 32 additions and 5 deletions.
  1. +14 −1 src/parrotgit.c
  2. +2 −1 src/parrotgit.nci
  3. +2 −0 src/parrotgit.pir
  4. +14 −3 t/winxed/001_load.t
View
@@ -153,7 +153,20 @@ git_tag * tag_lookup(git_repository * repo, const git_oid * oid){
int ret;
ret = git_tag_lookup(&tag, repo, oid);
if (ret < 0){
- fprintf(stderr, "Error in tag lookup: % d\n", ret);
+ fprintf(stderr, "Error in tag lookup.\n");
}
return tag;
}
+
+git_repository * clone(const char * url, const char * path){
+ // Clone options not supported for now.
+ git_repository *cloned_repo = NULL;
+ int ret;
+ ret = git_clone(&cloned_repo, url, path, NULL);
+ if (ret < 0){
+ const git_error *err = giterr_last();
+ if (err) printf("ERROR %d: %s\n", err->klass, err->message);
+ else printf("ERROR %d: no detailed info\n", ret);
+ }
+ return cloned_repo;
+}
View
@@ -21,4 +21,5 @@ p blob_lookup pp
p remote_create ppp
p revparse_single pp
p object_lookup pp
-p tag_lookup pp
+p tag_lookup pp
+p clone pp
View
@@ -33,4 +33,6 @@
set_global ['Git2';'Git'], 'object_lookup', nci
dlfunc nci, lib, 'tag_lookup', 'ppp'
set_global ['Git2';'Git'], 'tag_lookup', nci
+ dlfunc nci, lib, 'clone', 'ppp'
+ set_global ['Git2';'Git'], 'clone', nci
.end
View
@@ -114,6 +114,17 @@ class Test_git2_repository_open {
repo.free();
}
+ function clone_repo(){
+ using Git2.Repository;
+
+ var repo = new Repository;
+ repo.clone("https://github.com/letolabs/parrot-libgit2.git", "/tmp/parrot");
+ int rc1 = repo.is_empty();
+ self.assert.equal(rc1, 0);
+ repo.free();
+ //TODO: remove cloned directory
+ }
+
function show_branch(){
using Git2.Git.repo_head;
using Git2.Raw.git_reference_name;
@@ -134,12 +145,12 @@ class Test_git2_repository_open {
self.assert.equal(j, 0);
}
- function git_index() {
+ function index() {
var git_index = new Git2.Index;
self.assert.instance_of(git_index, class Git2.Index);
}
- function git_oid() {
+ function oid() {
using Git2.Oid;
var git_oid = new Git2.Oid();
@@ -151,7 +162,7 @@ class Test_git2_repository_open {
self.assert.defined(git_oid);
}
- function git_commit(){
+ function commit(){
using Git2.Commit;
using Git2.Repository;
using Git2.Oid;

0 comments on commit eb5c5a2

Please sign in to comment.