@matheusbsbs / matheus-bagliano / commits / e7d5a97d5e
Fork 0

remote show: list tracked remote branches with -n

Signed-off-by: Olivier Marin <dkr@freesurf.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Olivier Marin committed Jun 11, 2008 at 00:54 UTC e7d5a97d5e131925ccae48db94f2069631a8aa41
2 files changed +22 -2
builtin-remote.c
+20 -2
@@ -444,6 +444,22 @@ static int get_remote_ref_states(const char *name,
444 return 0;
445 }
446
447 +static int append_ref_to_tracked_list(const char *refname,
448 + const unsigned char *sha1, int flags, void *cb_data)
449 +{
450 + struct ref_states *states = cb_data;
451 + struct refspec refspec;
452 +
453 + memset(&refspec, 0, sizeof(refspec));
454 + refspec.dst = (char *)refname;
455 + if (!remote_find_tracking(states->remote, &refspec)) {
456 + path_list_append(skip_prefix(refspec.src, "refs/heads/"),
457 + &states->tracked);
458 + }
459 +
460 + return 0;
461 +}
462 +
463 static int show(int argc, const char **argv)
464 {
465 int no_query = 0, result = 0;
@@ -494,10 +510,12 @@ static int show(int argc, const char **argv)
510 strbuf_release(&buf);
511 show_list(" Stale tracking branch%s (use 'git remote "
512 "prune')", &states.stale);
497 - show_list(" Tracked remote branch%s",
498 - &states.tracked);
513 }
514
515 + if (no_query)
516 + for_each_ref(append_ref_to_tracked_list, &states);
517 + show_list(" Tracked remote branch%s", &states.tracked);
518 +
519 if (states.remote->push_refspec_nr) {
520 printf(" Local branch%s pushed with 'git push'\n ",
521 states.remote->push_refspec_nr > 1 ?
t/t5505-remote.sh
+2
@@ -143,6 +143,8 @@ cat > test/expect << EOF
143 URL: $(pwd)/one/.git
144 Remote branch merged with 'git pull' while on branch master
145 master
146 + Tracked remote branches
147 + master side
148 Local branches pushed with 'git push'
149 master:upstream +refs/tags/lastbackup
150 EOF