From: Olivier Marin <dkr@xxxxxxxxxxx> Signed-off-by: Olivier Marin <dkr@xxxxxxxxxxx> --- builtin-remote.c | 25 +++++++++++++++++++++++-- t/t5505-remote.sh | 3 ++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/builtin-remote.c b/builtin-remote.c index 851bdde..de4a4f2 100644 --- a/builtin-remote.c +++ b/builtin-remote.c @@ -444,6 +444,25 @@ static int get_remote_ref_states(const char *name, return 0; } +static int append_ref_to_tracked_list(const char *refname, + const unsigned char *sha1, int flags, void *cb_data) +{ + struct ref_states *states = cb_data; + struct strbuf buf; + + strbuf_init(&buf, 0); + strbuf_addf(&buf, "%s/", states->remote->name); + if (strncmp(buf.buf, refname, buf.len)) { + strbuf_release(&buf); + return 0; + } + + path_list_append(skip_prefix(refname, strbuf_detach(&buf, NULL)), + &states->tracked); + + return 0; +} + static int show(int argc, const char **argv) { int no_query = 0, result = 0; @@ -494,10 +513,12 @@ static int show(int argc, const char **argv) strbuf_release(&buf); show_list(" Stale tracking branch%s (use 'git remote " "prune')", &states.stale); - show_list(" Tracked remote branch%s", - &states.tracked); } + if (no_query) + for_each_remote_ref(append_ref_to_tracked_list, &states); + show_list(" Tracked remote branch%s", &states.tracked); + if (states.remote->push_refspec_nr) { printf(" Local branch%s pushed with 'git push'\n ", states.remote->push_refspec_nr > 1 ? diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index c27cfad..ec5ea54 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -137,12 +137,13 @@ test_expect_success 'show' ' git remote show origin > output && test_cmp expect output) ' - cat > test/expect << EOF * remote origin URL: $(pwd)/one/.git Remote branch merged with 'git pull' while on branch master master + Tracked remote branch + side Local branches pushed with 'git push' master:upstream +refs/tags/lastbackup EOF -- 1.5.6.rc2.160.gd660c -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html