path: root/builtin/ls-remote.c
diff options
authorTay Ray Chuan <>2010-05-11 17:20:23 (GMT)
committerJunio C Hamano <>2010-05-12 05:55:44 (GMT)
commitcefb2a5e39b165146aee3b093872721cc1155a87 (patch)
tree363db940a175c13b4524bacc2867ed6b6587cac9 /builtin/ls-remote.c
parent9c00de5a3135c8f7273668d4013c225d48d47861 (diff)
ls-remote: print URL when no repo is specified
After 9c00de5 (ls-remote: fall-back to default remotes when no remote specified), when no repository is specified, ls-remote may use the URL/remote in the config "branch.<name>.remote" or the remote "origin"; it may not be immediately obvious to the user which was used. In such cases, print a simple "From <URL>" line to indicate which repository was used. This message is similar to git-fetch's, and is printed to stderr to avoid breaking existing scripts that depend on ls-remote's output behaviour. It can also be disabled with -q/--quiet. Modify tests related to falling back on default remotes to check for this as well, and add a test to check for suppression of the message. Signed-off-by: Tay Ray Chuan <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/ls-remote.c')
1 files changed, 9 insertions, 1 deletions
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 8ee91eb..34480cf 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -5,7 +5,7 @@
static const char ls_remote_usage[] =
"git ls-remote [--heads] [--tags] [-u <exec> | --upload-pack <exec>]\n"
-" [<repository> [<refs>...]]";
+" [-q|--quiet] [<repository> [<refs>...]]";
* Is there one among the list of patterns that match the tail part
@@ -34,6 +34,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
const char *dest = NULL;
int nongit;
unsigned flags = 0;
+ int quiet = 0;
const char *uploadpack = NULL;
const char **pattern = NULL;
@@ -67,6 +68,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
flags |= REF_NORMAL;
+ if (!strcmp("--quiet", arg) || !strcmp("-q", arg)) {
+ quiet = 1;
+ continue;
+ }
dest = arg;
@@ -99,6 +104,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
ref = transport_get_remote_refs(transport);
if (transport_disconnect(transport))
return 1;
+ if (!dest && !quiet)
+ fprintf(stderr, "From %s\n", *remote->url);
for ( ; ref; ref = ref->next) {
if (!check_ref_type(ref, flags))