blame: default to HEAD in a bare repo when no start commit is given
[gitweb.git] / builtin / ls-remote.c
index ca3f04a839e79ecf361df5a1997da05c5d59a62d..1d7f1f5ce27834cafcf934db2085b36d4301e3c0 100644 (file)
@@ -47,6 +47,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
        const char **pattern = NULL;
        struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
        int i;
+       struct string_list server_options = STRING_LIST_INIT_DUP;
 
        struct remote *remote;
        struct transport *transport;
@@ -73,6 +74,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
                              2, PARSE_OPT_NOCOMPLETE),
                OPT_BOOL(0, "symref", &show_symref_target,
                         N_("show underlying ref in addition to the object pointed by it")),
+               OPT_STRING_LIST('o', "server-option", &server_options, N_("server-specific"), N_("option to transmit")),
                OPT_END()
        };
 
@@ -86,18 +88,15 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
                int i;
                pattern = xcalloc(argc, sizeof(const char *));
                for (i = 1; i < argc; i++) {
-                       const char *glob;
                        pattern[i - 1] = xstrfmt("*/%s", argv[i]);
-
-                       glob = strchr(argv[i], '*');
-                       if (glob)
-                               argv_array_pushf(&ref_prefixes, "%.*s",
-                                                (int)(glob - argv[i]), argv[i]);
-                       else
-                               expand_ref_prefix(&ref_prefixes, argv[i]);
                }
        }
 
+       if (flags & REF_TAGS)
+               argv_array_push(&ref_prefixes, "refs/tags/");
+       if (flags & REF_HEADS)
+               argv_array_push(&ref_prefixes, "refs/heads/");
+
        remote = remote_get(dest);
        if (!remote) {
                if (dest)
@@ -116,6 +115,8 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
        transport = transport_get(remote, NULL);
        if (uploadpack != NULL)
                transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack);
+       if (server_options.nr)
+               transport->server_options = &server_options;
 
        ref = transport_get_remote_refs(transport, &ref_prefixes);
        if (transport_disconnect(transport)) {
@@ -147,6 +148,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
        }
 
        UNLEAK(sorting);
-       UNLEAK(ref_array);
+       ref_array_clear(&ref_array);
        return status;
 }