Merge branch 'rr/remote-branch-config-refresh'
[gitweb.git] / builtin / checkout.c
index f5b50e520feb42c50cd1783871eb63d009e0a0e0..3be00188216f503ea1f9269acd312aebdb72a0fa 100644 (file)
@@ -838,13 +838,16 @@ static int check_tracking_name(struct remote *remote, void *cb_data)
        memset(&query, 0, sizeof(struct refspec));
        query.src = cb->src_ref;
        if (remote_find_tracking(remote, &query) ||
-           get_sha1(query.dst, cb->dst_sha1))
+           get_sha1(query.dst, cb->dst_sha1)) {
+               free(query.dst);
                return 0;
+       }
        if (cb->dst_ref) {
+               free(query.dst);
                cb->unique = 0;
                return 0;
        }
-       cb->dst_ref = xstrdup(query.dst);
+       cb->dst_ref = query.dst;
        return 0;
 }