summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2012-12-14 08:35:59 -0800
committerBen Straub <bs@github.com>2012-12-14 13:58:44 -0800
commitb524fe1a3c6033a5a8a64b7d8f9acc5cd3dd90c4 (patch)
tree89f7b606891f74e1dfec3befd6bb6e6757f87462 /src
parent850b1edfe8f04daaec05237e35e74f11600e5b4c (diff)
downloadlibgit2-b524fe1a3c6033a5a8a64b7d8f9acc5cd3dd90c4.tar.gz
Local Only ignore ENOTFOUNDs when adding corrupted refs
Diffstat (limited to 'src')
-rw-r--r--src/refs.c2
-rw-r--r--src/transports/local.c14
2 files changed, 11 insertions, 5 deletions
diff --git a/src/refs.c b/src/refs.c
index 85813096b..df533c95d 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -177,7 +177,7 @@ static int loose_parse_oid(git_oid *oid, git_buf *file_content)
corrupted:
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)
diff --git a/src/transports/local.c b/src/transports/local.c
index 8aeab2975..b5b1dd06d 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,12 +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) {
- /* This is actually okay. Empty repos often have a HEAD that points to
- * a nonexistant "refs/haeds/master". */
+ error = git_reference_name_to_id(&head->oid, t->repo, name);
+ if (error < 0) {
git__free(head->name);
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)