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>
'git-remote' [-v | --verbose]
'git-remote' add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>
'git-remote' rm <name>
'git-remote' [-v | --verbose]
'git-remote' add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>
'git-remote' rm <name>
-'git-remote' show <name>
+'git-remote' show [-n] <name>
'git-remote' prune <name>
'git-remote' update [group]
'git-remote' prune <name>
'git-remote' update [group]
static int show_or_prune(int argc, const char **argv, int prune)
{
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"),
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;
OPT_END()
};
struct ref_states states;
struct transport *transport;
const struct ref *ref;
struct strbuf buf;
struct transport *transport;
const struct ref *ref;
struct strbuf buf;
states.remote = remote_get(*argv);
if (!states.remote)
return error("No such remote: %s", *argv);
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);
- 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++) {
if (prune) {
for (i = 0; i < states.stale.nr; i++) {
- 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",
if (states.remote->push_refspec_nr) {
printf(" Local branch%s pushed with 'git push'\n ",
if (states.remote->push_refspec_nr) {
printf(" Local branch%s pushed with 'git push'\n ",
test_cmp expect 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
+ Local branches pushed with 'git push'
+ master:upstream +refs/tags/lastbackup
+EOF
+
+test_expect_success 'show -n' '
+ (mv one one.unreachable &&
+ cd test &&
+ git remote show -n origin > output &&
+ mv ../one.unreachable ../one &&
+ test_cmp expect output)
+'
+
test_expect_success 'prune' '
(cd one &&
git branch -m side side2) &&
test_expect_success 'prune' '
(cd one &&
git branch -m side side2) &&