From: Junio C Hamano Date: Wed, 20 Jan 2010 21:23:59 +0000 (-0800) Subject: Merge branch 'bg/maint-remote-update-default' into maint X-Git-Tag: v1.6.6.1~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/66276d972c0682d49773c20ca67c33bdab9ab76d?ds=inline;hp=-c Merge branch 'bg/maint-remote-update-default' into maint * bg/maint-remote-update-default: Fix "git remote update" with remotes.defalt set --- 66276d972c0682d49773c20ca67c33bdab9ab76d diff --combined builtin-remote.c index a5019397ff,50abd26a66..c4945b8708 --- a/builtin-remote.c +++ b/builtin-remote.c @@@ -12,45 -12,10 +12,45 @@@ static const char * const builtin_remot "git remote add [-t ] [-m ] [-f] [--mirror] ", "git remote rename ", "git remote rm ", - "git remote set-head [-a | -d | ]", - "git remote show [-n] ", + "git remote set-head (-a | -d | )", + "git remote [-v | --verbose] show [-n] ", "git remote prune [-n | --dry-run] ", - "git remote [-v | --verbose] update [-p | --prune] [group]", + "git remote [-v | --verbose] update [-p | --prune] [group | remote]", + NULL +}; + +static const char * const builtin_remote_add_usage[] = { + "git remote add [] ", + NULL +}; + +static const char * const builtin_remote_rename_usage[] = { + "git remote rename ", + NULL +}; + +static const char * const builtin_remote_rm_usage[] = { + "git remote rm ", + NULL +}; + +static const char * const builtin_remote_sethead_usage[] = { + "git remote set-head (-a | -d | ])", + NULL +}; + +static const char * const builtin_remote_show_usage[] = { + "git remote show [] ", + NULL +}; + +static const char * const builtin_remote_prune_usage[] = { + "git remote prune [] ", + NULL +}; + +static const char * const builtin_remote_update_usage[] = { + "git remote update [] [ | ]...", NULL }; @@@ -105,6 -70,7 +105,6 @@@ static int add(int argc, const char **a int i; struct option options[] = { - OPT_GROUP("add specific options"), OPT_BOOLEAN('f', "fetch", &fetch, "fetch the remote branches"), OPT_CALLBACK('t', "track", &track, "branch", "branch(es) to track", opt_parse_track), @@@ -113,11 -79,11 +113,11 @@@ OPT_END() }; - argc = parse_options(argc, argv, NULL, options, builtin_remote_usage, + argc = parse_options(argc, argv, NULL, options, builtin_remote_add_usage, 0); if (argc < 2) - usage_with_options(builtin_remote_usage, options); + usage_with_options(builtin_remote_add_usage, options); name = argv[0]; url = argv[1]; @@@ -272,9 -238,7 +272,9 @@@ static int get_ref_states(const struct die("Could not get fetch map for refspec %s", states->remote->fetch_refspec[i]); - states->new.strdup_strings = states->tracked.strdup_strings = 1; + states->new.strdup_strings = 1; + states->tracked.strdup_strings = 1; + states->stale.strdup_strings = 1; for (ref = fetch_map; ref; ref = ref->next) { unsigned char sha1[20]; if (!ref->peer_ref || read_ref(ref->peer_ref->name, sha1)) @@@ -560,7 -524,7 +560,7 @@@ static int mv(int argc, const char **ar int i; if (argc != 3) - usage_with_options(builtin_remote_usage, options); + usage_with_options(builtin_remote_rename_usage, options); rename.old = argv[1]; rename.new = argv[2]; @@@ -701,7 -665,7 +701,7 @@@ static int rm(int argc, const char **ar int i, result; if (argc != 2) - usage_with_options(builtin_remote_usage, options); + usage_with_options(builtin_remote_rm_usage, options); remote = remote_get(argv[1]); if (!remote) @@@ -770,7 -734,7 +770,7 @@@ static void clear_push_info(void *util static void free_remote_ref_states(struct ref_states *states) { string_list_clear(&states->new, 0); - string_list_clear(&states->stale, 0); + string_list_clear(&states->stale, 1); string_list_clear(&states->tracked, 0); string_list_clear(&states->heads, 0); string_list_clear_func(&states->push, clear_push_info); @@@ -973,7 -937,7 +973,7 @@@ static int show_push_info_item(struct s status = "up to date"; break; case PUSH_STATUS_FASTFORWARD: - status = "fast forwardable"; + status = "fast-forwardable"; break; case PUSH_STATUS_OUTOFDATE: status = "local out of date"; @@@ -996,6 -960,7 +996,6 @@@ static int show(int argc, const char ** { int no_query = 0, result = 0, query_flag = 0; struct option options[] = { - OPT_GROUP("show specific options"), OPT_BOOLEAN('n', NULL, &no_query, "do not query remotes"), OPT_END() }; @@@ -1003,7 -968,7 +1003,7 @@@ struct string_list info_list = { NULL, 0, 0, 0 }; struct show_info info; - argc = parse_options(argc, argv, NULL, options, builtin_remote_usage, + argc = parse_options(argc, argv, NULL, options, builtin_remote_show_usage, 0); if (argc < 1) @@@ -1100,13 -1065,14 +1100,13 @@@ static int set_head(int argc, const cha char *head_name = NULL; struct option options[] = { - OPT_GROUP("set-head specific options"), OPT_BOOLEAN('a', "auto", &opt_a, "set refs/remotes//HEAD according to remote"), OPT_BOOLEAN('d', "delete", &opt_d, "delete refs/remotes//HEAD"), OPT_END() }; - argc = parse_options(argc, argv, NULL, options, builtin_remote_usage, + argc = parse_options(argc, argv, NULL, options, builtin_remote_sethead_usage, 0); if (argc) strbuf_addf(&buf, "refs/remotes/%s/HEAD", argv[0]); @@@ -1132,7 -1098,7 +1132,7 @@@ if (delete_ref(buf.buf, NULL, REF_NODEREF)) result |= error("Could not delete %s", buf.buf); } else - usage_with_options(builtin_remote_usage, options); + usage_with_options(builtin_remote_sethead_usage, options); if (head_name) { unsigned char sha1[20]; @@@ -1156,15 -1122,16 +1156,15 @@@ static int prune(int argc, const char * { int dry_run = 0, result = 0; struct option options[] = { - OPT_GROUP("prune specific options"), OPT__DRY_RUN(&dry_run), OPT_END() }; - argc = parse_options(argc, argv, NULL, options, builtin_remote_usage, + argc = parse_options(argc, argv, NULL, options, builtin_remote_prune_usage, 0); if (argc < 1) - usage_with_options(builtin_remote_usage, options); + usage_with_options(builtin_remote_prune_usage, options); for (; argc; argc--, argv++) result |= prune_remote(*argv, dry_run); @@@ -1219,6 -1186,7 +1219,6 @@@ static int update(int argc, const char { int i, prune = 0; struct option options[] = { - OPT_GROUP("update specific options"), OPT_BOOLEAN('p', "prune", &prune, "prune remotes after fetching"), OPT_END() @@@ -1229,7 -1197,7 +1229,7 @@@ fetch_argv = xmalloc(sizeof(char *) * (argc+5)); - argc = parse_options(argc, argv, NULL, options, builtin_remote_usage, + argc = parse_options(argc, argv, NULL, options, builtin_remote_update_usage, PARSE_OPT_KEEP_ARGV0); fetch_argv[fetch_argc++] = "fetch"; @@@ -1238,13 -1206,11 +1238,11 @@@ fetch_argv[fetch_argc++] = "--prune"; if (verbose) fetch_argv[fetch_argc++] = "-v"; - if (argc < 2) { + fetch_argv[fetch_argc++] = "--multiple"; + if (argc < 2) fetch_argv[fetch_argc++] = "default"; - } else { - fetch_argv[fetch_argc++] = "--multiple"; - for (i = 1; i < argc; i++) - fetch_argv[fetch_argc++] = argv[i]; - } + for (i = 1; i < argc; i++) + fetch_argv[fetch_argc++] = argv[i]; if (strcmp(fetch_argv[fetch_argc-1], "default") == 0) { git_config(get_remote_default, &default_defined); @@@ -1318,7 -1284,7 +1316,7 @@@ static int show_all(void int cmd_remote(int argc, const char **argv, const char *prefix) { struct option options[] = { - OPT__VERBOSE(&verbose), + OPT_BOOLEAN('v', "verbose", &verbose, "be verbose; must be placed before a subcommand"), OPT_END() }; int result; diff --combined t/t5505-remote.sh index fd166d9de3,989f1d44a5..936fe0a1a6 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@@ -158,7 -158,7 +158,7 @@@ cat > test/expect << EO another master Local refs configured for 'git push': - ahead forces to master (fast forwardable) + ahead forces to master (fast-forwardable) master pushes to another (up to date) EOF @@@ -419,6 -419,20 +419,20 @@@ test_expect_success 'update default (ov ' + test_expect_success 'update (with remotes.default defined)' ' + + (cd one && + for b in $(git branch -r) + do + git branch -r -d $b || break + done && + git config remotes.default "drosophila" && + git remote update && + git branch -r > output && + test_cmp expect output) + + ' + test_expect_success '"remote show" does not show symbolic refs' ' git clone one three &&