Commit b524fe1a by Ben Straub

Local Only ignore ENOTFOUNDs when adding corrupted refs

parent 850b1edf
...@@ -177,7 +177,7 @@ static int loose_parse_oid(git_oid *oid, git_buf *file_content) ...@@ -177,7 +177,7 @@ static int loose_parse_oid(git_oid *oid, git_buf *file_content)
corrupted: corrupted:
giterr_set(GITERR_REFERENCE, "Corrupted loose reference file"); giterr_set(GITERR_REFERENCE, "Corrupted loose reference file");
return -1; return GIT_ENOTFOUND;
} }
static git_ref_t loose_guess_rtype(const git_buf *full_path) static git_ref_t loose_guess_rtype(const git_buf *full_path)
......
...@@ -42,6 +42,7 @@ static int add_ref(transport_local *t, const char *name) ...@@ -42,6 +42,7 @@ static int add_ref(transport_local *t, const char *name)
git_remote_head *head; git_remote_head *head;
git_object *obj = NULL, *target = NULL; git_object *obj = NULL, *target = NULL;
git_buf buf = GIT_BUF_INIT; git_buf buf = GIT_BUF_INIT;
int error;
head = git__calloc(1, sizeof(git_remote_head)); head = git__calloc(1, sizeof(git_remote_head));
GITERR_CHECK_ALLOC(head); GITERR_CHECK_ALLOC(head);
...@@ -49,12 +50,17 @@ static int add_ref(transport_local *t, const char *name) ...@@ -49,12 +50,17 @@ static int add_ref(transport_local *t, const char *name)
head->name = git__strdup(name); head->name = git__strdup(name);
GITERR_CHECK_ALLOC(head->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);
/* This is actually okay. Empty repos often have a HEAD that points to if (error < 0) {
* a nonexistant "refs/haeds/master". */
git__free(head->name); git__free(head->name);
git__free(head); git__free(head);
return 0; if (error == GIT_ENOTFOUND) {
/* This is actually okay. Empty repos often have a HEAD that points to
* a nonexistant "refs/haeds/master". */
giterr_clear();
return 0;
}
return error;
} }
if (git_vector_insert(&t->refs, head) < 0) if (git_vector_insert(&t->refs, head) < 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment