clone: convert cmd_clone to use refspec_item_init
[gitweb.git] / builtin / clone.c
index 7df5932b855e874d45b970f6150d65ed25b06f5f..8c5f4d8f074f13c62b7d6d5a3ea4deff80de2d58 100644 (file)
@@ -14,6 +14,7 @@
 #include "parse-options.h"
 #include "fetch-pack.h"
 #include "refs.h"
+#include "refspec.h"
 #include "tree.h"
 #include "tree-walk.h"
 #include "unpack-trees.h"
@@ -546,7 +547,7 @@ static struct ref *find_remote_branch(const struct ref *refs, const char *branch
 }
 
 static struct ref *wanted_peer_refs(const struct ref *refs,
-               struct refspec *refspec)
+               struct refspec_item *refspec)
 {
        struct ref *head = copy_ref(find_ref_by_name(refs, "HEAD"));
        struct ref *local_refs = head;
@@ -894,8 +895,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        int err = 0, complete_refs_before_fetch = 1;
        int submodule_progress;
 
-       struct refspec *refspec;
-       const char *fetch_pattern;
+       struct refspec_item refspec;
 
        fetch_if_missing = 0;
 
@@ -1077,8 +1077,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        if (option_required_reference.nr || option_optional_reference.nr)
                setup_reference();
 
-       fetch_pattern = value.buf;
-       refspec = parse_fetch_refspec(1, &fetch_pattern);
+       refspec_item_init(&refspec, value.buf, REFSPEC_FETCH);
 
        strbuf_reset(&value);
 
@@ -1135,10 +1134,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        if (transport->smart_options && !deepen && !filter_options.choice)
                transport->smart_options->check_self_contained_and_connected = 1;
 
-       refs = transport_get_remote_refs(transport);
+       refs = transport_get_remote_refs(transport, NULL);
 
        if (refs) {
-               mapped_refs = wanted_peer_refs(refs, refspec);
+               mapped_refs = wanted_peer_refs(refs, &refspec);
                /*
                 * transport_get_remote_refs() may return refs with null sha-1
                 * in mapped_refs (see struct transport->get_refs_list
@@ -1232,6 +1231,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        strbuf_release(&value);
        junk_mode = JUNK_LEAVE_ALL;
 
-       free(refspec);
+       refspec_item_clear(&refspec);
        return err;
 }