vscode: let cSpell work on commit messages, too
[gitweb.git] / transport.c
index 181db4d4d07500ab97aab1da25e37dd5c422daad..a32da30dee6f4e38433b68d7c9f7e9404aa58858 100644 (file)
@@ -269,7 +269,7 @@ static struct ref *get_refs_via_connect(struct transport *transport, int for_pus
        switch (data->version) {
        case protocol_v2:
                get_remote_refs(data->fd[1], &reader, &refs, for_push,
-                               ref_prefixes);
+                               ref_prefixes, transport->server_options);
                break;
        case protocol_v1:
        case protocol_v0:
@@ -317,6 +317,7 @@ static int fetch_refs_via_pack(struct transport *transport,
        args.no_dependents = data->options.no_dependents;
        args.filter_options = data->options.filter_options;
        args.stateless_rpc = transport->stateless_rpc;
+       args.server_options = transport->server_options;
 
        if (!data->got_remote_heads)
                refs_tmp = get_refs_via_connect(transport, 0, NULL);
@@ -619,29 +620,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;
@@ -737,7 +715,7 @@ void transport_take_over(struct transport *transport,
        struct git_transport_data *data;
 
        if (!transport->smart_options)
-               die("BUG: taking over transport requires non-NULL "
+               BUG("taking over transport requires non-NULL "
                    "smart_options field.");
 
        data = xcalloc(1, sizeof(*data));
@@ -862,7 +840,7 @@ int is_transport_allowed(const char *type, int from_user)
                return from_user;
        }
 
-       die("BUG: invalid protocol_allow_config type");
+       BUG("invalid protocol_allow_config type");
 }
 
 void transport_check_allowed(const char *type)
@@ -1093,11 +1071,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,39 +1088,17 @@ 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 = REFSPEC_INIT_PUSH;
                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) < 0)
                        return -1;
 
-               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 (item->dst)
-                               prefix = item->dst;
-                       else if (item->src && !item->exact_sha1)
-                               prefix = item->src;
-
-                       if (prefix) {
-                               const char *glob = strchr(prefix, '*');
-                               if (glob)
-                                       argv_array_pushf(&ref_prefixes, "%.*s",
-                                                        (int)(glob - prefix),
-                                                        prefix);
-                               else
-                                       expand_ref_prefix(&ref_prefixes, prefix);
-                       }
-               }
+               refspec_ref_prefixes(rs, &ref_prefixes);
 
                remote_refs = transport->vtable->get_refs_list(transport, 1,
                                                               &ref_prefixes);
 
                argv_array_clear(&ref_prefixes);
-               refspec_clear(&tmp_rs);
 
                if (flags & TRANSPORT_PUSH_ALL)
                        match_flags |= MATCH_REFS_ALL;
@@ -1154,10 +1109,8 @@ int transport_push(struct transport *transport,
                if (flags & TRANSPORT_PUSH_FOLLOW_TAGS)
                        match_flags |= MATCH_REFS_FOLLOW_TAGS;
 
-               if (match_push_refs(local_refs, &remote_refs,
-                                   refspec_nr, refspec, match_flags)) {
+               if (match_push_refs(local_refs, &remote_refs, rs, match_flags))
                        return -1;
-               }
 
                if (transport->smart_options &&
                    transport->smart_options->cas &&
@@ -1186,7 +1139,7 @@ int transport_push(struct transport *transport,
 
                        if (!push_unpushed_submodules(&commits,
                                                      transport->remote,
-                                                     refspec, refspec_nr,
+                                                     rs,
                                                      transport->push_options,
                                                      pretend)) {
                                oid_array_clear(&commits);