@matheusbsbs / matheus-bagliano / commits / 20244ea2d0
Fork 0

git-remote: list branches in vertical lists

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Sixt committed Oct 22, 2008 at 09:39 UTC 20244ea2d09a3f5c3c83133014ca1e1b7b3d0227
3 files changed +17 -12
Documentation/user-manual.txt
+3 -1
@@ -4356,7 +4356,9 @@ $ git remote show example # get details
4356 * remote example
4357 URL: git://example.com/project.git
4358 Tracked remote branches
4359 - master next ...
4359 + master
4360 + next
4361 + ...
4362 $ git fetch example # update branches from example
4363 $ git branch -r # list all remote branches
4364 -----------------------------------------------
builtin-remote.c
+5 -6
@@ -412,10 +412,9 @@ static void show_list(const char *title, struct string_list *list,
412 return;
413
414 printf(title, list->nr > 1 ? "es" : "", extra_arg);
415 - printf("\n ");
416 - for (i = 0; i < list->nr; i++)
417 - printf("%s%s", i ? " " : "", list->items[i].string);
415 printf("\n");
416 + for (i = 0; i < list->nr; i++)
417 + printf(" %s\n", list->items[i].string);
418 }
419
420 static int get_remote_ref_states(const char *name,
@@ -511,17 +510,17 @@ static int show(int argc, const char **argv)
510 show_list(" Tracked remote branch%s", &states.tracked, "");
511
512 if (states.remote->push_refspec_nr) {
514 - printf(" Local branch%s pushed with 'git push'\n ",
513 + printf(" Local branch%s pushed with 'git push'\n",
514 states.remote->push_refspec_nr > 1 ?
515 "es" : "");
516 for (i = 0; i < states.remote->push_refspec_nr; i++) {
517 struct refspec *spec = states.remote->push + i;
519 - printf(" %s%s%s%s", spec->force ? "+" : "",
518 + printf(" %s%s%s%s\n",
519 + spec->force ? "+" : "",
520 abbrev_branch(spec->src),
521 spec->dst ? ":" : "",
522 spec->dst ? abbrev_branch(spec->dst) : "");
523 }
524 - printf("\n");
524 }
525
526 /* NEEDSWORK: free remote */
t/t5505-remote.sh
+9 -5
@@ -28,7 +28,7 @@ tokens_match () {
28 }
29
30 check_remote_track () {
31 - actual=$(git remote show "$1" | sed -n -e '$p') &&
31 + actual=$(git remote show "$1" | sed -e '1,/Tracked/d') &&
32 shift &&
33 tokens_match "$*" "$actual"
34 }
@@ -115,9 +115,11 @@ cat > test/expect << EOF
115 New remote branch (next fetch will store in remotes/origin)
116 master
117 Tracked remote branches
118 - side master
118 + side
119 + master
120 Local branches pushed with 'git push'
120 - master:upstream +refs/tags/lastbackup
121 + master:upstream
122 + +refs/tags/lastbackup
123 EOF
124
125 test_expect_success 'show' '
@@ -144,9 +146,11 @@ cat > test/expect << EOF
146 Remote branch merged with 'git pull' while on branch master
147 master
148 Tracked remote branches
147 - master side
149 + master
150 + side
151 Local branches pushed with 'git push'
149 - master:upstream +refs/tags/lastbackup
152 + master:upstream
153 + +refs/tags/lastbackup
154 EOF
155
156 test_expect_success 'show -n' '