git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] git-remote: list branches in vertical lists
@ 2008-10-21 14:43 Johannes Sixt
  2008-10-21 16:49 ` Johannes Schindelin
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Sixt @ 2008-10-21 14:43 UTC (permalink / raw
  To: Junio C Hamano; +Cc: Git Mailing List

From: Johannes Sixt <johannes.sixt@telecom.at>

Previously, branches were listed on a single line in each section. But
if there are many branches, then horizontal, line-wrapped lists are very
inconvenient to scan for a human. This makes the lists vertical, i.e one
branch per line is printed.

This does mean that users' scripts must be updated because the output
format changed, but the result is friendlier to the eye *and* easier to
parse.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
 Documentation/user-manual.txt |    4 +++-
 builtin-remote.c              |   11 +++++------
 t/t5505-remote.sh             |   14 +++++++++-----
 3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
index 08d1310..645d752 100644
--- a/Documentation/user-manual.txt
+++ b/Documentation/user-manual.txt
@@ -4356,7 +4356,9 @@ $ git remote show example	# get details
 * remote example
   URL: git://example.com/project.git
   Tracked remote branches
-    master next ...
+    master
+    next
+    ...
 $ git fetch example		# update branches from example
 $ git branch -r			# list all remote branches
 -----------------------------------------------
diff --git a/builtin-remote.c b/builtin-remote.c
index 90a4e35..1b1697b 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -416,10 +416,9 @@ static void show_list(const char *title, struct string_list *list,
 		return;

 	printf(title, list->nr > 1 ? "es" : "", extra_arg);
-	printf("\n    ");
-	for (i = 0; i < list->nr; i++)
-		printf("%s%s", i ? " " : "", list->items[i].string);
 	printf("\n");
+	for (i = 0; i < list->nr; i++)
+		printf("    %s\n", list->items[i].string);
 }

 static int get_remote_ref_states(const char *name,
@@ -515,17 +514,17 @@ static int show(int argc, const char **argv)
 		show_list("  Tracked remote branch%s", &states.tracked, "");

 		if (states.remote->push_refspec_nr) {
-			printf("  Local branch%s pushed with 'git push'\n   ",
+			printf("  Local branch%s pushed with 'git push'\n",
 				states.remote->push_refspec_nr > 1 ?
 					"es" : "");
 			for (i = 0; i < states.remote->push_refspec_nr; i++) {
 				struct refspec *spec = states.remote->push + i;
-				printf(" %s%s%s%s", spec->force ? "+" : "",
+				printf("    %s%s%s%s\n",
+				       spec->force ? "+" : "",
 				       abbrev_branch(spec->src),
 				       spec->dst ? ":" : "",
 				       spec->dst ? abbrev_branch(spec->dst) : "");
 			}
-			printf("\n");
 		}

 		/* NEEDSWORK: free remote */
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index e5137dc..e6cf2c7 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -28,7 +28,7 @@ tokens_match () {
 }

 check_remote_track () {
-	actual=$(git remote show "$1" | sed -n -e '$p') &&
+	actual=$(git remote show "$1" | sed -e '1,/Tracked/d') &&
 	shift &&
 	tokens_match "$*" "$actual"
 }
@@ -118,9 +118,11 @@ cat > test/expect << EOF
   New remote branch (next fetch will store in remotes/origin)
     master
   Tracked remote branches
-    side master
+    side
+    master
   Local branches pushed with 'git push'
-    master:upstream +refs/tags/lastbackup
+    master:upstream
+    +refs/tags/lastbackup
 EOF

 test_expect_success 'show' '
@@ -147,9 +149,11 @@ cat > test/expect << EOF
   Remote branch merged with 'git pull' while on branch master
     master
   Tracked remote branches
-    master side
+    master
+    side
   Local branches pushed with 'git push'
-    master:upstream +refs/tags/lastbackup
+    master:upstream
+    +refs/tags/lastbackup
 EOF

 test_expect_success 'show -n' '
-- 
1.6.0.2.1573.gdf533

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] git-remote: list branches in vertical lists
  2008-10-21 14:43 [PATCH] git-remote: list branches in vertical lists Johannes Sixt
@ 2008-10-21 16:49 ` Johannes Schindelin
  2008-10-22  7:39   ` Johannes Sixt
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin @ 2008-10-21 16:49 UTC (permalink / raw
  To: Johannes Sixt; +Cc: Junio C Hamano, Git Mailing List

Hi,

On Tue, 21 Oct 2008, Johannes Sixt wrote:

> Previously, branches were listed on a single line in each section. But 
> if there are many branches, then horizontal, line-wrapped lists are very 
> inconvenient to scan for a human. This makes the lists vertical, i.e one 
> branch per line is printed.
> 
> This does mean that users' scripts must be updated because the output 
> format changed, but the result is friendlier to the eye *and* easier to 
> parse.

My initial reaction to that was: add an option, and keep the old behavior 
then.

But on second thought: No script has any business scanning the output of 
git-remote.  That command is a pure convenience wrapper, and scripts 
trying to list remote branches should use git show-ref instead.

So I'd say: replace the last comment with

	Since "git remote" is porcelain, we can easily make this 
	backwards-incompatible change.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] git-remote: list branches in vertical lists
  2008-10-21 16:49 ` Johannes Schindelin
