remote: convert get_ref_match to take a struct refspec
[gitweb.git] / transport.c
index 37410d8aad9dd70df282c133ea9939bba5589efd..181db4d4d07500ab97aab1da25e37dd5c422daad 100644 (file)
@@ -11,6 +11,7 @@
 #include "bundle.h"
 #include "dir.h"
 #include "refs.h"
+#include "refspec.h"
 #include "branch.h"
 #include "url.h"
 #include "submodule.h"
@@ -389,7 +390,7 @@ int transport_refs_pushed(struct ref *ref)
 
 void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int verbose)
 {
-       struct refspec rs;
+       struct refspec_item rs;
 
        if (ref->status != REF_STATUS_OK && ref->status != REF_STATUS_UPTODATE)
                return;
@@ -1110,21 +1111,22 @@ int transport_push(struct transport *transport,
                int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
                int pretend = flags & TRANSPORT_PUSH_DRY_RUN;
                int push_ret, ret, err;
-               struct refspec *tmp_rs;
+               struct refspec tmp_rs = REFSPEC_INIT_PUSH;
                struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
                int i;
 
                if (check_push_refs(local_refs, refspec_nr, refspec) < 0)
                        return -1;
 
-               tmp_rs = parse_push_refspec(refspec_nr, refspec);
-               for (i = 0; i < refspec_nr; i++) {
+               refspec_appendn(&tmp_rs, refspec, refspec_nr);
+               for (i = 0; i < tmp_rs.nr; i++) {
+                       const struct refspec_item *item = &tmp_rs.items[i];
                        const char *prefix = NULL;
 
-                       if (tmp_rs[i].dst)
-                               prefix = tmp_rs[i].dst;
-                       else if (tmp_rs[i].src && !tmp_rs[i].exact_sha1)
-                               prefix = tmp_rs[i].src;
+                       if (item->dst)
+                               prefix = item->dst;
+                       else if (item->src && !item->exact_sha1)
+                               prefix = item->src;
 
                        if (prefix) {
                                const char *glob = strchr(prefix, '*');
@@ -1141,7 +1143,7 @@ int transport_push(struct transport *transport,
                                                               &ref_prefixes);
 
                argv_array_clear(&ref_prefixes);
-               free_refspec(refspec_nr, tmp_rs);
+               refspec_clear(&tmp_rs);
 
                if (flags & TRANSPORT_PUSH_ALL)
                        match_flags |= MATCH_REFS_ALL;