summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/clone.c3
-rw-r--r--src/transports/local.c19
-rw-r--r--src/transports/smart_protocol.c7
3 files changed, 16 insertions, 13 deletions
diff --git a/src/clone.c b/src/clone.c
index f19771c1e..8381ec63c 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -113,11 +113,12 @@ static int update_head_to_new_branch(
const char *reflog_message)
{
git_reference *tracking_branch = NULL;
+ int error;
if (!git__prefixcmp(name, GIT_REFS_HEADS_DIR))
name += strlen(GIT_REFS_HEADS_DIR);
- int error = create_tracking_branch(&tracking_branch, repo, target, name,
+ error = create_tracking_branch(&tracking_branch, repo, target, name,
signature, reflog_message);
if (!error)
diff --git a/src/transports/local.c b/src/transports/local.c
index 8d3619388..038337d72 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -40,6 +40,13 @@ typedef struct {
have_refs : 1;
} transport_local;
+static void free_head(git_remote_head *head)
+{
+ git__free(head->name);
+ git__free(head->symref_target);
+ git__free(head);
+}
+
static int add_ref(transport_local *t, const char *name)
{
const char peeled[] = "^{}";
@@ -83,8 +90,7 @@ static int add_ref(transport_local *t, const char *name)
git_reference_free(ref);
if ((error = git_vector_insert(&t->refs, head)) < 0) {
- git__free(head->name);
- git__free(head);
+ free_head(head);
return error;
}
@@ -117,8 +123,7 @@ static int add_ref(transport_local *t, const char *name)
git_oid_cpy(&head->oid, git_object_id(target));
if ((error = git_vector_insert(&t->refs, head)) < 0) {
- git__free(head->name);
- git__free(head);
+ free_head(head);
}
}
@@ -640,10 +645,8 @@ static void local_free(git_transport *transport)
size_t i;
git_remote_head *head;
- git_vector_foreach(&t->refs, i, head) {
- git__free(head->name);
- git__free(head);
- }
+ git_vector_foreach(&t->refs, i, head)
+ free_head(head);
git_vector_free(&t->refs);
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index bab0cf113..a52aacc60 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -26,17 +26,16 @@ int git_smart__store_refs(transport_smart *t, int flushes)
int error, flush = 0, recvd;
const char *line_end = NULL;
git_pkt *pkt = NULL;
- git_pkt_ref *ref;
size_t i;
/* Clear existing refs in case git_remote_connect() is called again
* after git_remote_disconnect().
*/
- git_vector_foreach(refs, i, ref) {
- git__free(ref->head.name);
- git__free(ref);
+ git_vector_foreach(refs, i, pkt) {
+ git_pkt_free(pkt);
}
git_vector_clear(refs);
+ pkt = NULL;
do {
if (buf->offset > 0)