Merge branch 'il/loosen-remote-helper-names'
authorJunio C Hamano <gitster@pobox.com>
Sun, 7 Mar 2010 20:47:15 +0000 (12:47 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sun, 7 Mar 2010 20:47:15 +0000 (12:47 -0800)
* il/loosen-remote-helper-names:
Allow '+', '-' and '.' in remote helper names

1  2 
transport.c
diff --combined transport.c
index 1a360cfb48545efbbb97969c6879262e321338cd,d3ec44985994df66fc7e1eeb401b289055dd0f19..f07bd33e86cdfb1b41d2e4d27ad1942fcf326147
@@@ -573,7 -573,7 +573,7 @@@ static int push_had_errors(struct ref *
        return 0;
  }
  
 -static int refs_pushed(struct ref *ref)
 +int transport_refs_pushed(struct ref *ref)
  {
        for (; ref; ref = ref->next) {
                switch(ref->status) {
        return 0;
  }
  
 -static void update_tracking_ref(struct remote *remote, struct ref *ref, int verbose)
 +void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int verbose)
  {
        struct refspec rs;
  
        }
  }
  
 -#define SUMMARY_WIDTH (2 * DEFAULT_ABBREV + 3)
 -
  static void print_ref_status(char flag, const char *summary, struct ref *to, struct ref *from, const char *msg, int porcelain)
  {
        if (porcelain) {
                else
                        fprintf(stdout, "%s\n", summary);
        } else {
 -              fprintf(stderr, " %c %-*s ", flag, SUMMARY_WIDTH, summary);
 +              fprintf(stderr, " %c %-*s ", flag, TRANSPORT_SUMMARY_WIDTH, summary);
                if (from)
                        fprintf(stderr, "%s -> %s", prettify_refname(from->name), prettify_refname(to->name));
                else
@@@ -709,8 -711,8 +709,8 @@@ static int print_one_push_status(struc
        return 1;
  }
  
 -static void print_push_status(const char *dest, struct ref *refs,
 -                            int verbose, int porcelain, int * nonfastforward)
 +void transport_print_push_status(const char *dest, struct ref *refs,
 +                                int verbose, int porcelain, int *nonfastforward)
  {
        struct ref *ref;
        int n = 0;
        }
  }
  
 -static void verify_remote_names(int nr_heads, const char **heads)
 +void transport_verify_remote_names(int nr_heads, const char **heads)
  {
        int i;
  
@@@ -870,6 -872,21 +870,21 @@@ static int is_file(const char *url
        return S_ISREG(buf.st_mode);
  }
  
+ static int isurlschemechar(int first_flag, int ch)
+ {
+       /*
+        * The set of valid URL schemes, as per STD66 (RFC3986) is
+        * '[A-Za-z][A-Za-z0-9+.-]*'. But use sightly looser check
+        * of '[A-Za-z0-9][A-Za-z0-9+.-]*' because earlier version
+        * of check used '[A-Za-z0-9]+' so not to break any remote
+        * helpers.
+        */
+       int alphanumeric, special;
+       alphanumeric = ch > 0 && isalnum(ch);
+       special = ch == '+' || ch == '-' || ch == '.';
+       return alphanumeric || (!first_flag && special);
+ }
  static int is_url(const char *url)
  {
        const char *url2, *first_slash;
         */
        url2 = url;
        while (url2 < first_slash - 1) {
-               if (!isalnum((unsigned char)*url2))
+               if (!isurlschemechar(url2 == url, (unsigned char)*url2))
                        return 0;
                url2++;
        }
@@@ -916,7 -933,6 +931,7 @@@ struct transport *transport_get(struct 
        if (!remote)
                die("No remote provided to transport_get()");
  
 +      ret->got_remote_refs = 0;
        ret->remote = remote;
        helper = remote->foreign_vcs;
  
        if (url) {
                const char *p = url;
  
-               while (isalnum(*p))
+               while (isurlschemechar(p == url, *p))
                        p++;
                if (!prefixcmp(p, "::"))
                        helper = xstrndup(url, p - url);
@@@ -1017,7 -1033,7 +1032,7 @@@ int transport_push(struct transport *tr
                   int *nonfastforward)
  {
        *nonfastforward = 0;
 -      verify_remote_names(refspec_nr, refspec);
 +      transport_verify_remote_names(refspec_nr, refspec);
  
        if (transport->push) {
                /* Maybe FIXME. But no important transport uses this case. */
                ret |= err;
  
                if (!quiet || err)
 -                      print_push_status(transport->url, remote_refs,
 +                      transport_print_push_status(transport->url, remote_refs,
                                        verbose | porcelain, porcelain,
                                        nonfastforward);
  
                if (!(flags & TRANSPORT_PUSH_DRY_RUN)) {
                        struct ref *ref;
                        for (ref = remote_refs; ref; ref = ref->next)
 -                              update_tracking_ref(transport->remote, ref, verbose);
 +                              transport_update_tracking_ref(transport->remote, ref, verbose);
                }
  
 -              if (!quiet && !ret && !refs_pushed(remote_refs))
 +              if (!quiet && !ret && !transport_refs_pushed(remote_refs))
                        fprintf(stderr, "Everything up-to-date\n");
                return ret;
        }
  
  const struct ref *transport_get_remote_refs(struct transport *transport)
  {
 -      if (!transport->remote_refs)
 +      if (!transport->got_remote_refs) {
                transport->remote_refs = transport->get_refs_list(transport, 0);
 +              transport->got_remote_refs = 1;
 +      }
  
        return transport->remote_refs;
  }