diff options
author | Olivier Marin <dkr@freesurf.fr> | 2008-06-10 16:51:08 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-06-10 22:30:01 -0700 |
commit | 0ecfcb3b700e7e3097a55f015894ad75f1097090 (patch) | |
tree | ddf0505acd318b58dfc6dcbd9dfecc3c9a3d83e4 /builtin-remote.c | |
parent | ea81e10ff4e31820407f4cb1b8ebd87de9e51737 (diff) | |
download | git-0ecfcb3b700e7e3097a55f015894ad75f1097090.tar.gz |
remote show: fix the -n option
The perl version accepted a -n flag, to show local informations only
without querying remote heads, that seems to have been lost in the C
revrite.
This restores the older behaviour and add a test case.
Signed-off-by: Olivier Marin <dkr@freesurf.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-remote.c')
-rw-r--r-- | builtin-remote.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/builtin-remote.c b/builtin-remote.c index c49f00f58b..efe74c7d5d 100644 --- a/builtin-remote.c +++ b/builtin-remote.c @@ -421,10 +421,10 @@ static void show_list(const char *title, struct path_list *list) static int show_or_prune(int argc, const char **argv, int prune) { - int dry_run = 0, result = 0; + int no_query = 0, result = 0; struct option options[] = { OPT_GROUP("show specific options"), - OPT__DRY_RUN(&dry_run), + OPT_BOOLEAN('n', NULL, &no_query, "do not query remotes"), OPT_END() }; struct ref_states states; @@ -442,21 +442,23 @@ static int show_or_prune(int argc, const char **argv, int prune) struct transport *transport; const struct ref *ref; struct strbuf buf; - int i, got_states; + int i; states.remote = remote_get(*argv); if (!states.remote) return error("No such remote: %s", *argv); - transport = transport_get(NULL, states.remote->url_nr > 0 ? - states.remote->url[0] : NULL); - ref = transport_get_remote_refs(transport); - transport_disconnect(transport); read_branches(); - got_states = get_ref_states(ref, &states); - if (got_states) - result = error("Error getting local info for '%s'", - states.remote->name); + + if (!no_query) { + transport = transport_get(NULL, + states.remote->url_nr > 0 ? + states.remote->url[0] : NULL); + ref = transport_get_remote_refs(transport); + transport_disconnect(transport); + + get_ref_states(ref, &states); + } if (prune) { for (i = 0; i < states.stale.nr; i++) { @@ -486,17 +488,17 @@ static int show_or_prune(int argc, const char **argv, int prune) printf("\n"); } - if (got_states) - continue; - strbuf_init(&buf, 0); - strbuf_addf(&buf, " New remote branch%%s (next fetch will " - "store in remotes/%s)", states.remote->name); - show_list(buf.buf, &states.new); - strbuf_release(&buf); - show_list(" Stale tracking branch%s (use 'git remote prune')", - &states.stale); - show_list(" Tracked remote branch%s", + if (!no_query) { + strbuf_init(&buf, 0); + strbuf_addf(&buf, " New remote branch%%s (next fetch " + "will store in remotes/%s)", states.remote->name); + show_list(buf.buf, &states.new); + strbuf_release(&buf); + show_list(" Stale tracking branch%s (use 'git remote " + "prune')", &states.stale); + show_list(" Tracked remote branch%s", &states.tracked); + } if (states.remote->push_refspec_nr) { printf(" Local branch%s pushed with 'git push'\n ", |