transport: remove transport_verify_remote_names
[gitweb.git] / transport.c
index 3ad4d37dc0dc19b9038b78d758aee3dbcd20d31c..fe96c0b8077ec6dd634a03a85134b6f2686c54c6 100644 (file)
@@ -619,29 +619,6 @@ void transport_print_push_status(const char *dest, struct ref *refs,
        free(head);
 }
 
-void transport_verify_remote_names(int nr_heads, const char **heads)
-{
-       int i;
-
-       for (i = 0; i < nr_heads; i++) {
-               const char *local = heads[i];
-               const char *remote = strrchr(heads[i], ':');
-
-               if (*local == '+')
-                       local++;
-
-               /* A matching refspec is okay.  */
-               if (remote == local && remote[1] == '\0')
-                       continue;
-
-               remote = remote ? (remote + 1) : local;
-               if (check_refname_format(remote,
-                               REFNAME_ALLOW_ONELEVEL|REFNAME_REFSPEC_PATTERN))
-                       die("remote part of refspec is not a valid name in %s",
-                               heads[i]);
-       }
-}
-
 static int git_transport_push(struct transport *transport, struct ref *remote_refs, int flags)
 {
        struct git_transport_data *data = transport->data;
@@ -1093,11 +1070,10 @@ static int run_pre_push_hook(struct transport *transport,
 }
 
 int transport_push(struct transport *transport,
-                  int refspec_nr, const char **refspec, int flags,
+                  struct refspec *rs, int flags,
                   unsigned int *reject_reasons)
 {
        *reject_reasons = 0;
-       transport_verify_remote_names(refspec_nr, refspec);
 
        if (transport_color_config() < 0)
                return -1;
@@ -1111,21 +1087,20 @@ 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_item *tmp_rs;
                struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
                int i;
 
-               if (check_push_refs(local_refs, refspec_nr, refspec) < 0)
+               if (check_push_refs(local_refs, rs->raw_nr, rs->raw) < 0)
                        return -1;
 
-               tmp_rs = parse_push_refspec(refspec_nr, refspec);
-               for (i = 0; i < refspec_nr; i++) {
+               for (i = 0; i < rs->nr; i++) {
+                       const struct refspec_item *item = &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, '*');
@@ -1142,7 +1117,6 @@ int transport_push(struct transport *transport,
                                                               &ref_prefixes);
 
                argv_array_clear(&ref_prefixes);
-               free_refspec(refspec_nr, tmp_rs);
 
                if (flags & TRANSPORT_PUSH_ALL)
                        match_flags |= MATCH_REFS_ALL;
@@ -1154,7 +1128,7 @@ int transport_push(struct transport *transport,
                        match_flags |= MATCH_REFS_FOLLOW_TAGS;
 
                if (match_push_refs(local_refs, &remote_refs,
-                                   refspec_nr, refspec, match_flags)) {
+                                   rs->raw_nr, rs->raw, match_flags)) {
                        return -1;
                }
 
@@ -1185,7 +1159,7 @@ int transport_push(struct transport *transport,
 
                        if (!push_unpushed_submodules(&commits,
                                                      transport->remote,
-                                                     refspec, refspec_nr,
+                                                     rs->raw, rs->raw_nr,
                                                      transport->push_options,
                                                      pretend)) {
                                oid_array_clear(&commits);