@ 2008-10-22  7:39   ` Johannes Sixt
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Sixt @ 2008-10-22  7:39 UTC (permalink / raw
  To: Johannes Schindelin; +Cc: Junio C Hamano, Git Mailing List

From: Johannes Sixt <j6t@kdbg.org>

Previously, branches were listed on a single line in each section. But
if there are many branches, then horizontal, line-wrapped lists are very
inconvenient to scan for a human. This makes the lists vertical, i.e one
branch per line is printed.

Since "git remote" is porcelain, we can easily make this
backwards-incompatible change.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
Johannes Schindelin schrieb:
> On Tue, 21 Oct 2008, Johannes Sixt wrote:
>> This does mean that users' scripts must be updated because the output 
>> format changed, but the result is friendlier to the eye *and* easier to 
>> parse.
> 
> My initial reaction to that was: add an option, and keep the old behavior 
> then.
> 
> But on second thought: No script has any business scanning the output of 
> git-remote.  That command is a pure convenience wrapper, and scripts 
> trying to list remote branches should use git show-ref instead.
> 
> So I'd say: replace the last comment with
> 
> 	Since "git remote" is porcelain, we can easily make this 
> 	backwards-incompatible change.

Here we go.

Note the new email address, too. I'm afraid the old one, @telecom.at, goes
out of service by the end of the year.

-- Hannes

 Documentation/user-manual.txt |    4 +++-
 builtin-remote.c              |   11 +++++------
 t/t5505-remote.sh             |   14 +++++++++-----
 3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
index 08d1310..645d752 100644
--- a/Documentation/user-manual.txt
+++ b/Documentation/user-manual.txt
@@ -4356,7 +4356,9 @@ $ git remote show example	# get details
 * remote example
   URL: git://example.com/project.git
   Tracked remote branches
-    master next ...
+    master
+    next
+    ...
 $ git fetch example		# update branches from example
 $ git branch -r			# list all remote branches
 -----------------------------------------------
diff --git a/builtin-remote.c b/builtin-remote.c
index 90a4e35..1b1697b 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -416,10 +416,9 @@ static void show_list(const char *title, struct string_list *list,
 		return;

 	printf(title, list->nr > 1 ? "es" : "", extra_arg);
-	printf("\n    ");
-	for (i = 0; i < list->nr; i++)
-		printf("%s%s", i ? " " : "", list->items[i].string);
 	printf("\n");
+	for (i = 0; i < list->nr; i++)
+		printf("    %s\n", list->items[i].string);
 }

 static int get_remote_ref_states(const char *name,
@@ -515,17 +514,17 @@ static int show(int argc, const char **argv)
 		show_list("  Tracked remote branch%s", &states.tracked, "");

 		if (states.remote->push_refspec_nr) {
-			printf("  Local branch%s pushed with 'git push'\n   ",
+			printf("  Local branch%s pushed with 'git push'\n",
 				states.remote->push_refspec_nr > 1 ?
 					"es" : "");
 			for (i = 0; i < states.remote->push_refspec_nr; i++) {
 				struct refspec *spec = states.remote->push + i;
-				printf(" %s%s%s%s", spec->force ? "+" : "",
+				printf("    %s%s%s%s\n",
+				       spec->force ? "+" : "",
 				       abbrev_branch(spec->src),
 				       spec->dst ? ":" : "",
 				       spec->dst ? abbrev_branch(spec->dst) : "");
 			}
-			printf("\n");
 		}

 		/* NEEDSWORK: free remote */
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index e5137dc..e6cf2c7 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -28,7 +28,7 @@ tokens_match () {
 }

 check_remote_track () {
-	actual=$(git remote show "$1" | sed -n -e '$p') &&
+	actual=$(git remote show "$1" | sed -e '1,/Tracked/d') &&
 	shift &&
 	tokens_match "$*" "$actual"
 }
@@ -118,9 +118,11 @@ cat > test/expect << EOF
   New remote branch (next fetch will store in remotes/origin)
     master
   Tracked remote branches
-    side master
+    side
+    master
   Local branches pushed with 'git push'
-    master:upstream +refs/tags/lastbackup
+    master:upstream
+    +refs/tags/lastbackup
 EOF

 test_expect_success 'show' '
@@ -147,9 +149,11 @@ cat > test/expect << EOF
   Remote branch merged with 'git pull' while on branch master
     master
   Tracked remote branches
-    master side
+    master
+    side
   Local branches pushed with 'git push'
-    master:upstream +refs/tags/lastbackup
+    master:upstream
+    +refs/tags/lastbackup
 EOF

 test_expect_success 'show -n' '
-- 
1.6.0.2.1573.gdf533

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-10-22  7:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-21 14:43 [PATCH] git-remote: list branches in vertical lists Johannes Sixt
2008-10-21 16:49 ` Johannes Schindelin
2008-10-22  7:39   ` Johannes Sixt

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).