{"thread":{"id":"15994","subject":"[PATCH] git-remote: list branches in vertical lists","startedAt":"2008-10-21T14:43:14Z","lastAt":"2008-10-22T07:39:47Z","messageCount":3,"participants":["Johannes Sixt","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"93605","messageId":"48FDEA82.5050903@viscovery.net","threadId":"15994","inReplyTo":null,"subject":"[PATCH] git-remote: list branches in vertical lists","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-10-21T14:43:14Z","receivedAt":"2008-10-21T14:43:14Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Johannes Sixt <johannes.sixt@telecom.at>\n\nPreviously, branches were listed on a single line in each section. But\nif there are many branches, then horizontal, line-wrapped lists are very\ninconvenient to scan for a human. This makes the lists vertical, i.e one\nbranch per line is printed.\n\nThis does mean that users' scripts must be updated because the output\nformat changed, but the result is friendlier to the eye *and* easier to\nparse.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n Documentation/user-manual.txt |    4 +++-\n builtin-remote.c              |   11 +++++------\n t/t5505-remote.sh             |   14 +++++++++-----\n 3 files changed, 17 insertions(+), 12 deletions(-)\n\ndiff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt\nindex 08d1310..645d752 100644\n--- a/Documentation/user-manual.txt\n+++ b/Documentation/user-manual.txt\n@@ -4356,7 +4356,9 @@ $ git remote show example\t# get details\n * remote example\n   URL: git://example.com/project.git\n   Tracked remote branches\n-    master next ...\n+    master\n+    next\n+    ...\n $ git fetch example\t\t# update branches from example\n $ git branch -r\t\t\t# list all remote branches\n -----------------------------------------------\ndiff --git a/builtin-remote.c b/builtin-remote.c\nindex 90a4e35..1b1697b 100644\n--- a/builtin-remote.c\n+++ b/builtin-remote.c\n@@ -416,10 +416,9 @@ static void show_list(const char *title, struct string_list *list,\n \t\treturn;\n\n \tprintf(title, list->nr > 1 ? \"es\" : \"\", extra_arg);\n-\tprintf(\"\\n    \");\n-\tfor (i = 0; i < list->nr; i++)\n-\t\tprintf(\"%s%s\", i ? \" \" : \"\", list->items[i].string);\n \tprintf(\"\\n\");\n+\tfor (i = 0; i < list->nr; i++)\n+\t\tprintf(\"    %s\\n\", list->items[i].string);\n }\n\n static int get_remote_ref_states(const char *name,\n@@ -515,17 +514,17 @@ static int show(int argc, const char **argv)\n \t\tshow_list(\"  Tracked remote branch%s\", &states.tracked, \"\");\n\n \t\tif (states.remote->push_refspec_nr) {\n-\t\t\tprintf(\"  Local branch%s pushed with 'git push'\\n   \",\n+\t\t\tprintf(\"  Local branch%s pushed with 'git push'\\n\",\n \t\t\t\tstates.remote->push_refspec_nr > 1 ?\n \t\t\t\t\t\"es\" : \"\");\n \t\t\tfor (i = 0; i < states.remote->push_refspec_nr; i++) {\n \t\t\t\tstruct refspec *spec = states.remote->push + i;\n-\t\t\t\tprintf(\" %s%s%s%s\", spec->force ? \"+\" : \"\",\n+\t\t\t\tprintf(\"    %s%s%s%s\\n\",\n+\t\t\t\t       spec->force ? \"+\" : \"\",\n \t\t\t\t       abbrev_branch(spec->src),\n \t\t\t\t       spec->dst ? \":\" : \"\",\n \t\t\t\t       spec->dst ? abbrev_branch(spec->dst) : \"\");\n \t\t\t}\n-\t\t\tprintf(\"\\n\");\n \t\t}\n\n \t\t/* NEEDSWORK: free remote */\ndiff --git a/t/t5505-remote.sh b/t/t5505-remote.sh\nindex e5137dc..e6cf2c7 100755\n--- a/t/t5505-remote.sh\n+++ b/t/t5505-remote.sh\n@@ -28,7 +28,7 @@ tokens_match () {\n }\n\n check_remote_track () {\n-\tactual=$(git remote show \"$1\" | sed -n -e '$p') &&\n+\tactual=$(git remote show \"$1\" | sed -e '1,/Tracked/d') &&\n \tshift &&\n \ttokens_match \"$*\" \"$actual\"\n }\n@@ -118,9 +118,11 @@ cat > test/expect << EOF\n   New remote branch (next fetch will store in remotes/origin)\n     master\n   Tracked remote branches\n-    side master\n+    side\n+    master\n   Local branches pushed with 'git push'\n-    master:upstream +refs/tags/lastbackup\n+    master:upstream\n+    +refs/tags/lastbackup\n EOF\n\n test_expect_success 'show' '\n@@ -147,9 +149,11 @@ cat > test/expect << EOF\n   Remote branch merged with 'git pull' while on branch master\n     master\n   Tracked remote branches\n-    master side\n+    master\n+    side\n   Local branches pushed with 'git push'\n-    master:upstream +refs/tags/lastbackup\n+    master:upstream\n+    +refs/tags/lastbackup\n EOF\n\n test_expect_success 'show -n' '\n-- \n1.6.0.2.1573.gdf533\n"},{"id":"93612","messageId":"alpine.DEB.1.00.0810211847410.22125@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"15994","inReplyTo":"48FDEA82.5050903@viscovery.net","subject":"Re: [PATCH] git-remote: list branches in vertical lists","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-10-21T16:49:47Z","receivedAt":"2008-10-21T16:49:47Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 21 Oct 2008, Johannes Sixt wrote:\n\n> Previously, branches were listed on a single line in each section. But \n> if there are many branches, then horizontal, line-wrapped lists are very \n> inconvenient to scan for a human. This makes the lists vertical, i.e one \n> branch per line is printed.\n> \n> This does mean that users' scripts must be updated because the output \n> format changed, but the result is friendlier to the eye *and* easier to \n> parse.\n\nMy initial reaction to that was: add an option, and keep the old behavior \nthen.\n\nBut on second thought: No script has any business scanning the output of \ngit-remote.  That command is a pure convenience wrapper, and scripts \ntrying to list remote branches should use git show-ref instead.\n\nSo I'd say: replace the last comment with\n\n\tSince \"git remote\" is porcelain, we can easily make this \n\tbackwards-incompatible change.\n\nCiao,\nDscho\n"},{"id":"93654","messageId":"48FED8C3.20003@viscovery.net","threadId":"15994","inReplyTo":"alpine.DEB.1.00.0810211847410.22125@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [PATCH] git-remote: list branches in vertical lists","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-10-22T07:39:47Z","receivedAt":"2008-10-22T07:39:47Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Johannes Sixt <j6t@kdbg.org>\n\nPreviously, branches were listed on a single line in each section. But\nif there are many branches, then horizontal, line-wrapped lists are very\ninconvenient to scan for a human. This makes the lists vertical, i.e one\nbranch per line is printed.\n\nSince \"git remote\" is porcelain, we can easily make this\nbackwards-incompatible change.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\nJohannes Schindelin schrieb:\n> On Tue, 21 Oct 2008, Johannes Sixt wrote:\n>> This does mean that users' scripts must be updated because the output \n>> format changed, but the result is friendlier to the eye *and* easier to \n>> parse.\n> \n> My initial reaction to that was: add an option, and keep the old behavior \n> then.\n> \n> But on second thought: No script has any business scanning the output of \n> git-remote.  That command is a pure convenience wrapper, and scripts \n> trying to list remote branches should use git show-ref instead.\n> \n> So I'd say: replace the last comment with\n> \n> \tSince \"git remote\" is porcelain, we can easily make this \n> \tbackwards-incompatible change.\n\nHere we go.\n\nNote the new email address, too. I'm afraid the old one, @telecom.at, goes\nout of service by the end of the year.\n\n-- Hannes\n\n Documentation/user-manual.txt |    4 +++-\n builtin-remote.c              |   11 +++++------\n t/t5505-remote.sh             |   14 +++++++++-----\n 3 files changed, 17 insertions(+), 12 deletions(-)\n\ndiff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt\nindex 08d1310..645d752 100644\n--- a/Documentation/user-manual.txt\n+++ b/Documentation/user-manual.txt\n@@ -4356,7 +4356,9 @@ $ git remote show example\t# get details\n * remote example\n   URL: git://example.com/project.git\n   Tracked remote branches\n-    master next ...\n+    master\n+    next\n+    ...\n $ git fetch example\t\t# update branches from example\n $ git branch -r\t\t\t# list all remote branches\n -----------------------------------------------\ndiff --git a/builtin-remote.c b/builtin-remote.c\nindex 90a4e35..1b1697b 100644\n--- a/builtin-remote.c\n+++ b/builtin-remote.c\n@@ -416,10 +416,9 @@ static void show_list(const char *title, struct string_list *list,\n \t\treturn;\n\n \tprintf(title, list->nr > 1 ? \"es\" : \"\", extra_arg);\n-\tprintf(\"\\n    \");\n-\tfor (i = 0; i < list->nr; i++)\n-\t\tprintf(\"%s%s\", i ? \" \" : \"\", list->items[i].string);\n \tprintf(\"\\n\");\n+\tfor (i = 0; i < list->nr; i++)\n+\t\tprintf(\"    %s\\n\", list->items[i].string);\n }\n\n static int get_remote_ref_states(const char *name,\n@@ -515,17 +514,17 @@ static int show(int argc, const char **argv)\n \t\tshow_list(\"  Tracked remote branch%s\", &states.tracked, \"\");\n\n \t\tif (states.remote->push_refspec_nr) {\n-\t\t\tprintf(\"  Local branch%s pushed with 'git push'\\n   \",\n+\t\t\tprintf(\"  Local branch%s pushed with 'git push'\\n\",\n \t\t\t\tstates.remote->push_refspec_nr > 1 ?\n \t\t\t\t\t\"es\" : \"\");\n \t\t\tfor (i = 0; i < states.remote->push_refspec_nr; i++) {\n \t\t\t\tstruct refspec *spec = states.remote->push + i;\n-\t\t\t\tprintf(\" %s%s%s%s\", spec->force ? \"+\" : \"\",\n+\t\t\t\tprintf(\"    %s%s%s%s\\n\",\n+\t\t\t\t       spec->force ? \"+\" : \"\",\n \t\t\t\t       abbrev_branch(spec->src),\n \t\t\t\t       spec->dst ? \":\" : \"\",\n \t\t\t\t       spec->dst ? abbrev_branch(spec->dst) : \"\");\n \t\t\t}\n-\t\t\tprintf(\"\\n\");\n \t\t}\n\n \t\t/* NEEDSWORK: free remote */\ndiff --git a/t/t5505-remote.sh b/t/t5505-remote.sh\nindex e5137dc..e6cf2c7 100755\n--- a/t/t5505-remote.sh\n+++ b/t/t5505-remote.sh\n@@ -28,7 +28,7 @@ tokens_match () {\n }\n\n check_remote_track () {\n-\tactual=$(git remote show \"$1\" | sed -n -e '$p') &&\n+\tactual=$(git remote show \"$1\" | sed -e '1,/Tracked/d') &&\n \tshift &&\n \ttokens_match \"$*\" \"$actual\"\n }\n@@ -118,9 +118,11 @@ cat > test/expect << EOF\n   New remote branch (next fetch will store in remotes/origin)\n     master\n   Tracked remote branches\n-    side master\n+    side\n+    master\n   Local branches pushed with 'git push'\n-    master:upstream +refs/tags/lastbackup\n+    master:upstream\n+    +refs/tags/lastbackup\n EOF\n\n test_expect_success 'show' '\n@@ -147,9 +149,11 @@ cat > test/expect << EOF\n   Remote branch merged with 'git pull' while on branch master\n     master\n   Tracked remote branches\n-    master side\n+    master\n+    side\n   Local branches pushed with 'git push'\n-    master:upstream +refs/tags/lastbackup\n+    master:upstream\n+    +refs/tags/lastbackup\n EOF\n\n test_expect_success 'show -n' '\n-- \n1.6.0.2.1573.gdf533\n"}]}