diff options
| author | Vicent Martà <vicent@github.com> | 2012-12-17 03:17:16 -0800 |
|---|---|---|
| committer | Vicent Martà <vicent@github.com> | 2012-12-17 03:17:16 -0800 |
| commit | 69a402d46c5cee6a09499cf763202dfad2004e95 (patch) | |
| tree | 29e7256c4ca192952944ccef190f3308a1ab66e5 /src | |
| parent | 71131b550904824a047d41c7da174686202abd6a (diff) | |
| parent | c4e3e797d11bf7d8a9873a193e182d2537b0ee6a (diff) | |
| download | libgit2-69a402d46c5cee6a09499cf763202dfad2004e95.tar.gz | |
Merge pull request #1141 from ben/clone-empty-repo
Allow clone to handle empty repos
Diffstat (limited to 'src')
| -rw-r--r-- | src/transports/local.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/transports/local.c b/src/transports/local.c index 53b24947c..c6c95ce75 100644 --- a/src/transports/local.c +++ b/src/transports/local.c @@ -42,6 +42,7 @@ static int add_ref(transport_local *t, const char *name) git_remote_head *head; git_object *obj = NULL, *target = NULL; git_buf buf = GIT_BUF_INIT; + int error; head = git__calloc(1, sizeof(git_remote_head)); GITERR_CHECK_ALLOC(head); @@ -49,10 +50,17 @@ static int add_ref(transport_local *t, const char *name) head->name = git__strdup(name); GITERR_CHECK_ALLOC(head->name); - if (git_reference_name_to_id(&head->oid, t->repo, name) < 0) { + error = git_reference_name_to_id(&head->oid, t->repo, name); + if (error < 0) { git__free(head->name); git__free(head); - return -1; + if (!strcmp(name, GIT_HEAD_FILE) && error == GIT_ENOTFOUND) { + /* This is actually okay. Empty repos often have a HEAD that points to + * a nonexistent "refs/heads/master". */ + giterr_clear(); + return 0; + } + return error; } if (git_vector_insert(&t->refs, head) < 0) |
