diff options
author | Etienne Samson <samson.etienne@gmail.com> | 2018-07-06 20:21:25 +0000 |
---|---|---|
committer | Etienne Samson <samson.etienne@gmail.com> | 2018-07-06 22:22:42 +0200 |
commit | 68c7480a8ef77424c67bcf5f0b822926e030d758 (patch) | |
tree | 8b9e4a2bd9f3140f5fb33f65c0ffc0ad5a806d4f | |
parent | 36a5b557f146affcc627e6f762b2ab722e2796ce (diff) | |
download | libgit2-68c7480a8ef77424c67bcf5f0b822926e030d758.tar.gz |
smart: clarify error handling in git_smart__connect
-rw-r--r-- | src/transports/smart.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/transports/smart.c b/src/transports/smart.c index 619a81ff8..180099539 100644 --- a/src/transports/smart.c +++ b/src/transports/smart.c @@ -279,14 +279,13 @@ static int git_smart__connect( return error; /* Detect capabilities */ - if (git_smart__detect_caps(first, &t->caps, &symrefs) < 0) { - free_symrefs(&symrefs); - return -1; + if ((error = git_smart__detect_caps(first, &t->caps, &symrefs)) == 0) { + goto cleanup; } /* If the only ref in the list is capabilities^{} with OID_ZERO, remove it */ if (1 == t->refs.length && !strcmp(first->head.name, "capabilities^{}") && - git_oid_iszero(&first->head.oid)) { + git_oid_iszero(&first->head.oid)) { git_vector_clear(&t->refs); git_pkt_free((git_pkt *)first); } @@ -294,15 +293,17 @@ static int git_smart__connect( /* Keep a list of heads for _ls */ git_smart__update_heads(t, &symrefs); - free_symrefs(&symrefs); - if (t->rpc && git_smart__reset_stream(t, false) < 0) - return -1; + if (t->rpc && (error = git_smart__reset_stream(t, false)) < 0) + goto cleanup; /* We're now logically connected. */ t->connected = 1; - return 0; +cleanup: + free_symrefs(&symrefs); + + return error; } static int git_smart__ls(const git_remote_head ***out, size_t *size, git_transport *transport) |