notes remove: --stdin reads from the standard input
[gitweb.git] / builtin / ls-remote.c
index 34480cfad6a8842d65ae61f6257c597a2a987b33..1a1ff87e8f9ed7db84f106960f36888835f7057b 100644 (file)
@@ -32,8 +32,8 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 {
        int i;
        const char *dest = NULL;
-       int nongit;
        unsigned flags = 0;
+       int get_url = 0;
        int quiet = 0;
        const char *uploadpack = NULL;
        const char **pattern = NULL;
@@ -42,8 +42,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
        struct transport *transport;
        const struct ref *ref;
 
-       setup_git_directory_gently(&nongit);
-
        for (i = 1; i < argc; i++) {
                const char *arg = argv[i];
 
@@ -72,6 +70,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
                                quiet = 1;
                                continue;
                        }
+                       if (!strcmp("--get-url", arg)) {
+                               get_url = 1;
+                               continue;
+                       }
                        usage(ls_remote_usage);
                }
                dest = arg;
@@ -97,6 +99,12 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
        }
        if (!remote->url_nr)
                die("remote %s has no configured URL", dest);
+
+       if (get_url) {
+               printf("%s\n", *remote->url);
+               return 0;
+       }
+
        transport = transport_get(remote, NULL);
        if (uploadpack != NULL)
                transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack);