refs: change signatures of get_packed_refs() and get_loose_refs()
[gitweb.git] / transport.c
index a2b1a258dc0b7ffd9d3988e65811e4e504808d90..51814b5da3064b617fa268a6b2bc6b3d6cb0b110 100644 (file)
@@ -432,7 +432,8 @@ static int fetch_refs_from_bundle(struct transport *transport,
                               int nr_heads, struct ref **to_fetch)
 {
        struct bundle_transport_data *data = transport->data;
-       return unbundle(&data->header, data->fd);
+       return unbundle(&data->header, data->fd,
+                       transport->progress ? BUNDLE_VERBOSE : 0);
 }
 
 static int close_bundle(struct transport *transport)
@@ -754,18 +755,10 @@ void transport_verify_remote_names(int nr_heads, const char **heads)
                        continue;
 
                remote = remote ? (remote + 1) : local;
-               switch (check_ref_format(remote)) {
-               case 0: /* ok */
-               case CHECK_REF_FORMAT_ONELEVEL:
-                       /* ok but a single level -- that is fine for
-                        * a match pattern.
-                        */
-               case CHECK_REF_FORMAT_WILDCARD:
-                       /* ok but ends with a pattern-match character */
-                       continue;
-               }
-               die("remote part of refspec is not a valid name in %s",
-                   heads[i]);
+               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]);
        }
 }
 
@@ -866,28 +859,6 @@ static int is_local(const char *url)
                has_dos_drive_prefix(url);
 }
 
-static int is_gitfile(const char *url)
-{
-       struct stat st;
-       char buf[9];
-       int fd, len;
-       if (stat(url, &st))
-               return 0;
-       if (!S_ISREG(st.st_mode))
-               return 0;
-       if (st.st_size < 10 || st.st_size > 9 + PATH_MAX)
-               return 0;
-
-       fd = open(url, O_RDONLY);
-       if (fd < 0)
-               die_errno("Error opening '%s'", url);
-       len = read_in_full(fd, buf, sizeof(buf));
-       close(fd);
-       if (len != sizeof(buf))
-               die("Error reading %s", url);
-       return !prefixcmp(buf, "gitdir: ");
-}
-
 static int is_file(const char *url)
 {
        struct stat buf;
@@ -936,7 +907,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
                ret->fetch = fetch_objs_via_rsync;
                ret->push = rsync_transport_push;
                ret->smart_options = NULL;
-       } else if (is_local(url) && is_file(url) && !is_gitfile(url)) {
+       } else if (is_local(url) && is_file(url) && is_bundle(url, 1)) {
                struct bundle_transport_data *data = xcalloc(1, sizeof(*data));
                ret->data = data;
                ret->get_refs_list = get_refs_from_bundle;
@@ -1055,8 +1026,8 @@ int transport_push(struct transport *transport,
                if (flags & TRANSPORT_PUSH_MIRROR)
                        match_flags |= MATCH_REFS_MIRROR;
 
-               if (match_refs(local_refs, &remote_refs,
-                              refspec_nr, refspec, match_flags)) {
+               if (match_push_refs(local_refs, &remote_refs,
+                                   refspec_nr, refspec, match_flags)) {
                        return -1;
                }