]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'bg/maint-remote-update-default' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 20 Jan 2010 21:23:59 +0000 (13:23 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Jan 2010 21:23:59 +0000 (13:23 -0800)
* bg/maint-remote-update-default:
  Fix "git remote update" with remotes.defalt set

1  2 
builtin-remote.c
t/t5505-remote.sh

diff --combined builtin-remote.c
index a5019397ff840204963e4e4b23d2ca16de1a332a,50abd26a66c091e2374744cdf5bd3b0c5dce889e..c4945b870882834fdaa75fd3d65f664570f6a5da
@@@ -12,45 -12,10 +12,45 @@@ static const char * const builtin_remot
        "git remote add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>",
        "git remote rename <old> <new>",
        "git remote rm <name>",
 -      "git remote set-head <name> [-a | -d | <branch>]",
 -      "git remote show [-n] <name>",
 +      "git remote set-head <name> (-a | -d | <branch>)",
 +      "git remote [-v | --verbose] show [-n] <name>",
        "git remote prune [-n | --dry-run] <name>",
 -      "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 [<options>] <name> <url>",
 +      NULL
 +};
 +
 +static const char * const builtin_remote_rename_usage[] = {
 +      "git remote rename <old> <new>",
 +      NULL
 +};
 +
 +static const char * const builtin_remote_rm_usage[] = {
 +      "git remote rm <name>",
 +      NULL
 +};
 +
 +static const char * const builtin_remote_sethead_usage[] = {
 +      "git remote set-head <name> (-a | -d | <branch>])",
 +      NULL
 +};
 +
 +static const char * const builtin_remote_show_usage[] = {
 +      "git remote show [<options>] <name>",
 +      NULL
 +};
 +
 +static const char * const builtin_remote_prune_usage[] = {
 +      "git remote prune [<options>] <name>",
 +      NULL
 +};
 +
 +static const char * const builtin_remote_update_usage[] = {
 +      "git remote update [<options>] [<group> | <remote>]...",
        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),
                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()
        };
        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/<name>/HEAD according to remote"),
                OPT_BOOLEAN('d', "delete", &opt_d,
                            "delete refs/remotes/<name>/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]);
                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()
  
        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";
                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 fd166d9de356dafb000504506285a6f77fcc0a37,989f1d44a579dedb58597cb65798cc1afbf80856..936fe0a1a635bc8a553962f13bff32e873c358cd
@@@ -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 &&