{"thread":{"id":"41208","subject":"[PATCH 0/4] ls-remote: introduce symref argument","startedAt":"2016-01-17T11:03:58Z","lastAt":"2016-01-19T18:14:30Z","messageCount":44,"participants":["Thomas Gummerer","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"276234","messageId":"1453028643-13978-1-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":null,"subject":"[PATCH 0/4] ls-remote: introduce symref argument","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-17T11:03:58Z","receivedAt":"2016-01-17T11:03:58Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"> I thought it might be nice for any porcelain which tries to wrap\n> `ls-remote`, make some decision based on the capabilities, and then\n> invoke another plumbing command. But I guess that is probably slightly\n> crazy, and nobody is doing it.\n> \n> Something like `ls-remote --symrefs` probably would be a better place to\n> start.\n\nTurns out adding this is pretty simple.\n\nThe first two patches are documentation, which I noticed when reading\nup about the command.  Patch three is a cleanup patch, which makes\nls-remote use the parse-options api instead of the hand-rolled option\nparser.  Patch four is actually adding the option.\n\nThomas Gummerer (4):\n  ls-remote: document --quiet option\n  ls-remote: fix synopsis\n  ls-remote: use parse-options api\n  ls-remote: add support for showing symrefs\n\n Documentation/git-ls-remote.txt | 12 +++++-\n builtin/ls-remote.c             | 90 +++++++++++++++++------------------------\n t/t5512-ls-remote.sh            | 20 +++++++++\n 3 files changed, 68 insertions(+), 54 deletions(-)\n\n-- \n2.7.0.14.g2b6d3d6\n"},{"id":"276237","messageId":"1453028643-13978-2-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453028643-13978-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH 1/4] ls-remote: document --quiet option","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-17T11:03:59Z","receivedAt":"2016-01-17T11:03:59Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"cefb2a5e3 (\"ls-remote: print URL when no repo is specified\") added a\nquiet option to ls-remote, but didn't add it to the documentation.  Add\nit.\n\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n Documentation/git-ls-remote.txt | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\nindex d510c05..27380de 100644\n--- a/Documentation/git-ls-remote.txt\n+++ b/Documentation/git-ls-remote.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git ls-remote' [--heads] [--tags]  [--upload-pack=<exec>]\n-\t      [--exit-code] <repository> [<refs>...]\n+\t      [-q | --quiet] [--exit-code] <repository> [<refs>...]\n \n DESCRIPTION\n -----------\n@@ -29,6 +29,10 @@ OPTIONS\n \tboth, references stored in refs/heads and refs/tags are\n \tdisplayed.\n \n+-q::\n+--quiet::\n+\tDo not print remote URL to stderr.\n+\n --upload-pack=<exec>::\n \tSpecify the full path of 'git-upload-pack' on the remote\n \thost. This allows listing references from repositories accessed via\n-- \n2.7.0.14.g2b6d3d6\n"},{"id":"276236","messageId":"1453028643-13978-3-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453028643-13978-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH 2/4] ls-remote: fix synopsis","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-17T11:04:00Z","receivedAt":"2016-01-17T11:04:00Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"git ls-remote takes an optional get-url argument, and specifying the\nrepository is optional.  Fix the synopsis in the documentation to\nreflect this.\n\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n Documentation/git-ls-remote.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\nindex 27380de..31c1427 100644\n--- a/Documentation/git-ls-remote.txt\n+++ b/Documentation/git-ls-remote.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git ls-remote' [--heads] [--tags]  [--upload-pack=<exec>]\n-\t      [-q | --quiet] [--exit-code] <repository> [<refs>...]\n+\t      [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\n \n DESCRIPTION\n -----------\n-- \n2.7.0.14.g2b6d3d6\n"},{"id":"276235","messageId":"1453028643-13978-4-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453028643-13978-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH 3/4] ls-remote: use parse-options api","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-17T11:04:01Z","receivedAt":"2016-01-17T11:04:01Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"Currently ls-remote uses a hand rolled parser for the its command line\narguments.  Use the parse-options api instead of the hand rolled parser\nto simplify the code and make it easier to add new arguments.  In\naddition this improves the help message.\n\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n builtin/ls-remote.c | 83 +++++++++++++++++++----------------------------------\n 1 file changed, 30 insertions(+), 53 deletions(-)\n\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex fa65a84..6ee7b0e 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -3,9 +3,11 @@\n #include \"transport.h\"\n #include \"remote.h\"\n \n-static const char ls_remote_usage[] =\n-\"git ls-remote [--heads] [--tags]  [--upload-pack=<exec>]\\n\"\n-\"                     [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\";\n+static const char * const ls_remote_usage[] = {\n+\tN_(\"git ls-remote [--heads] [--tags]  [--upload-pack=<exec>]\\n\"\n+\t   \"                     [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\"),\n+\tNULL\n+};\n \n /*\n  * Is there one among the list of patterns that match the tail part\n@@ -30,12 +32,12 @@ static int tail_match(const char **pattern, const char *path)\n \n int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n \tconst char *dest = NULL;\n \tunsigned flags = 0;\n \tint get_url = 0;\n \tint quiet = 0;\n \tint status = 0;\n+\tint tags = 0, heads = 0, refs = 0;\n \tconst char *uploadpack = NULL;\n \tconst char **pattern = NULL;\n \n@@ -43,59 +45,34 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tstruct transport *transport;\n \tconst struct ref *ref;\n \n-\tif (argc == 2 && !strcmp(\"-h\", argv[1]))\n-\t\tusage(ls_remote_usage);\n+\tstruct option options[] = {\n+\t\tOPT__QUIET(&quiet, N_(\"do not print remote URL\")),\n+\t\tOPT_STRING(0, \"upload-pack\", &uploadpack, N_(\"exec\"),\n+\t\t\t   N_(\"path of git-upload-pack on the remote host\")),\n+\t\tOPT_STRING(0, \"exec\", &uploadpack, N_(\"exec\"),\n+\t\t\t   N_(\"path of git-upload-pack on the remote host\")),\n+\t\tOPT_SET_INT('t', \"tags\", &tags, N_(\"limit to tags\"), REF_TAGS),\n+\t\tOPT_SET_INT('h', \"heads\", &heads, N_(\"limit to heads\"), REF_HEADS),\n+\t\tOPT_SET_INT(0, \"refs\", &refs, N_(\"no magic fake tag refs\"), REF_NORMAL),\n+\t\tOPT_SET_INT(0, \"get-url\", &get_url,\n+\t\t\t    N_(\"take url.<base>.insteadOf into account\"), 1),\n+\t\tOPT_SET_INT(0, \"exit-code\", &status,\n+\t\t\t    N_(\"exit with exit code 2 if no matching refs are found\"), 2),\n+\t\tOPT_END()\n+\t};\n \n-\tfor (i = 1; i < argc; i++) {\n-\t\tconst char *arg = argv[i];\n+\targc = parse_options(argc, argv, prefix, options, ls_remote_usage,\n+\t\t\t     PARSE_OPT_STOP_AT_NON_OPTION);\n+\tflags = tags | heads | refs;\n+\tdest = argv[0];\n \n-\t\tif (*arg == '-') {\n-\t\t\tif (starts_with(arg, \"--upload-pack=\")) {\n-\t\t\t\tuploadpack = arg + 14;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (starts_with(arg, \"--exec=\")) {\n-\t\t\t\tuploadpack = arg + 7;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--tags\", arg) || !strcmp(\"-t\", arg)) {\n-\t\t\t\tflags |= REF_TAGS;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--heads\", arg) || !strcmp(\"-h\", arg)) {\n-\t\t\t\tflags |= REF_HEADS;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--refs\", arg)) {\n-\t\t\t\tflags |= REF_NORMAL;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--quiet\", arg) || !strcmp(\"-q\", arg)) {\n-\t\t\t\tquiet = 1;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--get-url\", arg)) {\n-\t\t\t\tget_url = 1;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--exit-code\", arg)) {\n-\t\t\t\t/* return this code if no refs are reported */\n-\t\t\t\tstatus = 2;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tusage(ls_remote_usage);\n-\t\t}\n-\t\tdest = arg;\n-\t\ti++;\n-\t\tbreak;\n+\tif (argc > 1) {\n+\t\tint i;\n+\t\tpattern = xcalloc(argc, sizeof(const char *));\n+\t\tfor (i = 1; i < argc; i++)\n+\t\t\tpattern[i - 1] = xstrfmt(\"*/%s\", argv[i]);\n \t}\n \n-\tif (argv[i]) {\n-\t\tint j;\n-\t\tpattern = xcalloc(argc - i + 1, sizeof(const char *));\n-\t\tfor (j = i; j < argc; j++)\n-\t\t\tpattern[j - i] = xstrfmt(\"*/%s\", argv[j]);\n-\t}\n \tremote = remote_get(dest);\n \tif (!remote) {\n \t\tif (dest)\n-- \n2.7.0.14.g2b6d3d6\n"},{"id":"276238","messageId":"1453028643-13978-5-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453028643-13978-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH 4/4] builtin/ls-remote: add support for showing symrefs","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-17T11:04:02Z","receivedAt":"2016-01-17T11:04:02Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"Sometimes it's useful to know the main branch of a git repository\nwithout actually downloading the repository.  This can be done by\nlooking at the symrefs stored in the remote repository.  Currently git\ndoesn't provide a simple way to show the symrefs stored on the remote\nrepository, even though the information is available.  Add a --symrefs\ncommand line argument to the ls-remote command, which shows the symrefs\non the remote repository.\n\nSuggested-by: pedro rijo <pedrorijo91@gmail.com>\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n Documentation/git-ls-remote.txt |  8 +++++++-\n builtin/ls-remote.c             |  9 ++++++++-\n t/t5512-ls-remote.sh            | 20 ++++++++++++++++++++\n 3 files changed, 35 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\nindex 31c1427..5efef9e 100644\n--- a/Documentation/git-ls-remote.txt\n+++ b/Documentation/git-ls-remote.txt\n@@ -10,7 +10,8 @@ SYNOPSIS\n --------\n [verse]\n 'git ls-remote' [--heads] [--tags]  [--upload-pack=<exec>]\n-\t      [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\n+\t      [-q | --quiet] [--exit-code]\n+\t      [--symrefs] [--get-url] [<repository> [<refs>...]]\n \n DESCRIPTION\n -----------\n@@ -50,6 +51,11 @@ OPTIONS\n \t\"url.<base>.insteadOf\" config setting (See linkgit:git-config[1]) and\n \texit without talking to the remote.\n \n+--symrefs::\n+\tShow the symrefs on the server.  Shows only the symrefs by\n+\tdefault, and can be combined with --tags and --heads to show\n+\trefs/heads and refs/tags as well.\n+\n <repository>::\n \tThe \"remote\" repository to query.  This parameter can be\n \teither a URL or the name of a remote (see the GIT URLS and\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 6ee7b0e..f33ada9 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -5,7 +5,8 @@\n \n static const char * const ls_remote_usage[] = {\n \tN_(\"git ls-remote [--heads] [--tags]  [--upload-pack=<exec>]\\n\"\n-\t   \"                     [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\"),\n+\t   \"                     [-q | --quiet] [--exit-code] [--get-url]\\n\"\n+\t   \"                     [--symrefs] [<repository> [<refs>...]]\"),\n \tNULL\n };\n \n@@ -38,6 +39,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tint quiet = 0;\n \tint status = 0;\n \tint tags = 0, heads = 0, refs = 0;\n+\tint symrefs = 0;\n \tconst char *uploadpack = NULL;\n \tconst char **pattern = NULL;\n \n@@ -58,6 +60,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\t\t    N_(\"take url.<base>.insteadOf into account\"), 1),\n \t\tOPT_SET_INT(0, \"exit-code\", &status,\n \t\t\t    N_(\"exit with exit code 2 if no matching refs are found\"), 2),\n+\t\tOPT_BOOL(0, \"symrefs\", &symrefs, N_(\"show symrefs\")),\n \t\tOPT_END()\n \t};\n \n@@ -98,6 +101,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tif (!dest && !quiet)\n \t\tfprintf(stderr, \"From %s\\n\", *remote->url);\n \tfor ( ; ref; ref = ref->next) {\n+\t\tif (symrefs && ref->symref)\n+\t\t\tprintf(\"symref: %s\t%s\\n\", ref->symref, ref->name);\n+\t\tif (symrefs && !flags)\n+\t\t\tcontinue;\n \t\tif (!check_ref_type(ref, flags))\n \t\t\tcontinue;\n \t\tif (!tail_match(pattern, ref->name))\ndiff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh\nindex aadaac5..68a1429 100755\n--- a/t/t5512-ls-remote.sh\n+++ b/t/t5512-ls-remote.sh\n@@ -163,4 +163,24 @@ test_expect_success 'overrides work between mixed transfer/upload-pack hideRefs'\n \tgrep refs/tags/magic actual\n '\n \n+test_expect_success 'ls-remote --symrefs' '\n+\tcat >expect <<-EOF &&\n+\tsymref: refs/heads/master\tHEAD\n+\tEOF\n+\tgit ls-remote --symrefs >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'ls-remote with symrefs and refs combined' '\n+\tcat >expect <<-EOF &&\n+\tsymref: refs/heads/master\tHEAD\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/HEAD\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/master\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/tags/mark\n+\tEOF\n+\tgit ls-remote --symrefs --refs >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n2.7.0.14.g2b6d3d6\n"},{"id":"276239","messageId":"1453028643-13978-6-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453028643-13978-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH 4/4] ls-remote: add support for showing symrefs","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-17T11:04:03Z","receivedAt":"2016-01-17T11:04:03Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"Sometimes it's useful to know the main branch of a git repository\nwithout actually downloading the repository.  This can be done by\nlooking at the symrefs stored in the remote repository.  Currently git\ndoesn't provide a simple way to show the symrefs stored on the remote\nrepository, even though the information is available.  Add a --symrefs\ncommand line argument to the ls-remote command, which shows the symrefs\non the remote repository.\n\nThe new argument works similar to the --heads and --tags arguments.\nWhen only --symrefs is given, only the symrefs are shown.  It can\nhowever be combined with the --refs, --heads or --tags arguments, to\nshow all refs, heads, or tags as well.\n\nSuggested-by: pedro rijo <pedrorijo91@gmail.com>\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n Documentation/git-ls-remote.txt |  8 +++++++-\n builtin/ls-remote.c             |  9 ++++++++-\n t/t5512-ls-remote.sh            | 20 ++++++++++++++++++++\n 3 files changed, 35 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\nindex 31c1427..5b606dd 100644\n--- a/Documentation/git-ls-remote.txt\n+++ b/Documentation/git-ls-remote.txt\n@@ -10,7 +10,8 @@ SYNOPSIS\n --------\n [verse]\n 'git ls-remote' [--heads] [--tags]  [--upload-pack=<exec>]\n-\t      [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\n+\t      [-q | --quiet] [--exit-code] [--get-url]\n+\t      [--symrefs] [<repository> [<refs>...]]\n \n DESCRIPTION\n -----------\n@@ -50,6 +51,11 @@ OPTIONS\n \t\"url.<base>.insteadOf\" config setting (See linkgit:git-config[1]) and\n \texit without talking to the remote.\n \n+--symrefs::\n+\tShow the symrefs on the server.  Shows only the symrefs by\n+\tdefault, and can be combined with --tags and --heads to show\n+\trefs/heads and refs/tags as well.\n+\n <repository>::\n \tThe \"remote\" repository to query.  This parameter can be\n \teither a URL or the name of a remote (see the GIT URLS and\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 6ee7b0e..f33ada9 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -5,7 +5,8 @@\n \n static const char * const ls_remote_usage[] = {\n \tN_(\"git ls-remote [--heads] [--tags]  [--upload-pack=<exec>]\\n\"\n-\t   \"                     [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\"),\n+\t   \"                     [-q | --quiet] [--exit-code] [--get-url]\\n\"\n+\t   \"                     [--symrefs] [<repository> [<refs>...]]\"),\n \tNULL\n };\n \n@@ -38,6 +39,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tint quiet = 0;\n \tint status = 0;\n \tint tags = 0, heads = 0, refs = 0;\n+\tint symrefs = 0;\n \tconst char *uploadpack = NULL;\n \tconst char **pattern = NULL;\n \n@@ -58,6 +60,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\t\t    N_(\"take url.<base>.insteadOf into account\"), 1),\n \t\tOPT_SET_INT(0, \"exit-code\", &status,\n \t\t\t    N_(\"exit with exit code 2 if no matching refs are found\"), 2),\n+\t\tOPT_BOOL(0, \"symrefs\", &symrefs, N_(\"show symrefs\")),\n \t\tOPT_END()\n \t};\n \n@@ -98,6 +101,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tif (!dest && !quiet)\n \t\tfprintf(stderr, \"From %s\\n\", *remote->url);\n \tfor ( ; ref; ref = ref->next) {\n+\t\tif (symrefs && ref->symref)\n+\t\t\tprintf(\"symref: %s\t%s\\n\", ref->symref, ref->name);\n+\t\tif (symrefs && !flags)\n+\t\t\tcontinue;\n \t\tif (!check_ref_type(ref, flags))\n \t\t\tcontinue;\n \t\tif (!tail_match(pattern, ref->name))\ndiff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh\nindex aadaac5..68a1429 100755\n--- a/t/t5512-ls-remote.sh\n+++ b/t/t5512-ls-remote.sh\n@@ -163,4 +163,24 @@ test_expect_success 'overrides work between mixed transfer/upload-pack hideRefs'\n \tgrep refs/tags/magic actual\n '\n \n+test_expect_success 'ls-remote --symrefs' '\n+\tcat >expect <<-EOF &&\n+\tsymref: refs/heads/master\tHEAD\n+\tEOF\n+\tgit ls-remote --symrefs >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'ls-remote with symrefs and refs combined' '\n+\tcat >expect <<-EOF &&\n+\tsymref: refs/heads/master\tHEAD\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/HEAD\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/master\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/tags/mark\n+\tEOF\n+\tgit ls-remote --symrefs --refs >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n2.7.0.14.g2b6d3d6\n"},{"id":"276240","messageId":"20160117111433.GA7100@hank","threadId":"41208","inReplyTo":"1453028643-13978-1-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH 0/4] ls-remote: introduce symref argument","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-17T11:14:33Z","receivedAt":"2016-01-17T11:14:33Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"On 01/17, Thomas Gummerer wrote:\n> > I thought it might be nice for any porcelain which tries to wrap\n> > `ls-remote`, make some decision based on the capabilities, and then\n> > invoke another plumbing command. But I guess that is probably slightly\n> > crazy, and nobody is doing it.\n> >\n> > Something like `ls-remote --symrefs` probably would be a better place to\n> > start.\n>\n> Turns out adding this is pretty simple.\n>\n> The first two patches are documentation, which I noticed when reading\n> up about the command.  Patch three is a cleanup patch, which makes\n> ls-remote use the parse-options api instead of the hand-rolled option\n> parser.  Patch four is actually adding the option.\n\nSorry, I forgot to add --in-reply-to to git-send email.  For\nreference, the thread that got me to do this patch series is at\nhttp://thread.gmane.org/gmane.comp.version-control.git/284075.\n\n> Thomas Gummerer (4):\n>   ls-remote: document --quiet option\n>   ls-remote: fix synopsis\n>   ls-remote: use parse-options api\n>   ls-remote: add support for showing symrefs\n>\n>  Documentation/git-ls-remote.txt | 12 +++++-\n>  builtin/ls-remote.c             | 90 +++++++++++++++++------------------------\n>  t/t5512-ls-remote.sh            | 20 +++++++++\n>  3 files changed, 68 insertions(+), 54 deletions(-)\n>\n> --\n> 2.7.0.14.g2b6d3d6\n>\n"},{"id":"276241","messageId":"20160117111621.GB7100@hank","threadId":"41208","inReplyTo":"1453028643-13978-5-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH 4/4] builtin/ls-remote: add support for showing symrefs","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-17T11:16:21Z","receivedAt":"2016-01-17T11:16:21Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"On 01/17, Thomas Gummerer wrote:\n> Sometimes it's useful to know the main branch of a git repository\n> without actually downloading the repository.  This can be done by\n> looking at the symrefs stored in the remote repository.  Currently git\n> doesn't provide a simple way to show the symrefs stored on the remote\n> repository, even though the information is available.  Add a --symrefs\n> command line argument to the ls-remote command, which shows the symrefs\n> on the remote repository.\n>\n> Suggested-by: pedro rijo <pedrorijo91@gmail.com>\n> Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n> ---\n\nI meant to delete this, the other 4/4 has the re-worded commit\nmessage.  Please ignore this one.\n\n>  Documentation/git-ls-remote.txt |  8 +++++++-\n>  builtin/ls-remote.c             |  9 ++++++++-\n>  t/t5512-ls-remote.sh            | 20 ++++++++++++++++++++\n>  3 files changed, 35 insertions(+), 2 deletions(-)\n>\n> diff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\n> index 31c1427..5efef9e 100644\n> --- a/Documentation/git-ls-remote.txt\n> +++ b/Documentation/git-ls-remote.txt\n> @@ -10,7 +10,8 @@ SYNOPSIS\n>  --------\n>  [verse]\n>  'git ls-remote' [--heads] [--tags]  [--upload-pack=<exec>]\n> -\t      [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\n> +\t      [-q | --quiet] [--exit-code]\n> +\t      [--symrefs] [--get-url] [<repository> [<refs>...]]\n>\n>  DESCRIPTION\n>  -----------\n> @@ -50,6 +51,11 @@ OPTIONS\n>  \t\"url.<base>.insteadOf\" config setting (See linkgit:git-config[1]) and\n>  \texit without talking to the remote.\n>\n> +--symrefs::\n> +\tShow the symrefs on the server.  Shows only the symrefs by\n> +\tdefault, and can be combined with --tags and --heads to show\n> +\trefs/heads and refs/tags as well.\n> +\n>  <repository>::\n>  \tThe \"remote\" repository to query.  This parameter can be\n>  \teither a URL or the name of a remote (see the GIT URLS and\n> diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\n> index 6ee7b0e..f33ada9 100644\n> --- a/builtin/ls-remote.c\n> +++ b/builtin/ls-remote.c\n> @@ -5,7 +5,8 @@\n>\n>  static const char * const ls_remote_usage[] = {\n>  \tN_(\"git ls-remote [--heads] [--tags]  [--upload-pack=<exec>]\\n\"\n> -\t   \"                     [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\"),\n> +\t   \"                     [-q | --quiet] [--exit-code] [--get-url]\\n\"\n> +\t   \"                     [--symrefs] [<repository> [<refs>...]]\"),\n>  \tNULL\n>  };\n>\n> @@ -38,6 +39,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n>  \tint quiet = 0;\n>  \tint status = 0;\n>  \tint tags = 0, heads = 0, refs = 0;\n> +\tint symrefs = 0;\n>  \tconst char *uploadpack = NULL;\n>  \tconst char **pattern = NULL;\n>\n> @@ -58,6 +60,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n>  \t\t\t    N_(\"take url.<base>.insteadOf into account\"), 1),\n>  \t\tOPT_SET_INT(0, \"exit-code\", &status,\n>  \t\t\t    N_(\"exit with exit code 2 if no matching refs are found\"), 2),\n> +\t\tOPT_BOOL(0, \"symrefs\", &symrefs, N_(\"show symrefs\")),\n>  \t\tOPT_END()\n>  \t};\n>\n> @@ -98,6 +101,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n>  \tif (!dest && !quiet)\n>  \t\tfprintf(stderr, \"From %s\\n\", *remote->url);\n>  \tfor ( ; ref; ref = ref->next) {\n> +\t\tif (symrefs && ref->symref)\n> +\t\t\tprintf(\"symref: %s\t%s\\n\", ref->symref, ref->name);\n> +\t\tif (symrefs && !flags)\n> +\t\t\tcontinue;\n>  \t\tif (!check_ref_type(ref, flags))\n>  \t\t\tcontinue;\n>  \t\tif (!tail_match(pattern, ref->name))\n> diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh\n> index aadaac5..68a1429 100755\n> --- a/t/t5512-ls-remote.sh\n> +++ b/t/t5512-ls-remote.sh\n> @@ -163,4 +163,24 @@ test_expect_success 'overrides work between mixed transfer/upload-pack hideRefs'\n>  \tgrep refs/tags/magic actual\n>  '\n>\n> +test_expect_success 'ls-remote --symrefs' '\n> +\tcat >expect <<-EOF &&\n> +\tsymref: refs/heads/master\tHEAD\n> +\tEOF\n> +\tgit ls-remote --symrefs >actual &&\n> +\ttest_cmp expect actual\n> +'\n> +\n> +test_expect_success 'ls-remote with symrefs and refs combined' '\n> +\tcat >expect <<-EOF &&\n> +\tsymref: refs/heads/master\tHEAD\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/HEAD\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/master\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/tags/mark\n> +\tEOF\n> +\tgit ls-remote --symrefs --refs >actual &&\n> +\ttest_cmp expect actual\n> +'\n> +\n>  test_done\n> --\n> 2.7.0.14.g2b6d3d6\n>\n\n--\nThomas Gummerer\n"},{"id":"276242","messageId":"20160117144409.GA15519@sigill.intra.peff.net","threadId":"41208","inReplyTo":"1453028643-13978-4-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH 3/4] ls-remote: use parse-options api","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-01-17T14:44:09Z","receivedAt":"2016-01-17T14:44:09Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Jan 17, 2016 at 12:04:01PM +0100, Thomas Gummerer wrote:\n\n> Currently ls-remote uses a hand rolled parser for the its command line\n> arguments.  Use the parse-options api instead of the hand rolled parser\n> to simplify the code and make it easier to add new arguments.  In\n> addition this improves the help message.\n\nSounds like a good idea.\n\n> +\tint tags = 0, heads = 0, refs = 0;\n> [...]\n> +\t\tOPT_SET_INT('t', \"tags\", &tags, N_(\"limit to tags\"), REF_TAGS),\n> +\t\tOPT_SET_INT('h', \"heads\", &heads, N_(\"limit to heads\"), REF_HEADS),\n> +\t\tOPT_SET_INT(0, \"refs\", &refs, N_(\"no magic fake tag refs\"), REF_NORMAL),\n> [...]\n> +\tflags = tags | heads | refs;\n\nIs there any reason these can't be:\n\n  OPT_BIT('t', \"tags\", &flags, N_(\"limit to tags\"), REF_TAGS),\n  OPT_BIT('h', \"heads\", &flags, N_(\"limit to heads\"), REF_HEADS),\n  OPT_BIT(0, \"refs\", &flags, N_(\"no magic fake tag refs\"), REF_NORMAL),\n\nto make their interaction more obvious? I wondered if there was\nanything tricky going on (like some of the bits for each option\noverlapping), but I didn't see anything.\n\n> +\t\tOPT_SET_INT(0, \"refs\", &refs, N_(\"no magic fake tag refs\"), REF_NORMAL),\n\nI imagine you took the help string from the comment in check_ref. We can\nprobably come up with something more descriptive for the user-facing\nstring. :) How about \"do not show peeled tags\"?\n\n> +\t\tOPT_STRING(0, \"upload-pack\", &uploadpack, N_(\"exec\"),\n> +\t\t\t   N_(\"path of git-upload-pack on the remote host\")),\n> +\t\tOPT_STRING(0, \"exec\", &uploadpack, N_(\"exec\"),\n> +\t\t\t   N_(\"path of git-upload-pack on the remote host\")),\n\nSince these are redundant with each other, should we declare one\n\"hidden\" to not appear in \"-h\" output?\n\n> +\t\tOPT_SET_INT(0, \"get-url\", &get_url,\n> +\t\t\t    N_(\"take url.<base>.insteadOf into account\"), 1),\n\nShould this one be OPT_BOOL? I think \"--no-get-url\" works either way (it\nresets the variable to 0), but OPT_BOOL communicates the intent more\nclearly, I think.\n\n> +\t\tOPT_SET_INT(0, \"exit-code\", &status,\n> +\t\t\t    N_(\"exit with exit code 2 if no matching refs are found\"), 2),\n\nThis one can't be OPT_BOOL, obviously. What happens with\n\"--no-exit-code\"? We'll set it back to \"0\", which I think is the right\nthing to do. Good.\n\nThe rest of the patch looked good to me.\n\n-Peff\n"},{"id":"276243","messageId":"20160117144726.GB15519@sigill.intra.peff.net","threadId":"41208","inReplyTo":"1453028643-13978-2-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH 1/4] ls-remote: document --quiet option","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-01-17T14:47:26Z","receivedAt":"2016-01-17T14:47:26Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Jan 17, 2016 at 12:03:59PM +0100, Thomas Gummerer wrote:\n\n> cefb2a5e3 (\"ls-remote: print URL when no repo is specified\") added a\n> quiet option to ls-remote, but didn't add it to the documentation.  Add\n> it.\n\nGreat. I love it when a patch series starts by tidying up the area.\n\nThe patch looks obviously correct. Should we do the same for \"--refs\",\nwhich looks like the only other undocumented option (aside from --exec,\nbut I think that's just for historical compatibility).\n\n-Peff\n"},{"id":"276244","messageId":"20160117151510.GC15519@sigill.intra.peff.net","threadId":"41208","inReplyTo":"1453028643-13978-6-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH 4/4] ls-remote: add support for showing symrefs","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-01-17T15:15:10Z","receivedAt":"2016-01-17T15:15:10Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Jan 17, 2016 at 12:04:03PM +0100, Thomas Gummerer wrote:\n\n> Sometimes it's useful to know the main branch of a git repository\n> without actually downloading the repository.  This can be done by\n> looking at the symrefs stored in the remote repository.  Currently git\n> doesn't provide a simple way to show the symrefs stored on the remote\n> repository, even though the information is available.  Add a --symrefs\n> command line argument to the ls-remote command, which shows the symrefs\n> on the remote repository.\n> \n> The new argument works similar to the --heads and --tags arguments.\n> When only --symrefs is given, only the symrefs are shown.  It can\n> however be combined with the --refs, --heads or --tags arguments, to\n> show all refs, heads, or tags as well.\n\nI would have expected --symrefs to be \"also show symref destinations for\nrefs we are showing\" and not otherwise affect the set of refs we pick.\nThat would make:\n\n  git ls-remote --symrefs\n\nshow everything, including symrefs and peeled tags (which I think is not\npossible with your patch). It would also make:\n\n  git ls-remote --symrefs --heads\n\nshow symrefs and refs in refs/heads, but _not_ show symrefs outside\nof refs/heads.\n\nOn the flip side, though, it does not provide a way to just get the\nsymrefs without any other output. But I think if you just want a specific\nsymref (say, HEAD), you can ask for it:\n\n  git ls-remote --symrefs $remote HEAD\n\nThis is all somewhat moot, perhaps, as the server side currently only\nshares symref information for HEAD. But that may change in the future\n(it's a limitation of the current protocol).\n\nI'm also somewhat doubtful that people regularly use ls-remote much at\nall these days, let alone with \"--heads\" or \"--tags\". So it's hard to\ncome up with concrete use cases for any of this. The above is just what\nI would expect for general flexibility and consistency with other\ncommands.\n\n> ---\n>  Documentation/git-ls-remote.txt |  8 +++++++-\n>  builtin/ls-remote.c             |  9 ++++++++-\n>  t/t5512-ls-remote.sh            | 20 ++++++++++++++++++++\n\nDocumentation _and_ tests. Yay. :)\n\n> @@ -98,6 +101,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n>  \tif (!dest && !quiet)\n>  \t\tfprintf(stderr, \"From %s\\n\", *remote->url);\n>  \tfor ( ; ref; ref = ref->next) {\n> +\t\tif (symrefs && ref->symref)\n> +\t\t\tprintf(\"symref: %s\t%s\\n\", ref->symref, ref->name);\n\nI assume that's a raw tab in the string. Please use \"\\t\", which makes it\nmore obvious to readers what is going on.\n\nSince this output is only triggered by a new option, we're not\nconstrained by compatibility in the output. But I think it's still a\ngood idea to keep the general \"<content>\\t<refname>\" pattern set by the\nother lines, as you did.\n\nHere's my obligatory bikeshedding for the format. Feel free to ignore.\n\nI wondered if just:\n\n  refs/heads/master       HEAD\n  1bd44cb9d13204b0fe1958db0082f5028a16eb3a       refs/heads/master\n\nwould look nicer. It is technically ambiguous if a symref can point to a\n40-hex refname. They generally will start with refs/, but I'm not sure\nthat is strict requirement. It also makes it harder to add other output\nlater if we choose to. So some kind of keyword like \"symref:\" is a good\nidea.\n\nWe could also do it as:\n\n  ref: refs/heads/master     HEAD\n\nwhich matches the symref format itself. I guess that doesn't really\nmatter here, but somehow it seems more aesthetically pleasing to me.\n\nThe output would look a lot nicer for humans if we right-padded the\nsymref destination to match the 40-hex that is on all the other lines\n(so all of the refnames line up).  But that makes machine-parsing a lot\nharder. We could do something clever with isatty(1), but I don't think\nit's worth the effort.\n\n> +test_expect_success 'ls-remote with symrefs and refs combined' '\n> +\tcat >expect <<-EOF &&\n> +\tsymref: refs/heads/master\tHEAD\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/HEAD\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/master\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/tags/mark\n> +\tEOF\n\nI expected there to be a:\n\n  1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n\nline. It's technically redundant, since the caller can dereference\nrefs/heads/master themselves, but it potentially makes things easier for\na caller. I realized why it isn't here, though. We print all symrefs,\nregardless of whether they match the flags, but \"HEAD\" doesn't match\n\"--refs\", so we don't show its value.  Under the semantics I proposed\nabove, \"ls-remote --symrefs\" would show both.\n\n-Peff\n"},{"id":"276245","messageId":"20160117151622.GD15519@sigill.intra.peff.net","threadId":"41208","inReplyTo":"1453028643-13978-1-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH 0/4] ls-remote: introduce symref argument","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-01-17T15:16:23Z","receivedAt":"2016-01-17T15:16:23Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Jan 17, 2016 at 12:03:58PM +0100, Thomas Gummerer wrote:\n\n> > I thought it might be nice for any porcelain which tries to wrap\n> > `ls-remote`, make some decision based on the capabilities, and then\n> > invoke another plumbing command. But I guess that is probably slightly\n> > crazy, and nobody is doing it.\n> > \n> > Something like `ls-remote --symrefs` probably would be a better place to\n> > start.\n> \n> Turns out adding this is pretty simple.\n> \n> The first two patches are documentation, which I noticed when reading\n> up about the command.  Patch three is a cleanup patch, which makes\n> ls-remote use the parse-options api instead of the hand-rolled option\n> parser.  Patch four is actually adding the option.\n> \n> Thomas Gummerer (4):\n>   ls-remote: document --quiet option\n>   ls-remote: fix synopsis\n>   ls-remote: use parse-options api\n>   ls-remote: add support for showing symrefs\n> \n>  Documentation/git-ls-remote.txt | 12 +++++-\n>  builtin/ls-remote.c             | 90 +++++++++++++++++------------------------\n>  t/t5512-ls-remote.sh            | 20 +++++++++\n>  3 files changed, 68 insertions(+), 54 deletions(-)\n\nThanks for working on this. One of my favorite things about open source\nis when I realize I'm too lazy/busy to work on something, and then it\nmagically appears in my inbox. :)\n\nThis looks like a good start. I left a few comments on the specific\npatches.\n\n-Peff\n"},{"id":"276247","messageId":"20160117171354.GC7100@hank","threadId":"41208","inReplyTo":"20160117144726.GB15519@sigill.intra.peff.net","subject":"Re: [PATCH 1/4] ls-remote: document --quiet option","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-17T17:13:54Z","receivedAt":"2016-01-17T17:13:54Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"On 01/17, Jeff King wrote:\n> On Sun, Jan 17, 2016 at 12:03:59PM +0100, Thomas Gummerer wrote:\n>\n> > cefb2a5e3 (\"ls-remote: print URL when no repo is specified\") added a\n> > quiet option to ls-remote, but didn't add it to the documentation.  Add\n> > it.\n>\n> Great. I love it when a patch series starts by tidying up the area.\n>\n> The patch looks obviously correct. Should we do the same for \"--refs\",\n> which looks like the only other undocumented option (aside from --exec,\n> but I think that's just for historical compatibility).\n\nSounds like a good idea.  I will add a patch for that.\n\n>\n> -Peff\n\n--\nThomas\n"},{"id":"276248","messageId":"20160117172706.GD7100@hank","threadId":"41208","inReplyTo":"20160117144409.GA15519@sigill.intra.peff.net","subject":"Re: [PATCH 3/4] ls-remote: use parse-options api","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-17T17:27:06Z","receivedAt":"2016-01-17T17:27:06Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"On 01/17, Jeff King wrote:\n> On Sun, Jan 17, 2016 at 12:04:01PM +0100, Thomas Gummerer wrote:\n>\n> > Currently ls-remote uses a hand rolled parser for the its command line\n> > arguments.  Use the parse-options api instead of the hand rolled parser\n> > to simplify the code and make it easier to add new arguments.  In\n> > addition this improves the help message.\n>\n> Sounds like a good idea.\n>\n> > +\tint tags = 0, heads = 0, refs = 0;\n> > [...]\n> > +\t\tOPT_SET_INT('t', \"tags\", &tags, N_(\"limit to tags\"), REF_TAGS),\n> > +\t\tOPT_SET_INT('h', \"heads\", &heads, N_(\"limit to heads\"), REF_HEADS),\n> > +\t\tOPT_SET_INT(0, \"refs\", &refs, N_(\"no magic fake tag refs\"), REF_NORMAL),\n> > [...]\n> > +\tflags = tags | heads | refs;\n>\n> Is there any reason these can't be:\n>\n>   OPT_BIT('t', \"tags\", &flags, N_(\"limit to tags\"), REF_TAGS),\n>   OPT_BIT('h', \"heads\", &flags, N_(\"limit to heads\"), REF_HEADS),\n>   OPT_BIT(0, \"refs\", &flags, N_(\"no magic fake tag refs\"), REF_NORMAL),\n>\n> to make their interaction more obvious? I wondered if there was\n> anything tricky going on (like some of the bits for each option\n> overlapping), but I didn't see anything.\n\nI was looking for something like this, but totally overlooked it when\ngoing through the docs.  Thanks, will change.\n\n> > +\t\tOPT_SET_INT(0, \"refs\", &refs, N_(\"no magic fake tag refs\"), REF_NORMAL),\n>\n> I imagine you took the help string from the comment in check_ref. We can\n> probably come up with something more descriptive for the user-facing\n> string. :) How about \"do not show peeled tags\"?\n\nIndeed, I wasn't really happy about it, but couldn't come up with\nanything better.  Your version sounds much better, will fix.\n\n> > +\t\tOPT_STRING(0, \"upload-pack\", &uploadpack, N_(\"exec\"),\n> > +\t\t\t   N_(\"path of git-upload-pack on the remote host\")),\n> > +\t\tOPT_STRING(0, \"exec\", &uploadpack, N_(\"exec\"),\n> > +\t\t\t   N_(\"path of git-upload-pack on the remote host\")),\n>\n> Since these are redundant with each other, should we declare one\n> \"hidden\" to not appear in \"-h\" output?\n\nMakes sense, I'll declare the exec option as hidden, as that's the one\nthat's not documented anywhere else either.\n\n> > +\t\tOPT_SET_INT(0, \"get-url\", &get_url,\n> > +\t\t\t    N_(\"take url.<base>.insteadOf into account\"), 1),\n>\n> Should this one be OPT_BOOL? I think \"--no-get-url\" works either way (it\n> resets the variable to 0), but OPT_BOOL communicates the intent more\n> clearly, I think.\n\nMakes sense, will change in the re-roll.\n\n>\n> > +\t\tOPT_SET_INT(0, \"exit-code\", &status,\n> > +\t\t\t    N_(\"exit with exit code 2 if no matching refs are found\"), 2),\n>\n> This one can't be OPT_BOOL, obviously. What happens with\n> \"--no-exit-code\"? We'll set it back to \"0\", which I think is the right\n> thing to do. Good.\n>\n> The rest of the patch looked good to me.\n\nThanks for the review!\n\n>\n> -Peff\n\n--\nThomas\n"},{"id":"276249","messageId":"20160117173822.GE7100@hank","threadId":"41208","inReplyTo":"20160117151510.GC15519@sigill.intra.peff.net","subject":"Re: [PATCH 4/4] ls-remote: add support for showing symrefs","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-17T17:38:22Z","receivedAt":"2016-01-17T17:38:22Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"On 01/17, Jeff King wrote:\n> On Sun, Jan 17, 2016 at 12:04:03PM +0100, Thomas Gummerer wrote:\n>\n> > Sometimes it's useful to know the main branch of a git repository\n> > without actually downloading the repository.  This can be done by\n> > looking at the symrefs stored in the remote repository.  Currently git\n> > doesn't provide a simple way to show the symrefs stored on the remote\n> > repository, even though the information is available.  Add a --symrefs\n> > command line argument to the ls-remote command, which shows the symrefs\n> > on the remote repository.\n> >\n> > The new argument works similar to the --heads and --tags arguments.\n> > When only --symrefs is given, only the symrefs are shown.  It can\n> > however be combined with the --refs, --heads or --tags arguments, to\n> > show all refs, heads, or tags as well.\n>\n> I would have expected --symrefs to be \"also show symref destinations for\n> refs we are showing\" and not otherwise affect the set of refs we pick.\n> That would make:\n>\n>   git ls-remote --symrefs\n>\n> show everything, including symrefs and peeled tags (which I think is not\n> possible with your patch). It would also make:\n>\n>   git ls-remote --symrefs --heads\n>\n> show symrefs and refs in refs/heads, but _not_ show symrefs outside\n> of refs/heads.\n>\n> On the flip side, though, it does not provide a way to just get the\n> symrefs without any other output.\n\nThat's why I decided to implement it this way.  However I think the\nbelow makes sense, so I'll change the behavior in the re-roll.  In\ncase we really want to have only symrefs we could still introduce\nsomething like --symrefs-only, though I'm doubtful we'll need that.\n\n> But I think if you just want a specific\n> symref (say, HEAD), you can ask for it:\n>\n>   git ls-remote --symrefs $remote HEAD\n>\n> This is all somewhat moot, perhaps, as the server side currently only\n> shares symref information for HEAD. But that may change in the future\n> (it's a limitation of the current protocol).\n>\n> I'm also somewhat doubtful that people regularly use ls-remote much at\n> all these days, let alone with \"--heads\" or \"--tags\". So it's hard to\n> come up with concrete use cases for any of this. The above is just what\n> I would expect for general flexibility and consistency with other\n> commands.\n>\n> > ---\n> >  Documentation/git-ls-remote.txt |  8 +++++++-\n> >  builtin/ls-remote.c             |  9 ++++++++-\n> >  t/t5512-ls-remote.sh            | 20 ++++++++++++++++++++\n>\n> Documentation _and_ tests. Yay. :)\n>\n> > @@ -98,6 +101,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n> >  \tif (!dest && !quiet)\n> >  \t\tfprintf(stderr, \"From %s\\n\", *remote->url);\n> >  \tfor ( ; ref; ref = ref->next) {\n> > +\t\tif (symrefs && ref->symref)\n> > +\t\t\tprintf(\"symref: %s\t%s\\n\", ref->symref, ref->name);\n>\n> I assume that's a raw tab in the string. Please use \"\\t\", which makes it\n> more obvious to readers what is going on.\n\nThanks, will change.\n\n> Since this output is only triggered by a new option, we're not\n> constrained by compatibility in the output. But I think it's still a\n> good idea to keep the general \"<content>\\t<refname>\" pattern set by the\n> other lines, as you did.\n>\n> Here's my obligatory bikeshedding for the format. Feel free to ignore.\n>\n> I wondered if just:\n>\n>   refs/heads/master       HEAD\n>   1bd44cb9d13204b0fe1958db0082f5028a16eb3a       refs/heads/master\n>\n> would look nicer. It is technically ambiguous if a symref can point to a\n> 40-hex refname. They generally will start with refs/, but I'm not sure\n> that is strict requirement. It also makes it harder to add other output\n> later if we choose to. So some kind of keyword like \"symref:\" is a good\n> idea.\n>\n> We could also do it as:\n>\n>   ref: refs/heads/master     HEAD\n>\n> which matches the symref format itself. I guess that doesn't really\n> matter here, but somehow it seems more aesthetically pleasing to me.\n\nI like this format the most so far, so unless I hear any objections\nI'll do this.\n\n> The output would look a lot nicer for humans if we right-padded the\n> symref destination to match the 40-hex that is on all the other lines\n> (so all of the refnames line up).  But that makes machine-parsing a lot\n> harder. We could do something clever with isatty(1), but I don't think\n> it's worth the effort.\n>\n> > +test_expect_success 'ls-remote with symrefs and refs combined' '\n> > +\tcat >expect <<-EOF &&\n> > +\tsymref: refs/heads/master\tHEAD\n> > +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n> > +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/HEAD\n> > +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/master\n> > +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/tags/mark\n> > +\tEOF\n>\n> I expected there to be a:\n>\n>   1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n>\n> line. It's technically redundant, since the caller can dereference\n> refs/heads/master themselves, but it potentially makes things easier for\n> a caller. I realized why it isn't here, though. We print all symrefs,\n> regardless of whether they match the flags, but \"HEAD\" doesn't match\n> \"--refs\", so we don't show its value.  Under the semantics I proposed\n> above, \"ls-remote --symrefs\" would show both.\n>\n> -Peff\n\n--\nThomas\n"},{"id":"276250","messageId":"20160117173952.GF7100@hank","threadId":"41208","inReplyTo":"20160117151622.GD15519@sigill.intra.peff.net","subject":"Re: [PATCH 0/4] ls-remote: introduce symref argument","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-17T17:39:52Z","receivedAt":"2016-01-17T17:39:52Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"On 01/17, Jeff King wrote:\n> On Sun, Jan 17, 2016 at 12:03:58PM +0100, Thomas Gummerer wrote:\n>\n> > > I thought it might be nice for any porcelain which tries to wrap\n> > > `ls-remote`, make some decision based on the capabilities, and then\n> > > invoke another plumbing command. But I guess that is probably slightly\n> > > crazy, and nobody is doing it.\n> > >\n> > > Something like `ls-remote --symrefs` probably would be a better place to\n> > > start.\n> >\n> > Turns out adding this is pretty simple.\n> >\n> > The first two patches are documentation, which I noticed when reading\n> > up about the command.  Patch three is a cleanup patch, which makes\n> > ls-remote use the parse-options api instead of the hand-rolled option\n> > parser.  Patch four is actually adding the option.\n> >\n> > Thomas Gummerer (4):\n> >   ls-remote: document --quiet option\n> >   ls-remote: fix synopsis\n> >   ls-remote: use parse-options api\n> >   ls-remote: add support for showing symrefs\n> >\n> >  Documentation/git-ls-remote.txt | 12 +++++-\n> >  builtin/ls-remote.c             | 90 +++++++++++++++++------------------------\n> >  t/t5512-ls-remote.sh            | 20 +++++++++\n> >  3 files changed, 68 insertions(+), 54 deletions(-)\n>\n> Thanks for working on this. One of my favorite things about open source\n> is when I realize I'm too lazy/busy to work on something, and then it\n> magically appears in my inbox. :)\n\n:) thanks for suggesting it, and thanks for the review!\n\n> This looks like a good start. I left a few comments on the specific\n> patches.\n>\n> -Peff\n\n--\nThomas\n"},{"id":"276252","messageId":"xmqqwpr7etvs.fsf@gitster.mtv.corp.google.com","threadId":"41208","inReplyTo":"20160117151510.GC15519@sigill.intra.peff.net","subject":"Re: [PATCH 4/4] ls-remote: add support for showing symrefs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-01-17T22:14:15Z","receivedAt":"2016-01-17T22:14:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> We could also do it as:\n>\n>   ref: refs/heads/master     HEAD\n>\n> which matches the symref format itself. I guess that doesn't really\n> matter here, but somehow it seems more aesthetically pleasing to me.\n\nYes, I think this should be the way to go.\n\n> The output would look a lot nicer for humans if we right-padded the\n> symref destination to match the 40-hex that is on all the other lines\n> (so all of the refnames line up).  But that makes machine-parsing a lot\n> harder. We could do something clever with isatty(1), but I don't think\n> it's worth the effort.\n\nAnd the target can be longer than 40-hex.  Don't play games with\npadding.\n\n>> +test_expect_success 'ls-remote with symrefs and refs combined' '\n>> +\tcat >expect <<-EOF &&\n>> +\tsymref: refs/heads/master\tHEAD\n>> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n>> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/HEAD\n>> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/master\n>> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/tags/mark\n>> +\tEOF\n>\n> I expected there to be a:\n>\n>   1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n>\n> line.\n\nYes, there should be, as I would imagine the most natural\ninterpretation of \"--symrefs\" by end users would be \"show me ALSO\nthe symref information.\", not \"show me ONLY the symref information\"\n(if it were the latter we woudln't be seeing refs/tags/mark in the\nabove output).\n\nI also suspect that this part of the patch is wrong (or at least\nmisleading):\n\n@@ -98,6 +101,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tif (!dest && !quiet)\n \t\tfprintf(stderr, \"From %s\\n\", *remote->url);\n \tfor ( ; ref; ref = ref->next) {\n+\t\tif (symrefs && ref->symref)\n+\t\t\tprintf(\"symref: %s\t%s\\n\", ref->symref, ref->name);\n+\t\tif (symrefs && !flags)\n+\t\t\tcontinue;\n \t\tif (!check_ref_type(ref, flags))\n \t\t\tcontinue;\n \t\tif (!tail_match(pattern, ref->name))\n\nIt looks wrong that the usual filtering with check_ref_type() and\ntail_match() are bypassed for symbolic refs.  Even though the server\nside currently feeds reflog information for only \"HEAD\", the code\nshould be prepared to do the sane thing in a future in which that\nserver-side limitation is corrected, and allow the user to ask\n\n    ls-remote $there --symref refs/remotes/origin/HEAD\n\nto learn the information on one specific ref, without having to see\nthe primary branch of $there repository, for example.\n\nThanks.\n"},{"id":"276253","messageId":"xmqqsi1vetsw.fsf@gitster.mtv.corp.google.com","threadId":"41208","inReplyTo":"20160117151622.GD15519@sigill.intra.peff.net","subject":"Re: [PATCH 0/4] ls-remote: introduce symref argument","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-01-17T22:15:59Z","receivedAt":"2016-01-17T22:15:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Thanks for working on this. One of my favorite things about open source\n> is when I realize I'm too lazy/busy to work on something, and then it\n> magically appears in my inbox. :)\n\n;-) Once you suggest guess_remote_head(), 50% of the necessary\nbrainwork for this topic is already done, so you should take as much\ncredit, too.\n\nThanks, both.  Lookikng forward to a reroll.\n"},{"id":"276280","messageId":"1453136238-19448-1-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453028643-13978-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH v2 0/5] ls-remote: introduce symrefs argument","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T16:57:13Z","receivedAt":"2016-01-18T16:57:13Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"The previous round is at $gmane/284248.  Thanks to Peff an Junio for\ncomments on the previous round.\n\nChanges from the previous round:\n - added patch documenting the --refs option\n - addressed peffs comments on the parse-option patch\n - the symrefs format now uses only ref: as an indicator for a symref\n - symrefs are now shown in addition to the other refs, instead of\n   replacing them in the output.\n - symrefs are now filtered by the same rules as other refs.\n\nInterdiff below:\n\ndiff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\nindex 5b606dd..9356df2 100644\n--- a/Documentation/git-ls-remote.txt\n+++ b/Documentation/git-ls-remote.txt\n@@ -9,7 +9,7 @@ git-ls-remote - List references in a remote repository\n SYNOPSIS\n --------\n [verse]\n-'git ls-remote' [--heads] [--tags]  [--upload-pack=<exec>]\n+'git ls-remote' [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n \t      [-q | --quiet] [--exit-code] [--get-url]\n \t      [--symrefs] [<repository> [<refs>...]]\n \n@@ -30,6 +30,10 @@ OPTIONS\n \tboth, references stored in refs/heads and refs/tags are\n \tdisplayed.\n \n+--refs::\n+\tDo not show peeled tags or pseudo-refs like HEAD or MERGE_HEAD\n+\tin the output.\n+\n -q::\n --quiet::\n \tDo not print remote URL to stderr.\n@@ -52,9 +56,7 @@ OPTIONS\n \texit without talking to the remote.\n \n --symrefs::\n-\tShow the symrefs on the server.  Shows only the symrefs by\n-\tdefault, and can be combined with --tags and --heads to show\n-\trefs/heads and refs/tags as well.\n+\tShow the symrefs in addition to the other refs.\n \n <repository>::\n \tThe \"remote\" repository to query.  This parameter can be\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex f33ada9..ea73d53 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -4,7 +4,7 @@\n #include \"remote.h\"\n \n static const char * const ls_remote_usage[] = {\n-\tN_(\"git ls-remote [--heads] [--tags]  [--upload-pack=<exec>]\\n\"\n+\tN_(\"git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\\n\"\n \t   \"                     [-q | --quiet] [--exit-code] [--get-url]\\n\"\n \t   \"                     [--symrefs] [<repository> [<refs>...]]\"),\n \tNULL\n@@ -38,7 +38,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tint get_url = 0;\n \tint quiet = 0;\n \tint status = 0;\n-\tint tags = 0, heads = 0, refs = 0;\n \tint symrefs = 0;\n \tconst char *uploadpack = NULL;\n \tconst char **pattern = NULL;\n@@ -51,13 +50,14 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\tOPT__QUIET(&quiet, N_(\"do not print remote URL\")),\n \t\tOPT_STRING(0, \"upload-pack\", &uploadpack, N_(\"exec\"),\n \t\t\t   N_(\"path of git-upload-pack on the remote host\")),\n-\t\tOPT_STRING(0, \"exec\", &uploadpack, N_(\"exec\"),\n-\t\t\t   N_(\"path of git-upload-pack on the remote host\")),\n-\t\tOPT_SET_INT('t', \"tags\", &tags, N_(\"limit to tags\"), REF_TAGS),\n-\t\tOPT_SET_INT('h', \"heads\", &heads, N_(\"limit to heads\"), REF_HEADS),\n-\t\tOPT_SET_INT(0, \"refs\", &refs, N_(\"no magic fake tag refs\"), REF_NORMAL),\n-\t\tOPT_SET_INT(0, \"get-url\", &get_url,\n-\t\t\t    N_(\"take url.<base>.insteadOf into account\"), 1),\n+\t\t{ OPTION_STRING, 0, \"exec\", &uploadpack, N_(\"exec\"),\n+\t\t\t   N_(\"path of git-upload-pack on the remote host\"),\n+\t\t\t   PARSE_OPT_HIDDEN },\n+\t\tOPT_BIT('t', \"tags\", &flags, N_(\"limit to tags\"), REF_TAGS),\n+\t\tOPT_BIT('h', \"heads\", &flags, N_(\"limit to heads\"), REF_HEADS),\n+\t\tOPT_BIT(0, \"refs\", &flags, N_(\"do not show peeled tags\"), REF_NORMAL),\n+\t\tOPT_BOOL(0, \"get-url\", &get_url,\n+\t\t\t N_(\"take url.<base>.insteadOf into account\")),\n \t\tOPT_SET_INT(0, \"exit-code\", &status,\n \t\t\t    N_(\"exit with exit code 2 if no matching refs are found\"), 2),\n \t\tOPT_BOOL(0, \"symrefs\", &symrefs, N_(\"show symrefs\")),\n@@ -66,7 +66,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \n \targc = parse_options(argc, argv, prefix, options, ls_remote_usage,\n \t\t\t     PARSE_OPT_STOP_AT_NON_OPTION);\n-\tflags = tags | heads | refs;\n \tdest = argv[0];\n \n \tif (argc > 1) {\n@@ -101,15 +100,13 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tif (!dest && !quiet)\n \t\tfprintf(stderr, \"From %s\\n\", *remote->url);\n \tfor ( ; ref; ref = ref->next) {\n-\t\tif (symrefs && ref->symref)\n-\t\t\tprintf(\"symref: %s\t%s\\n\", ref->symref, ref->name);\n-\t\tif (symrefs && !flags)\n-\t\t\tcontinue;\n \t\tif (!check_ref_type(ref, flags))\n \t\t\tcontinue;\n \t\tif (!tail_match(pattern, ref->name))\n \t\t\tcontinue;\n-\t\tprintf(\"%s\t%s\\n\", oid_to_hex(&ref->old_oid), ref->name);\n+\t\tif (symrefs && ref->symref)\n+\t\t\tprintf(\"ref: %s\\t%s\\n\", ref->symref, ref->name);\n+\t\tprintf(\"%s\\t%s\\n\", oid_to_hex(&ref->old_oid), ref->name);\n \t\tstatus = 0; /* we found something */\n \t}\n \treturn status;\ndiff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh\nindex 68a1429..3edbc9e 100755\n--- a/t/t5512-ls-remote.sh\n+++ b/t/t5512-ls-remote.sh\n@@ -165,21 +165,23 @@ test_expect_success 'overrides work between mixed transfer/upload-pack hideRefs'\n \n test_expect_success 'ls-remote --symrefs' '\n \tcat >expect <<-EOF &&\n-\tsymref: refs/heads/master\tHEAD\n+\tref: refs/heads/master\tHEAD\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/HEAD\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/master\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/tags/mark\n \tEOF\n \tgit ls-remote --symrefs >actual &&\n \ttest_cmp expect actual\n '\n \n-test_expect_success 'ls-remote with symrefs and refs combined' '\n+test_expect_success 'ls-remote with filtered symrefs' '\n \tcat >expect <<-EOF &&\n-\tsymref: refs/heads/master\tHEAD\n-\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n-\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/HEAD\n-\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/master\n-\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/tags/mark\n+\tref: refs/heads/master\tHEAD\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n \tEOF\n-\tgit ls-remote --symrefs --refs >actual &&\n+\tgit ls-remote --symrefs . HEAD >actual &&\n \ttest_cmp expect actual\n '\n \nThomas Gummerer (5):\n  ls-remote: document --quiet option\n  ls-remote: document --refs option\n  ls-remote: fix synopsis\n  ls-remote: use parse-options api\n  ls-remote: add support for showing symrefs\n\n Documentation/git-ls-remote.txt | 16 +++++++-\n builtin/ls-remote.c             | 89 ++++++++++++++++-------------------------\n t/t5512-ls-remote.sh            | 22 ++++++++++\n 3 files changed, 71 insertions(+), 56 deletions(-)\n\n-- \n2.7.0.30.gd0a78e9.dirty\n"},{"id":"276283","messageId":"1453136238-19448-2-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453136238-19448-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH v2 1/5] ls-remote: document --quiet option","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T16:57:14Z","receivedAt":"2016-01-18T16:57:14Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"cefb2a5e3 (\"ls-remote: print URL when no repo is specified\") added a\nquiet option to ls-remote, but didn't add it to the documentation.  Add\nit.\n\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n Documentation/git-ls-remote.txt | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\nindex d510c05..27380de 100644\n--- a/Documentation/git-ls-remote.txt\n+++ b/Documentation/git-ls-remote.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git ls-remote' [--heads] [--tags]  [--upload-pack=<exec>]\n-\t      [--exit-code] <repository> [<refs>...]\n+\t      [-q | --quiet] [--exit-code] <repository> [<refs>...]\n \n DESCRIPTION\n -----------\n@@ -29,6 +29,10 @@ OPTIONS\n \tboth, references stored in refs/heads and refs/tags are\n \tdisplayed.\n \n+-q::\n+--quiet::\n+\tDo not print remote URL to stderr.\n+\n --upload-pack=<exec>::\n \tSpecify the full path of 'git-upload-pack' on the remote\n \thost. This allows listing references from repositories accessed via\n-- \n2.7.0.30.gd0a78e9.dirty\n"},{"id":"276281","messageId":"1453136238-19448-3-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453136238-19448-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH v2 2/5] ls-remote: document --refs option","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T16:57:15Z","receivedAt":"2016-01-18T16:57:15Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"The --refs option was originally introduced in 2718ff0 (\"Improve\ngit-peek-remote\").  The ls-remote command was first documented in\n972b6fe (\"ls-remote: drop storing operation and add documentation.\"),\nbut the --refs option was never documented.  Fix this.\n\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n Documentation/git-ls-remote.txt | 6 +++++-\n builtin/ls-remote.c             | 2 +-\n 2 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\nindex 27380de..5cd47c0 100644\n--- a/Documentation/git-ls-remote.txt\n+++ b/Documentation/git-ls-remote.txt\n@@ -9,7 +9,7 @@ git-ls-remote - List references in a remote repository\n SYNOPSIS\n --------\n [verse]\n-'git ls-remote' [--heads] [--tags]  [--upload-pack=<exec>]\n+'git ls-remote' [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n \t      [-q | --quiet] [--exit-code] <repository> [<refs>...]\n \n DESCRIPTION\n@@ -29,6 +29,10 @@ OPTIONS\n \tboth, references stored in refs/heads and refs/tags are\n \tdisplayed.\n \n+--refs::\n+\tDo not show peeled tags or pseudo-refs like HEAD or MERGE_HEAD\n+\tin the output.\n+\n -q::\n --quiet::\n \tDo not print remote URL to stderr.\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex fa65a84..db21e52 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -4,7 +4,7 @@\n #include \"remote.h\"\n \n static const char ls_remote_usage[] =\n-\"git ls-remote [--heads] [--tags]  [--upload-pack=<exec>]\\n\"\n+\"git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\\n\"\n \"                     [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\";\n \n /*\n-- \n2.7.0.30.gd0a78e9.dirty\n"},{"id":"276282","messageId":"1453136238-19448-4-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453136238-19448-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH v2 3/5] ls-remote: fix synopsis","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T16:57:16Z","receivedAt":"2016-01-18T16:57:16Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"git ls-remote takes an optional get-url argument, and specifying the\nrepository is optional.  Fix the synopsis in the documentation to\nreflect this.\n\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n Documentation/git-ls-remote.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\nindex 5cd47c0..f7d1091 100644\n--- a/Documentation/git-ls-remote.txt\n+++ b/Documentation/git-ls-remote.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git ls-remote' [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n-\t      [-q | --quiet] [--exit-code] <repository> [<refs>...]\n+\t      [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\n \n DESCRIPTION\n -----------\n-- \n2.7.0.30.gd0a78e9.dirty\n"},{"id":"276285","messageId":"1453136238-19448-5-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453136238-19448-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH v2 4/5] ls-remote: use parse-options api","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T16:57:17Z","receivedAt":"2016-01-18T16:57:17Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"Currently ls-remote uses a hand rolled parser for the its command line\narguments.  Use the parse-options api instead of the hand rolled parser\nto simplify the code and make it easier to add new arguments.  In\naddition this improves the help message.\n\nHelped-by: Jeff King <peff@peff.net>\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n builtin/ls-remote.c | 82 +++++++++++++++++++----------------------------------\n 1 file changed, 29 insertions(+), 53 deletions(-)\n\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex db21e52..3a20378 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -3,9 +3,11 @@\n #include \"transport.h\"\n #include \"remote.h\"\n \n-static const char ls_remote_usage[] =\n-\"git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\\n\"\n-\"                     [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\";\n+static const char * const ls_remote_usage[] = {\n+\tN_(\"git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\\n\"\n+\t   \"                     [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\"),\n+\tNULL\n+};\n \n /*\n  * Is there one among the list of patterns that match the tail part\n@@ -30,7 +32,6 @@ static int tail_match(const char **pattern, const char *path)\n \n int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n \tconst char *dest = NULL;\n \tunsigned flags = 0;\n \tint get_url = 0;\n@@ -43,59 +44,34 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tstruct transport *transport;\n \tconst struct ref *ref;\n \n-\tif (argc == 2 && !strcmp(\"-h\", argv[1]))\n-\t\tusage(ls_remote_usage);\n+\tstruct option options[] = {\n+\t\tOPT__QUIET(&quiet, N_(\"do not print remote URL\")),\n+\t\tOPT_STRING(0, \"upload-pack\", &uploadpack, N_(\"exec\"),\n+\t\t\t   N_(\"path of git-upload-pack on the remote host\")),\n+\t\t{ OPTION_STRING, 0, \"exec\", &uploadpack, N_(\"exec\"),\n+\t\t\t   N_(\"path of git-upload-pack on the remote host\"),\n+\t\t\t   PARSE_OPT_HIDDEN },\n+\t\tOPT_BIT('t', \"tags\", &flags, N_(\"limit to tags\"), REF_TAGS),\n+\t\tOPT_BIT('h', \"heads\", &flags, N_(\"limit to heads\"), REF_HEADS),\n+\t\tOPT_BIT(0, \"refs\", &flags, N_(\"do not show peeled tags\"), REF_NORMAL),\n+\t\tOPT_BOOL(0, \"get-url\", &get_url,\n+\t\t\t N_(\"take url.<base>.insteadOf into account\")),\n+\t\tOPT_SET_INT(0, \"exit-code\", &status,\n+\t\t\t    N_(\"exit with exit code 2 if no matching refs are found\"), 2),\n+\t\tOPT_END()\n+\t};\n \n-\tfor (i = 1; i < argc; i++) {\n-\t\tconst char *arg = argv[i];\n+\targc = parse_options(argc, argv, prefix, options, ls_remote_usage,\n+\t\t\t     PARSE_OPT_STOP_AT_NON_OPTION);\n+\tdest = argv[0];\n \n-\t\tif (*arg == '-') {\n-\t\t\tif (starts_with(arg, \"--upload-pack=\")) {\n-\t\t\t\tuploadpack = arg + 14;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (starts_with(arg, \"--exec=\")) {\n-\t\t\t\tuploadpack = arg + 7;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--tags\", arg) || !strcmp(\"-t\", arg)) {\n-\t\t\t\tflags |= REF_TAGS;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--heads\", arg) || !strcmp(\"-h\", arg)) {\n-\t\t\t\tflags |= REF_HEADS;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--refs\", arg)) {\n-\t\t\t\tflags |= REF_NORMAL;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--quiet\", arg) || !strcmp(\"-q\", arg)) {\n-\t\t\t\tquiet = 1;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--get-url\", arg)) {\n-\t\t\t\tget_url = 1;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--exit-code\", arg)) {\n-\t\t\t\t/* return this code if no refs are reported */\n-\t\t\t\tstatus = 2;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tusage(ls_remote_usage);\n-\t\t}\n-\t\tdest = arg;\n-\t\ti++;\n-\t\tbreak;\n+\tif (argc > 1) {\n+\t\tint i;\n+\t\tpattern = xcalloc(argc, sizeof(const char *));\n+\t\tfor (i = 1; i < argc; i++)\n+\t\t\tpattern[i - 1] = xstrfmt(\"*/%s\", argv[i]);\n \t}\n \n-\tif (argv[i]) {\n-\t\tint j;\n-\t\tpattern = xcalloc(argc - i + 1, sizeof(const char *));\n-\t\tfor (j = i; j < argc; j++)\n-\t\t\tpattern[j - i] = xstrfmt(\"*/%s\", argv[j]);\n-\t}\n \tremote = remote_get(dest);\n \tif (!remote) {\n \t\tif (dest)\n-- \n2.7.0.30.gd0a78e9.dirty\n"},{"id":"276284","messageId":"1453136238-19448-6-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453136238-19448-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH v2 5/5] ls-remote: add support for showing symrefs","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T16:57:18Z","receivedAt":"2016-01-18T16:57:18Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"Sometimes it's useful to know the main branch of a git repository\nwithout actually downloading the repository.  This can be done by\nlooking at the symrefs stored in the remote repository.  Currently git\ndoesn't provide a simple way to show the symrefs stored on the remote\nrepository, even though the information is available.  Add a --symrefs\ncommand line argument to the ls-remote command, which shows the symrefs\non the remote repository.\n\nThe new argument works similar to the --heads and --tags arguments.\nWhen only --symrefs is given, only the symrefs are shown.  It can\nhowever be combined with the --refs, --heads or --tags arguments, to\nshow all refs, heads, or tags as well.\n\nWhile there, replace a literal tab in the format string with \\t to make\nit more obvious to the reader.\n\nSuggested-by: pedro rijo <pedrorijo91@gmail.com>\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n Documentation/git-ls-remote.txt |  6 +++++-\n builtin/ls-remote.c             |  9 +++++++--\n t/t5512-ls-remote.sh            | 22 ++++++++++++++++++++++\n 3 files changed, 34 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\nindex f7d1091..9356df2 100644\n--- a/Documentation/git-ls-remote.txt\n+++ b/Documentation/git-ls-remote.txt\n@@ -10,7 +10,8 @@ SYNOPSIS\n --------\n [verse]\n 'git ls-remote' [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n-\t      [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\n+\t      [-q | --quiet] [--exit-code] [--get-url]\n+\t      [--symrefs] [<repository> [<refs>...]]\n \n DESCRIPTION\n -----------\n@@ -54,6 +55,9 @@ OPTIONS\n \t\"url.<base>.insteadOf\" config setting (See linkgit:git-config[1]) and\n \texit without talking to the remote.\n \n+--symrefs::\n+\tShow the symrefs in addition to the other refs.\n+\n <repository>::\n \tThe \"remote\" repository to query.  This parameter can be\n \teither a URL or the name of a remote (see the GIT URLS and\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 3a20378..ea73d53 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -5,7 +5,8 @@\n \n static const char * const ls_remote_usage[] = {\n \tN_(\"git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\\n\"\n-\t   \"                     [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\"),\n+\t   \"                     [-q | --quiet] [--exit-code] [--get-url]\\n\"\n+\t   \"                     [--symrefs] [<repository> [<refs>...]]\"),\n \tNULL\n };\n \n@@ -37,6 +38,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tint get_url = 0;\n \tint quiet = 0;\n \tint status = 0;\n+\tint symrefs = 0;\n \tconst char *uploadpack = NULL;\n \tconst char **pattern = NULL;\n \n@@ -58,6 +60,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\t\t N_(\"take url.<base>.insteadOf into account\")),\n \t\tOPT_SET_INT(0, \"exit-code\", &status,\n \t\t\t    N_(\"exit with exit code 2 if no matching refs are found\"), 2),\n+\t\tOPT_BOOL(0, \"symrefs\", &symrefs, N_(\"show symrefs\")),\n \t\tOPT_END()\n \t};\n \n@@ -101,7 +104,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\t\tcontinue;\n \t\tif (!tail_match(pattern, ref->name))\n \t\t\tcontinue;\n-\t\tprintf(\"%s\t%s\\n\", oid_to_hex(&ref->old_oid), ref->name);\n+\t\tif (symrefs && ref->symref)\n+\t\t\tprintf(\"ref: %s\\t%s\\n\", ref->symref, ref->name);\n+\t\tprintf(\"%s\\t%s\\n\", oid_to_hex(&ref->old_oid), ref->name);\n \t\tstatus = 0; /* we found something */\n \t}\n \treturn status;\ndiff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh\nindex aadaac5..3edbc9e 100755\n--- a/t/t5512-ls-remote.sh\n+++ b/t/t5512-ls-remote.sh\n@@ -163,4 +163,26 @@ test_expect_success 'overrides work between mixed transfer/upload-pack hideRefs'\n \tgrep refs/tags/magic actual\n '\n \n+test_expect_success 'ls-remote --symrefs' '\n+\tcat >expect <<-EOF &&\n+\tref: refs/heads/master\tHEAD\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/HEAD\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/master\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/tags/mark\n+\tEOF\n+\tgit ls-remote --symrefs >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'ls-remote with filtered symrefs' '\n+\tcat >expect <<-EOF &&\n+\tref: refs/heads/master\tHEAD\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n+\tEOF\n+\tgit ls-remote --symrefs . HEAD >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n2.7.0.30.gd0a78e9.dirty\n"},{"id":"276292","messageId":"20160118193140.GB1009@sigill.intra.peff.net","threadId":"41208","inReplyTo":"1453136238-19448-3-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH v2 2/5] ls-remote: document --refs option","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-01-18T19:31:40Z","receivedAt":"2016-01-18T19:31:40Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jan 18, 2016 at 05:57:15PM +0100, Thomas Gummerer wrote:\n\n> +--refs::\n> +\tDo not show peeled tags or pseudo-refs like HEAD or MERGE_HEAD\n> +\tin the output.\n> +\n\nMinor nit: we show whatever the other side sends us, which is the refs,\nHEAD, and peeled tags. So mentioning MERGE_HEAD isn't wrong (if the\nserver _did_ send it to us, we would omit it), but it is a bit\nmisleading.\n\nI think saying \"pseudo-refs like HEAD\" is OK; even though we know it is\nonly HEAD in the current server implementation, it better describes what\nthe client side is doing.\n\n-Peff\n"},{"id":"276293","messageId":"20160118193338.GC1009@sigill.intra.peff.net","threadId":"41208","inReplyTo":"1453136238-19448-5-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH v2 4/5] ls-remote: use parse-options api","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-01-18T19:33:38Z","receivedAt":"2016-01-18T19:33:38Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jan 18, 2016 at 05:57:17PM +0100, Thomas Gummerer wrote:\n\n> Currently ls-remote uses a hand rolled parser for the its command line\n\ns/the its/its/\n\n> arguments.  Use the parse-options api instead of the hand rolled parser\n> to simplify the code and make it easier to add new arguments.  In\n> addition this improves the help message.\n> \n> Helped-by: Jeff King <peff@peff.net>\n> Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n> ---\n>  builtin/ls-remote.c | 82 +++++++++++++++++++----------------------------------\n>  1 file changed, 29 insertions(+), 53 deletions(-)\n\nPatch itself looks good to me.\n\n-Peff\n"},{"id":"276294","messageId":"20160118195159.GD1009@sigill.intra.peff.net","threadId":"41208","inReplyTo":"1453136238-19448-6-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH v2 5/5] ls-remote: add support for showing symrefs","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-01-18T19:52:00Z","receivedAt":"2016-01-18T19:52:00Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jan 18, 2016 at 05:57:18PM +0100, Thomas Gummerer wrote:\n\n> While there, replace a literal tab in the format string with \\t to make\n> it more obvious to the reader.\n\nHeh, I didn't notice in the first review that you actually inherited\nthat from the original. Definitely worth doing, IMHO.\n\n> @@ -101,7 +104,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n>  \t\t\tcontinue;\n>  \t\tif (!tail_match(pattern, ref->name))\n>  \t\t\tcontinue;\n> -\t\tprintf(\"%s\t%s\\n\", oid_to_hex(&ref->old_oid), ref->name);\n> +\t\tif (symrefs && ref->symref)\n> +\t\t\tprintf(\"ref: %s\\t%s\\n\", ref->symref, ref->name);\n> +\t\tprintf(\"%s\\t%s\\n\", oid_to_hex(&ref->old_oid), ref->name);\n>  \t\tstatus = 0; /* we found something */\n\nYeah, this looks like the right logic to me.\n\n> +test_expect_success 'ls-remote --symrefs' '\n> +\tcat >expect <<-EOF &&\n\nPlease use \"<<-\\EOF\" here (and in the test below) to prevent\ninterpolation. It's not wrong in your case, but it's easier for a reader\n(or somebody who later modifies the test) to not have to wonder what you\nwere expecting to be expanded. So as a general style, we quote our\nhere-doc markers.\n\n> +\tref: refs/heads/master\tHEAD\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/HEAD\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/master\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/tags/mark\n> +\tEOF\n> +\tgit ls-remote --symrefs >actual &&\n> +\ttest_cmp expect actual\n> +'\n\nThis test covers \"symrefs, along with everything\". And this one:\n\n> +test_expect_success 'ls-remote with filtered symrefs' '\n> +\tcat >expect <<-EOF &&\n> +\tref: refs/heads/master\tHEAD\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n> +\tEOF\n> +\tgit ls-remote --symrefs . HEAD >actual &&\n> +\ttest_cmp expect actual\n> +'\n\ncovers symrefs plus a refname filter. It would be nice to also test that\n\"git ls-remote --symrefs --heads\" shows \"refs/heads/foo\" as a symref.\nBut that cannot work with the current code, because upload-pack only\ntells us about the symref HEAD, and not any others.\n\nThis may change in the future, though. I'm not sure if it's worth\nsquashing in the expect_failure test below. The \"negative\" one below\nthat does tell us something, though it is somewhat redundant (it does\ncatch the \"always show symrefs\" logic from your original version, but\nit seems unlikely that would pop up as a regression).\n\n---\ndiff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh\nindex 3edbc9e..92fc7e9 100755\n--- a/t/t5512-ls-remote.sh\n+++ b/t/t5512-ls-remote.sh\n@@ -176,7 +176,7 @@ test_expect_success 'ls-remote --symrefs' '\n \ttest_cmp expect actual\n '\n \n-test_expect_success 'ls-remote with filtered symrefs' '\n+test_expect_success 'ls-remote with filtered symrefs (refname)' '\n \tcat >expect <<-EOF &&\n \tref: refs/heads/master\tHEAD\n \t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n@@ -185,4 +185,27 @@ test_expect_success 'ls-remote with filtered symrefs' '\n \ttest_cmp expect actual\n '\n \n+test_expect_failure 'ls-remote with filtered symrefs (--heads)' '\n+\tgit symbolic-ref refs/heads/foo refs/tags/mark &&\n+\tcat >expect <<-\\EOF &&\n+\tref: refs/heads/bar\trefs/tags/mark\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/foo\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n+\tEOF\n+\tgit ls-remote --symrefs --heads . >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'ls-remote --symrefs omits filtered-out matches' '\n+\tcat >expect <<-\\EOF &&\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/foo\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n+\tEOF\n+\tgit ls-remote --symrefs --heads . >actual &&\n+\ttest_cmp expect actual &&\n+\tgit ls-remote --symrefs . \"refs/heads/*\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+\n test_done\n"},{"id":"276295","messageId":"20160118195346.GA9337@sigill.intra.peff.net","threadId":"41208","inReplyTo":"20160118195159.GD1009@sigill.intra.peff.net","subject":"Re: [PATCH v2 5/5] ls-remote: add support for showing symrefs","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-01-18T19:53:46Z","receivedAt":"2016-01-18T19:53:46Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jan 18, 2016 at 02:51:59PM -0500, Jeff King wrote:\n\n> It would be nice to also test that\n> \"git ls-remote --symrefs --heads\" shows \"refs/heads/foo\" as a symref.\n> But that cannot work with the current code, because upload-pack only\n> tells us about the symref HEAD, and not any others.\n\nActually, I wonder if it is worth making a note of that in the new\n\"--symref\" documentation, so people do not report it is a bug that\n\"ls-remote\" does not show it. :)\n\n-Peff\n"},{"id":"276296","messageId":"20160118195350.GE1009@sigill.intra.peff.net","threadId":"41208","inReplyTo":"1453136238-19448-1-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH v2 0/5] ls-remote: introduce symrefs argument","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-01-18T19:53:50Z","receivedAt":"2016-01-18T19:53:50Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jan 18, 2016 at 05:57:13PM +0100, Thomas Gummerer wrote:\n\n> The previous round is at $gmane/284248.  Thanks to Peff an Junio for\n> comments on the previous round.\n\nThanks. Aside from a few minor nits, this whole thing looks good to me.\n\n-Peff\n"},{"id":"276298","messageId":"xmqqsi1ud5dk.fsf@gitster.mtv.corp.google.com","threadId":"41208","inReplyTo":"20160118193140.GB1009@sigill.intra.peff.net","subject":"Re: [PATCH v2 2/5] ls-remote: document --refs option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-01-18T20:01:11Z","receivedAt":"2016-01-18T20:01:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Mon, Jan 18, 2016 at 05:57:15PM +0100, Thomas Gummerer wrote:\n>\n>> +--refs::\n>> +\tDo not show peeled tags or pseudo-refs like HEAD or MERGE_HEAD\n>> +\tin the output.\n>> +\n>\n> Minor nit: we show whatever the other side sends us, which is the refs,\n> HEAD, and peeled tags. So mentioning MERGE_HEAD isn't wrong (if the\n> server _did_ send it to us, we would omit it), but it is a bit\n> misleading.\n>\n> I think saying \"pseudo-refs like HEAD\" is OK; even though we know it is\n> only HEAD in the current server implementation, it better describes what\n> the client side is doing.\n\nGood point, I think.  We probably would want to fix the glossary\nentry of the word that is not spelled with a dash in between the\ntwo word components (or update the above to spell it as a single\nword).\n"},{"id":"276306","messageId":"xmqqoacid4zh.fsf@gitster.mtv.corp.google.com","threadId":"41208","inReplyTo":"1453136238-19448-6-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH v2 5/5] ls-remote: add support for showing symrefs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-01-18T20:09:38Z","receivedAt":"2016-01-18T20:09:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Gummerer <t.gummerer@gmail.com> writes:\n\n> +--symrefs::\n> +\tShow the symrefs in addition to the other refs.\n> +\n\nMicronit.  The above sounds as if the output would not talk about\nHEAD at all unless this option is given, which is not what you meant\nhere.  \"In addition to the object pointed by it, show the underlying\nref pointed by it when showing a symbolic ref\" or something like that,\nperhaps?\n\n> @@ -58,6 +60,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n>  \t\t\t N_(\"take url.<base>.insteadOf into account\")),\n>  \t\tOPT_SET_INT(0, \"exit-code\", &status,\n>  \t\t\t    N_(\"exit with exit code 2 if no matching refs are found\"), 2),\n> +\t\tOPT_BOOL(0, \"symrefs\", &symrefs, N_(\"show symrefs\")),\n\nLikewise.\n\nBy the way, unlike \"--heads\" and \"--tags\", which is to choose a\ngroup of refs to be shown, this controls one specific aspect,\ni.e. target of symbolic ref, of each thing that is being shown,\nwithout affecting the set of refs that the command talks about.\n\nShouldn't this option be \"--symref\" (and variable named as\nshow_symref_target or something more explicit)?\n\nOther than these nits, the code itself looks good.\n\nThanks.\n"},{"id":"276310","messageId":"20160118213946.GG7100@hank","threadId":"41208","inReplyTo":"xmqqsi1ud5dk.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2 2/5] ls-remote: document --refs option","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T21:39:46Z","receivedAt":"2016-01-18T21:39:46Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"On 01/18, Junio C Hamano wrote:\n> Jeff King <peff@peff.net> writes:\n>\n> > On Mon, Jan 18, 2016 at 05:57:15PM +0100, Thomas Gummerer wrote:\n> >\n> >> +--refs::\n> >> +\tDo not show peeled tags or pseudo-refs like HEAD or MERGE_HEAD\n> >> +\tin the output.\n> >> +\n> >\n> > Minor nit: we show whatever the other side sends us, which is the refs,\n> > HEAD, and peeled tags. So mentioning MERGE_HEAD isn't wrong (if the\n> > server _did_ send it to us, we would omit it), but it is a bit\n> > misleading.\n> >\n> > I think saying \"pseudo-refs like HEAD\" is OK; even though we know it is\n> > only HEAD in the current server implementation, it better describes what\n> > the client side is doing.\n\nMakes sense, will change.\n\n>\n> Good point, I think.  We probably would want to fix the glossary\n> entry of the word that is not spelled with a dash in between the\n> two word components (or update the above to spell it as a single\n> word).\n>\n\nI'll update to spell it as a single word, as that seems to be more in\nline with how it was used throughout the history.\n\n$ git log | grep pseudo-ref | wc -l\n2\n$ git log | grep pseudoref | wc -l\n18\n\nThanks, both.\n\n--\nThomas\n"},{"id":"276312","messageId":"20160118214845.GH7100@hank","threadId":"41208","inReplyTo":"xmqqoacid4zh.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2 5/5] ls-remote: add support for showing symrefs","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T21:48:45Z","receivedAt":"2016-01-18T21:48:45Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"On 01/18, Junio C Hamano wrote:\n> Thomas Gummerer <t.gummerer@gmail.com> writes:\n>\n> > +--symrefs::\n> > +\tShow the symrefs in addition to the other refs.\n> > +\n>\n> Micronit.  The above sounds as if the output would not talk about\n> HEAD at all unless this option is given, which is not what you meant\n> here.  \"In addition to the object pointed by it, show the underlying\n> ref pointed by it when showing a symbolic ref\" or something like that,\n> perhaps?\n\nThanks, that sounds better, will change.\n\n> > @@ -58,6 +60,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n> >  \t\t\t N_(\"take url.<base>.insteadOf into account\")),\n> >  \t\tOPT_SET_INT(0, \"exit-code\", &status,\n> >  \t\t\t    N_(\"exit with exit code 2 if no matching refs are found\"), 2),\n> > +\t\tOPT_BOOL(0, \"symrefs\", &symrefs, N_(\"show symrefs\")),\n>\n> Likewise.\n>\n> By the way, unlike \"--heads\" and \"--tags\", which is to choose a\n> group of refs to be shown, this controls one specific aspect,\n> i.e. target of symbolic ref, of each thing that is being shown,\n> without affecting the set of refs that the command talks about.\n>\n> Shouldn't this option be \"--symref\" (and variable named as\n> show_symref_target or something more explicit)?\n\nThe change of the variable name definitely makes sense.  My thoughts\nwere that potentially multiple symrefs are shown, so the plural would\nmake sense, but after reading your explanation I think I agree with\nusing --symref as the name.  Thanks.\n\n> Other than these nits, the code itself looks good.\n>\n> Thanks.\n>\n\n--\nThomas\n"},{"id":"276316","messageId":"20160118220913.GI7100@hank","threadId":"41208","inReplyTo":"20160118195159.GD1009@sigill.intra.peff.net","subject":"Re: [PATCH v2 5/5] ls-remote: add support for showing symrefs","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T22:09:13Z","receivedAt":"2016-01-18T22:09:13Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"On 01/18, Jeff King wrote:\n> On Mon, Jan 18, 2016 at 05:57:18PM +0100, Thomas Gummerer wrote:\n>\n> > While there, replace a literal tab in the format string with \\t to make\n> > it more obvious to the reader.\n>\n> Heh, I didn't notice in the first review that you actually inherited\n> that from the original. Definitely worth doing, IMHO.\n>\n> > @@ -101,7 +104,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n> >  \t\t\tcontinue;\n> >  \t\tif (!tail_match(pattern, ref->name))\n> >  \t\t\tcontinue;\n> > -\t\tprintf(\"%s\t%s\\n\", oid_to_hex(&ref->old_oid), ref->name);\n> > +\t\tif (symrefs && ref->symref)\n> > +\t\t\tprintf(\"ref: %s\\t%s\\n\", ref->symref, ref->name);\n> > +\t\tprintf(\"%s\\t%s\\n\", oid_to_hex(&ref->old_oid), ref->name);\n> >  \t\tstatus = 0; /* we found something */\n>\n> Yeah, this looks like the right logic to me.\n>\n> > +test_expect_success 'ls-remote --symrefs' '\n> > +\tcat >expect <<-EOF &&\n>\n> Please use \"<<-\\EOF\" here (and in the test below) to prevent\n> interpolation. It's not wrong in your case, but it's easier for a reader\n> (or somebody who later modifies the test) to not have to wonder what you\n> were expecting to be expanded. So as a general style, we quote our\n> here-doc markers.\n\nWill do, thanks!\n\n> > +\tref: refs/heads/master\tHEAD\n> > +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n> > +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n> > +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/HEAD\n> > +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/master\n> > +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/tags/mark\n> > +\tEOF\n> > +\tgit ls-remote --symrefs >actual &&\n> > +\ttest_cmp expect actual\n> > +'\n>\n> This test covers \"symrefs, along with everything\". And this one:\n>\n> > +test_expect_success 'ls-remote with filtered symrefs' '\n> > +\tcat >expect <<-EOF &&\n> > +\tref: refs/heads/master\tHEAD\n> > +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n> > +\tEOF\n> > +\tgit ls-remote --symrefs . HEAD >actual &&\n> > +\ttest_cmp expect actual\n> > +'\n>\n> covers symrefs plus a refname filter. It would be nice to also test that\n> \"git ls-remote --symrefs --heads\" shows \"refs/heads/foo\" as a symref.\n> But that cannot work with the current code, because upload-pack only\n> tells us about the symref HEAD, and not any others.\n>\n> This may change in the future, though. I'm not sure if it's worth\n> squashing in the expect_failure test below. The \"negative\" one below\n> that does tell us something, though it is somewhat redundant (it does\n> catch the \"always show symrefs\" logic from your original version, but\n> it seems unlikely that would pop up as a regression).\n>\n> ---\n> diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh\n> index 3edbc9e..92fc7e9 100755\n> --- a/t/t5512-ls-remote.sh\n> +++ b/t/t5512-ls-remote.sh\n> @@ -176,7 +176,7 @@ test_expect_success 'ls-remote --symrefs' '\n>  \ttest_cmp expect actual\n>  '\n>\n> -test_expect_success 'ls-remote with filtered symrefs' '\n> +test_expect_success 'ls-remote with filtered symrefs (refname)' '\n>  \tcat >expect <<-EOF &&\n>  \tref: refs/heads/master\tHEAD\n>  \t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n> @@ -185,4 +185,27 @@ test_expect_success 'ls-remote with filtered symrefs' '\n>  \ttest_cmp expect actual\n>  '\n>\n> +test_expect_failure 'ls-remote with filtered symrefs (--heads)' '\n> +\tgit symbolic-ref refs/heads/foo refs/tags/mark &&\n> +\tcat >expect <<-\\EOF &&\n> +\tref: refs/heads/bar\trefs/tags/mark\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/foo\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n> +\tEOF\n> +\tgit ls-remote --symrefs --heads . >actual &&\n> +\ttest_cmp expect actual\n> +'\n\nI'm a bit confused by this.  Shouldn't the \"ref: refs/heads/bar\nrefs/tags/mark\" line only show up when we use --tags, not --heads?\nAlso should refs/heads/bar be refs/heads/foo?\n\n> +\n> +test_expect_success 'ls-remote --symrefs omits filtered-out matches' '\n> +\tcat >expect <<-\\EOF &&\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/foo\n> +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n> +\tEOF\n> +\tgit ls-remote --symrefs --heads . >actual &&\n> +\ttest_cmp expect actual &&\n> +\tgit ls-remote --symrefs . \"refs/heads/*\" >actual &&\n> +\ttest_cmp expect actual\n> +'\n> +\n> +\n>  test_done\n>\n\n--\nThomas\n"},{"id":"276317","messageId":"20160118220958.GJ7100@hank","threadId":"41208","inReplyTo":"20160118195346.GA9337@sigill.intra.peff.net","subject":"Re: [PATCH v2 5/5] ls-remote: add support for showing symrefs","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T22:09:58Z","receivedAt":"2016-01-18T22:09:58Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"On 01/18, Jeff King wrote:\n> On Mon, Jan 18, 2016 at 02:51:59PM -0500, Jeff King wrote:\n>\n> > It would be nice to also test that\n> > \"git ls-remote --symrefs --heads\" shows \"refs/heads/foo\" as a symref.\n> > But that cannot work with the current code, because upload-pack only\n> > tells us about the symref HEAD, and not any others.\n>\n> Actually, I wonder if it is worth making a note of that in the new\n> \"--symref\" documentation, so people do not report it is a bug that\n> \"ls-remote\" does not show it. :)\n\nI agree, I'll add that.  Thanks.\n\n> -Peff\n\n--\nThomas\n"},{"id":"276319","messageId":"20160118222012.GA24740@sigill.intra.peff.net","threadId":"41208","inReplyTo":"20160118220913.GI7100@hank","subject":"Re: [PATCH v2 5/5] ls-remote: add support for showing symrefs","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-01-18T22:20:12Z","receivedAt":"2016-01-18T22:20:12Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jan 18, 2016 at 11:09:13PM +0100, Thomas Gummerer wrote:\n\n> > +test_expect_failure 'ls-remote with filtered symrefs (--heads)' '\n> > +\tgit symbolic-ref refs/heads/foo refs/tags/mark &&\n> > +\tcat >expect <<-\\EOF &&\n> > +\tref: refs/heads/bar\trefs/tags/mark\n> > +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/foo\n> > +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n> > +\tEOF\n> > +\tgit ls-remote --symrefs --heads . >actual &&\n> > +\ttest_cmp expect actual\n> > +'\n> \n> I'm a bit confused by this.  Shouldn't the \"ref: refs/heads/bar\n> refs/tags/mark\" line only show up when we use --tags, not --heads?\n> Also should refs/heads/bar be refs/heads/foo?\n\nYes, sorry, I bungled this. It should expect:\n\n  ref: refs/tags/mark\\trefs/heads/foo\n\nI changed my mind about which refs to use halfway through writing, and\nof course because it is marked to expect failure, running the test\ndidn't clue me in. :)\n\n-Peff\n"},{"id":"276320","messageId":"20160118223500.GK7100@hank","threadId":"41208","inReplyTo":"20160118222012.GA24740@sigill.intra.peff.net","subject":"Re: [PATCH v2 5/5] ls-remote: add support for showing symrefs","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T22:35:00Z","receivedAt":"2016-01-18T22:35:00Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"On 01/18, Jeff King wrote:\n> On Mon, Jan 18, 2016 at 11:09:13PM +0100, Thomas Gummerer wrote:\n>\n> > > +test_expect_failure 'ls-remote with filtered symrefs (--heads)' '\n> > > +\tgit symbolic-ref refs/heads/foo refs/tags/mark &&\n> > > +\tcat >expect <<-\\EOF &&\n> > > +\tref: refs/heads/bar\trefs/tags/mark\n> > > +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/foo\n> > > +\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n> > > +\tEOF\n> > > +\tgit ls-remote --symrefs --heads . >actual &&\n> > > +\ttest_cmp expect actual\n> > > +'\n> >\n> > I'm a bit confused by this.  Shouldn't the \"ref: refs/heads/bar\n> > refs/tags/mark\" line only show up when we use --tags, not --heads?\n> > Also should refs/heads/bar be refs/heads/foo?\n>\n> Yes, sorry, I bungled this. It should expect:\n>\n>   ref: refs/tags/mark\\trefs/heads/foo\n>\n> I changed my mind about which refs to use halfway through writing, and\n> of course because it is marked to expect failure, running the test\n> didn't clue me in. :)\n\nHeh, thanks for clearing this up :-)\n\n> -Peff\n\n--\nThomas\n"},{"id":"276322","messageId":"1453159250-21298-1-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453136238-19448-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH v3 0/5] ls-remote: introduce symref argument","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T23:20:45Z","receivedAt":"2016-01-18T23:20:45Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"The previous rounds are at $gmane/284248.  Thanks to Peff and Junio\nfor reviewing and suggestions on the previous round.\n\nChanges from the previous round:\n - Slightly reworded the documentation for the --refs option\n - Small fix in the commit message of patch 4.\n - use <<-\\EOF instead of <<-EOF in the tests\n - added a note about upload-pack only showing the HEAD symref\n - squashed in tests by peff\n - changed --symrefs option to --symref\n - reworded description and documentation of the option according to\n   comments from junio.\n\nInterdiff below:\n\ndiff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\nindex 9356df2..5f2628c 100644\n--- a/Documentation/git-ls-remote.txt\n+++ b/Documentation/git-ls-remote.txt\n@@ -11,7 +11,7 @@ SYNOPSIS\n [verse]\n 'git ls-remote' [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n \t      [-q | --quiet] [--exit-code] [--get-url]\n-\t      [--symrefs] [<repository> [<refs>...]]\n+\t      [--symref] [<repository> [<refs>...]]\n \n DESCRIPTION\n -----------\n@@ -31,8 +31,7 @@ OPTIONS\n \tdisplayed.\n \n --refs::\n-\tDo not show peeled tags or pseudo-refs like HEAD or MERGE_HEAD\n-\tin the output.\n+\tDo not show peeled tags or pseudorefs like HEAD\tin the output.\n \n -q::\n --quiet::\n@@ -55,8 +54,11 @@ OPTIONS\n \t\"url.<base>.insteadOf\" config setting (See linkgit:git-config[1]) and\n \texit without talking to the remote.\n \n---symrefs::\n-\tShow the symrefs in addition to the other refs.\n+--symref::\n+\tIn addition to the object pointed by it, show the underlying\n+\tref pointed by it when showing a symbolic ref.  Currently,\n+\tupload-pack only shows the symref HEAD, so it will be the only\n+\tone shown by ls-remote.\n \n <repository>::\n \tThe \"remote\" repository to query.  This parameter can be\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex ea73d53..66cdd45 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -6,7 +6,7 @@\n static const char * const ls_remote_usage[] = {\n \tN_(\"git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\\n\"\n \t   \"                     [-q | --quiet] [--exit-code] [--get-url]\\n\"\n-\t   \"                     [--symrefs] [<repository> [<refs>...]]\"),\n+\t   \"                     [--symref] [<repository> [<refs>...]]\"),\n \tNULL\n };\n \n@@ -38,7 +38,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tint get_url = 0;\n \tint quiet = 0;\n \tint status = 0;\n-\tint symrefs = 0;\n+\tint show_symref_target = 0;\n \tconst char *uploadpack = NULL;\n \tconst char **pattern = NULL;\n \n@@ -60,7 +60,8 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\t\t N_(\"take url.<base>.insteadOf into account\")),\n \t\tOPT_SET_INT(0, \"exit-code\", &status,\n \t\t\t    N_(\"exit with exit code 2 if no matching refs are found\"), 2),\n-\t\tOPT_BOOL(0, \"symrefs\", &symrefs, N_(\"show symrefs\")),\n+\t\tOPT_BOOL(0, \"symref\", &show_symref_target,\n+\t\t\t N_(\"show underlying ref in addition to the object pointed by it\")),\n \t\tOPT_END()\n \t};\n \n@@ -104,7 +105,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\t\tcontinue;\n \t\tif (!tail_match(pattern, ref->name))\n \t\t\tcontinue;\n-\t\tif (symrefs && ref->symref)\n+\t\tif (show_symref_target && ref->symref)\n \t\t\tprintf(\"ref: %s\\t%s\\n\", ref->symref, ref->name);\n \t\tprintf(\"%s\\t%s\\n\", oid_to_hex(&ref->old_oid), ref->name);\n \t\tstatus = 0; /* we found something */\ndiff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh\nindex 3edbc9e..819b9dd 100755\n--- a/t/t5512-ls-remote.sh\n+++ b/t/t5512-ls-remote.sh\n@@ -163,8 +163,8 @@ test_expect_success 'overrides work between mixed transfer/upload-pack hideRefs'\n \tgrep refs/tags/magic actual\n '\n \n-test_expect_success 'ls-remote --symrefs' '\n-\tcat >expect <<-EOF &&\n+test_expect_success 'ls-remote --symref' '\n+\tcat >expect <<-\\EOF &&\n \tref: refs/heads/master\tHEAD\n \t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n \t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n@@ -172,17 +172,40 @@ test_expect_success 'ls-remote --symrefs' '\n \t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/master\n \t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/tags/mark\n \tEOF\n-\tgit ls-remote --symrefs >actual &&\n+\tgit ls-remote --symref >actual &&\n \ttest_cmp expect actual\n '\n \n-test_expect_success 'ls-remote with filtered symrefs' '\n-\tcat >expect <<-EOF &&\n+test_expect_success 'ls-remote with filtered symref (refname)' '\n+\tcat >expect <<-\\EOF &&\n \tref: refs/heads/master\tHEAD\n \t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n \tEOF\n-\tgit ls-remote --symrefs . HEAD >actual &&\n+\tgit ls-remote --symref . HEAD >actual &&\n \ttest_cmp expect actual\n '\n \n+test_expect_failure 'ls-remote with filtered symref (--heads)' '\n+\tgit symbolic-ref refs/heads/foo refs/tags/mark &&\n+\tcat >expect <<-\\EOF &&\n+\tref: refs/tags/mark\trefs/heads/foo\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/foo\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n+\tEOF\n+\tgit ls-remote --symref --heads . >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'ls-remote --symref omits filtered-out matches' '\n+\tcat >expect <<-\\EOF &&\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/foo\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n+\tEOF\n+\tgit ls-remote --symref --heads . >actual &&\n+\ttest_cmp expect actual &&\n+\tgit ls-remote --symref . \"refs/heads/*\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+\n test_done\n\nThomas Gummerer (5):\n  ls-remote: document --quiet option\n  ls-remote: document --refs option\n  ls-remote: fix synopsis\n  ls-remote: use parse-options api\n  ls-remote: add support for showing symrefs\n\n Documentation/git-ls-remote.txt | 16 +++++++-\n builtin/ls-remote.c             | 90 +++++++++++++++++------------------------\n t/t5512-ls-remote.sh            | 45 +++++++++++++++++++++\n 3 files changed, 95 insertions(+), 56 deletions(-)\n\n-- \n2.7.0.30.g56a8654.dirty\n"},{"id":"276323","messageId":"1453159250-21298-2-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453159250-21298-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH v3 1/5] ls-remote: document --quiet option","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T23:20:46Z","receivedAt":"2016-01-18T23:20:46Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"cefb2a5e3 (\"ls-remote: print URL when no repo is specified\") added a\nquiet option to ls-remote, but didn't add it to the documentation.  Add\nit.\n\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n Documentation/git-ls-remote.txt | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\nindex d510c05..27380de 100644\n--- a/Documentation/git-ls-remote.txt\n+++ b/Documentation/git-ls-remote.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git ls-remote' [--heads] [--tags]  [--upload-pack=<exec>]\n-\t      [--exit-code] <repository> [<refs>...]\n+\t      [-q | --quiet] [--exit-code] <repository> [<refs>...]\n \n DESCRIPTION\n -----------\n@@ -29,6 +29,10 @@ OPTIONS\n \tboth, references stored in refs/heads and refs/tags are\n \tdisplayed.\n \n+-q::\n+--quiet::\n+\tDo not print remote URL to stderr.\n+\n --upload-pack=<exec>::\n \tSpecify the full path of 'git-upload-pack' on the remote\n \thost. This allows listing references from repositories accessed via\n-- \n2.7.0.30.g56a8654.dirty\n"},{"id":"276324","messageId":"1453159250-21298-3-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453159250-21298-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH v3 2/5] ls-remote: document --refs option","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T23:20:47Z","receivedAt":"2016-01-18T23:20:47Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"The --refs option was originally introduced in 2718ff0 (\"Improve\ngit-peek-remote\").  The ls-remote command was first documented in\n972b6fe (\"ls-remote: drop storing operation and add documentation.\"),\nbut the --refs option was never documented.  Fix this.\n\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n Documentation/git-ls-remote.txt | 5 ++++-\n builtin/ls-remote.c             | 2 +-\n 2 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\nindex 27380de..7467162 100644\n--- a/Documentation/git-ls-remote.txt\n+++ b/Documentation/git-ls-remote.txt\n@@ -9,7 +9,7 @@ git-ls-remote - List references in a remote repository\n SYNOPSIS\n --------\n [verse]\n-'git ls-remote' [--heads] [--tags]  [--upload-pack=<exec>]\n+'git ls-remote' [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n \t      [-q | --quiet] [--exit-code] <repository> [<refs>...]\n \n DESCRIPTION\n@@ -29,6 +29,9 @@ OPTIONS\n \tboth, references stored in refs/heads and refs/tags are\n \tdisplayed.\n \n+--refs::\n+\tDo not show peeled tags or pseudorefs like HEAD\tin the output.\n+\n -q::\n --quiet::\n \tDo not print remote URL to stderr.\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex fa65a84..db21e52 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -4,7 +4,7 @@\n #include \"remote.h\"\n \n static const char ls_remote_usage[] =\n-\"git ls-remote [--heads] [--tags]  [--upload-pack=<exec>]\\n\"\n+\"git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\\n\"\n \"                     [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\";\n \n /*\n-- \n2.7.0.30.g56a8654.dirty\n"},{"id":"276327","messageId":"1453159250-21298-4-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453159250-21298-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH v3 3/5] ls-remote: fix synopsis","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T23:20:48Z","receivedAt":"2016-01-18T23:20:48Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"git ls-remote takes an optional get-url argument, and specifying the\nrepository is optional.  Fix the synopsis in the documentation to\nreflect this.\n\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n Documentation/git-ls-remote.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\nindex 7467162..453e93c 100644\n--- a/Documentation/git-ls-remote.txt\n+++ b/Documentation/git-ls-remote.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git ls-remote' [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n-\t      [-q | --quiet] [--exit-code] <repository> [<refs>...]\n+\t      [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\n \n DESCRIPTION\n -----------\n-- \n2.7.0.30.g56a8654.dirty\n"},{"id":"276325","messageId":"1453159250-21298-5-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453159250-21298-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH v3 4/5] ls-remote: use parse-options api","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T23:20:49Z","receivedAt":"2016-01-18T23:20:49Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"Currently ls-remote uses a hand rolled parser for its command line\narguments.  Use the parse-options api instead of the hand rolled parser\nto simplify the code and make it easier to add new arguments.  In\naddition this improves the help message.\n\nHelped-by: Jeff King <peff@peff.net>\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n builtin/ls-remote.c | 82 +++++++++++++++++++----------------------------------\n 1 file changed, 29 insertions(+), 53 deletions(-)\n\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex db21e52..3a20378 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -3,9 +3,11 @@\n #include \"transport.h\"\n #include \"remote.h\"\n \n-static const char ls_remote_usage[] =\n-\"git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\\n\"\n-\"                     [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\";\n+static const char * const ls_remote_usage[] = {\n+\tN_(\"git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\\n\"\n+\t   \"                     [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\"),\n+\tNULL\n+};\n \n /*\n  * Is there one among the list of patterns that match the tail part\n@@ -30,7 +32,6 @@ static int tail_match(const char **pattern, const char *path)\n \n int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n \tconst char *dest = NULL;\n \tunsigned flags = 0;\n \tint get_url = 0;\n@@ -43,59 +44,34 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tstruct transport *transport;\n \tconst struct ref *ref;\n \n-\tif (argc == 2 && !strcmp(\"-h\", argv[1]))\n-\t\tusage(ls_remote_usage);\n+\tstruct option options[] = {\n+\t\tOPT__QUIET(&quiet, N_(\"do not print remote URL\")),\n+\t\tOPT_STRING(0, \"upload-pack\", &uploadpack, N_(\"exec\"),\n+\t\t\t   N_(\"path of git-upload-pack on the remote host\")),\n+\t\t{ OPTION_STRING, 0, \"exec\", &uploadpack, N_(\"exec\"),\n+\t\t\t   N_(\"path of git-upload-pack on the remote host\"),\n+\t\t\t   PARSE_OPT_HIDDEN },\n+\t\tOPT_BIT('t', \"tags\", &flags, N_(\"limit to tags\"), REF_TAGS),\n+\t\tOPT_BIT('h', \"heads\", &flags, N_(\"limit to heads\"), REF_HEADS),\n+\t\tOPT_BIT(0, \"refs\", &flags, N_(\"do not show peeled tags\"), REF_NORMAL),\n+\t\tOPT_BOOL(0, \"get-url\", &get_url,\n+\t\t\t N_(\"take url.<base>.insteadOf into account\")),\n+\t\tOPT_SET_INT(0, \"exit-code\", &status,\n+\t\t\t    N_(\"exit with exit code 2 if no matching refs are found\"), 2),\n+\t\tOPT_END()\n+\t};\n \n-\tfor (i = 1; i < argc; i++) {\n-\t\tconst char *arg = argv[i];\n+\targc = parse_options(argc, argv, prefix, options, ls_remote_usage,\n+\t\t\t     PARSE_OPT_STOP_AT_NON_OPTION);\n+\tdest = argv[0];\n \n-\t\tif (*arg == '-') {\n-\t\t\tif (starts_with(arg, \"--upload-pack=\")) {\n-\t\t\t\tuploadpack = arg + 14;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (starts_with(arg, \"--exec=\")) {\n-\t\t\t\tuploadpack = arg + 7;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--tags\", arg) || !strcmp(\"-t\", arg)) {\n-\t\t\t\tflags |= REF_TAGS;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--heads\", arg) || !strcmp(\"-h\", arg)) {\n-\t\t\t\tflags |= REF_HEADS;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--refs\", arg)) {\n-\t\t\t\tflags |= REF_NORMAL;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--quiet\", arg) || !strcmp(\"-q\", arg)) {\n-\t\t\t\tquiet = 1;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--get-url\", arg)) {\n-\t\t\t\tget_url = 1;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tif (!strcmp(\"--exit-code\", arg)) {\n-\t\t\t\t/* return this code if no refs are reported */\n-\t\t\t\tstatus = 2;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t\tusage(ls_remote_usage);\n-\t\t}\n-\t\tdest = arg;\n-\t\ti++;\n-\t\tbreak;\n+\tif (argc > 1) {\n+\t\tint i;\n+\t\tpattern = xcalloc(argc, sizeof(const char *));\n+\t\tfor (i = 1; i < argc; i++)\n+\t\t\tpattern[i - 1] = xstrfmt(\"*/%s\", argv[i]);\n \t}\n \n-\tif (argv[i]) {\n-\t\tint j;\n-\t\tpattern = xcalloc(argc - i + 1, sizeof(const char *));\n-\t\tfor (j = i; j < argc; j++)\n-\t\t\tpattern[j - i] = xstrfmt(\"*/%s\", argv[j]);\n-\t}\n \tremote = remote_get(dest);\n \tif (!remote) {\n \t\tif (dest)\n-- \n2.7.0.30.g56a8654.dirty\n"},{"id":"276326","messageId":"1453159250-21298-6-git-send-email-t.gummerer@gmail.com","threadId":"41208","inReplyTo":"1453159250-21298-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH v3 5/5] ls-remote: add support for showing symrefs","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2016-01-18T23:20:50Z","receivedAt":"2016-01-18T23:20:50Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"Sometimes it's useful to know the main branch of a git repository\nwithout actually downloading the repository.  This can be done by\nlooking at the symrefs stored in the remote repository.  Currently git\ndoesn't provide a simple way to show the symrefs stored on the remote\nrepository, even though the information is available.  Add a --symref\ncommand line argument to the ls-remote command, which shows the symrefs\nin the remote repository.\n\nWhile there, replace a literal tab in the format string with \\t to make\nit more obvious to the reader.\n\nSuggested-by: pedro rijo <pedrorijo91@gmail.com>\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n Documentation/git-ls-remote.txt |  9 ++++++++-\n builtin/ls-remote.c             | 10 +++++++--\n t/t5512-ls-remote.sh            | 45 +++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 61 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\nindex 453e93c..5f2628c 100644\n--- a/Documentation/git-ls-remote.txt\n+++ b/Documentation/git-ls-remote.txt\n@@ -10,7 +10,8 @@ SYNOPSIS\n --------\n [verse]\n 'git ls-remote' [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n-\t      [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\n+\t      [-q | --quiet] [--exit-code] [--get-url]\n+\t      [--symref] [<repository> [<refs>...]]\n \n DESCRIPTION\n -----------\n@@ -53,6 +54,12 @@ OPTIONS\n \t\"url.<base>.insteadOf\" config setting (See linkgit:git-config[1]) and\n \texit without talking to the remote.\n \n+--symref::\n+\tIn addition to the object pointed by it, show the underlying\n+\tref pointed by it when showing a symbolic ref.  Currently,\n+\tupload-pack only shows the symref HEAD, so it will be the only\n+\tone shown by ls-remote.\n+\n <repository>::\n \tThe \"remote\" repository to query.  This parameter can be\n \teither a URL or the name of a remote (see the GIT URLS and\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 3a20378..66cdd45 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -5,7 +5,8 @@\n \n static const char * const ls_remote_usage[] = {\n \tN_(\"git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\\n\"\n-\t   \"                     [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\"),\n+\t   \"                     [-q | --quiet] [--exit-code] [--get-url]\\n\"\n+\t   \"                     [--symref] [<repository> [<refs>...]]\"),\n \tNULL\n };\n \n@@ -37,6 +38,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tint get_url = 0;\n \tint quiet = 0;\n \tint status = 0;\n+\tint show_symref_target = 0;\n \tconst char *uploadpack = NULL;\n \tconst char **pattern = NULL;\n \n@@ -58,6 +60,8 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\t\t N_(\"take url.<base>.insteadOf into account\")),\n \t\tOPT_SET_INT(0, \"exit-code\", &status,\n \t\t\t    N_(\"exit with exit code 2 if no matching refs are found\"), 2),\n+\t\tOPT_BOOL(0, \"symref\", &show_symref_target,\n+\t\t\t N_(\"show underlying ref in addition to the object pointed by it\")),\n \t\tOPT_END()\n \t};\n \n@@ -101,7 +105,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\t\tcontinue;\n \t\tif (!tail_match(pattern, ref->name))\n \t\t\tcontinue;\n-\t\tprintf(\"%s\t%s\\n\", oid_to_hex(&ref->old_oid), ref->name);\n+\t\tif (show_symref_target && ref->symref)\n+\t\t\tprintf(\"ref: %s\\t%s\\n\", ref->symref, ref->name);\n+\t\tprintf(\"%s\\t%s\\n\", oid_to_hex(&ref->old_oid), ref->name);\n \t\tstatus = 0; /* we found something */\n \t}\n \treturn status;\ndiff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh\nindex aadaac5..819b9dd 100755\n--- a/t/t5512-ls-remote.sh\n+++ b/t/t5512-ls-remote.sh\n@@ -163,4 +163,49 @@ test_expect_success 'overrides work between mixed transfer/upload-pack hideRefs'\n \tgrep refs/tags/magic actual\n '\n \n+test_expect_success 'ls-remote --symref' '\n+\tcat >expect <<-\\EOF &&\n+\tref: refs/heads/master\tHEAD\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/HEAD\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/remotes/origin/master\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/tags/mark\n+\tEOF\n+\tgit ls-remote --symref >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'ls-remote with filtered symref (refname)' '\n+\tcat >expect <<-\\EOF &&\n+\tref: refs/heads/master\tHEAD\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\tHEAD\n+\tEOF\n+\tgit ls-remote --symref . HEAD >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_failure 'ls-remote with filtered symref (--heads)' '\n+\tgit symbolic-ref refs/heads/foo refs/tags/mark &&\n+\tcat >expect <<-\\EOF &&\n+\tref: refs/tags/mark\trefs/heads/foo\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/foo\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n+\tEOF\n+\tgit ls-remote --symref --heads . >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'ls-remote --symref omits filtered-out matches' '\n+\tcat >expect <<-\\EOF &&\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/foo\n+\t1bd44cb9d13204b0fe1958db0082f5028a16eb3a\trefs/heads/master\n+\tEOF\n+\tgit ls-remote --symref --heads . >actual &&\n+\ttest_cmp expect actual &&\n+\tgit ls-remote --symref . \"refs/heads/*\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+\n test_done\n-- \n2.7.0.30.g56a8654.dirty\n"},{"id":"276352","messageId":"xmqqegddbfnd.fsf@gitster.mtv.corp.google.com","threadId":"41208","inReplyTo":"1453159250-21298-1-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH v3 0/5] ls-remote: introduce symref argument","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-01-19T18:14:30Z","receivedAt":"2016-01-19T18:14:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Looks good to me; will queue.\n\nThanks.\n"}]}