diff options
| author | Carlos Martín Nieto <cmn@elego.de> | 2013-04-15 22:53:57 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@elego.de> | 2013-04-15 23:22:32 +0200 |
| commit | 67ba7d2031f1eef63d66db6ce3ecaceddb06a4f3 (patch) | |
| tree | 4a1a7e8e054747481d28538d229dbd3553dedb90 /src/transports/local.c | |
| parent | 77849ebf1e39126bcb9f1245423749d45d226022 (diff) | |
| download | libgit2-67ba7d2031f1eef63d66db6ce3ecaceddb06a4f3.tar.gz | |
Allow git_remote_ls after disconnecting from the remote
Keep the data around until free, as expected by our own fetch example
Diffstat (limited to 'src/transports/local.c')
| -rw-r--r-- | src/transports/local.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/transports/local.c b/src/transports/local.c index ce89bb213..8af970eac 100644 --- a/src/transports/local.c +++ b/src/transports/local.c @@ -36,7 +36,8 @@ typedef struct { git_atomic cancelled; git_repository *repo; git_vector refs; - unsigned connected : 1; + unsigned connected : 1, + have_refs : 1; } transport_local; static int add_ref(transport_local *t, const char *name) @@ -139,6 +140,7 @@ static int store_refs(transport_local *t) goto on_error; } + t->have_refs = 1; git_strarray_free(&ref_names); return 0; @@ -208,8 +210,8 @@ static int local_ls(git_transport *transport, git_headlist_cb list_cb, void *pay unsigned int i; git_remote_head *head = NULL; - if (!t->connected) { - giterr_set(GITERR_NET, "The transport is not connected"); + if (!t->have_refs) { + giterr_set(GITERR_NET, "The transport has not yet loaded the refs"); return -1; } @@ -569,8 +571,6 @@ static void local_cancel(git_transport *transport) static int local_close(git_transport *transport) { transport_local *t = (transport_local *)transport; - size_t i; - git_remote_head *head; t->connected = 0; @@ -579,13 +579,6 @@ static int local_close(git_transport *transport) t->repo = NULL; } - git_vector_foreach(&t->refs, i, head) { - git__free(head->name); - git__free(head); - } - - git_vector_free(&t->refs); - if (t->url) { git__free(t->url); t->url = NULL; @@ -597,10 +590,19 @@ static int local_close(git_transport *transport) static void local_free(git_transport *transport) { transport_local *t = (transport_local *)transport; + size_t i; + git_remote_head *head; /* Close the transport, if it's still open. */ local_close(transport); + git_vector_foreach(&t->refs, i, head) { + git__free(head->name); + git__free(head); + } + + git_vector_free(&t->refs); + /* Free the transport */ git__free(t); } |
