Code

Merge branch 'bg/fetch-multi'
authorJunio C Hamano <gitster@pobox.com>
Mon, 23 Nov 2009 08:03:15 +0000 (00:03 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Nov 2009 08:03:15 +0000 (00:03 -0800)
* bg/fetch-multi:
  Re-implement 'git remote update' using 'git fetch'
  builtin-fetch: add --dry-run option
  builtin-fetch: add --prune option
  teach warn_dangling_symref to take a FILE argument
  remote: refactor some logic into get_stale_heads()
  Add missing test for 'git remote update --prune'
  Add the configuration option skipFetchAll
  Teach the --multiple option to 'git fetch'
  Teach the --all option to 'git fetch'

1  2 
Documentation/config.txt
Documentation/git-fetch.txt
Documentation/pull-fetch-param.txt
builtin-fetch.c
builtin-remote.c
remote.c
t/t5505-remote.sh

Simple merge
Simple merge
Simple merge
diff --cc builtin-fetch.c
Simple merge
index b08608ef967a86ae6838bc5e5fd775697d212e0b,fb0d66d8c5ab94156326fe5eb9ef91acb4992c00..79166262182a1cb51839e20b8abcef8f6752b59f
@@@ -1255,52 -1184,45 +1215,44 @@@ static int get_remote_default(const cha
  
  static int update(int argc, const char **argv)
  {
-       int i, result = 0, prune = 0;
-       struct string_list list = { NULL, 0, 0, 0 };
-       static const char *default_argv[] = { NULL, "default", NULL };
+       int i, prune = 0;
        struct option options[] = {
 -              OPT_GROUP("update specific options"),
                OPT_BOOLEAN('p', "prune", &prune,
                            "prune remotes after fetching"),
                OPT_END()
        };
+       const char **fetch_argv;
+       int fetch_argc = 0;
+       int default_defined = 0;
+       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);
-       if (argc < 2) {
-               argc = 2;
-               argv = default_argv;
-       }
  
-       remote_group.list = &list;
-       for (i = 1; i < argc; i++) {
-               int groups_found = 0;
-               remote_group.name = argv[i];
-               result = git_config(get_remote_group, &groups_found);
-               if (!groups_found && (i != 1 || strcmp(argv[1], "default"))) {
-                       struct remote *remote;
-                       if (!remote_is_configured(argv[i]))
-                               die("No such remote or remote group: %s",
-                                   argv[i]);
-                       remote = remote_get(argv[i]);
-                       string_list_append(remote->name, remote_group.list);
-               }
-       }
+       fetch_argv[fetch_argc++] = "fetch";
  
-       if (!result && !list.nr  && argc == 2 && !strcmp(argv[1], "default"))
-               result = for_each_remote(get_one_remote_for_update, &list);
+       if (prune)
+               fetch_argv[fetch_argc++] = "--prune";
+       if (verbose)
+               fetch_argv[fetch_argc++] = "-v";
+       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 = 0; i < list.nr; i++) {
-               int err = fetch_remote(list.items[i].string);
-               result |= err;
-               if (!err && prune)
-                       result |= prune_remote(list.items[i].string, 0);
+       if (strcmp(fetch_argv[fetch_argc-1], "default") == 0) {
+               git_config(get_remote_default, &default_defined);
+               if (!default_defined)
+                       fetch_argv[fetch_argc-1] = "--all";
        }
  
-       /* all names were strdup()ed or strndup()ed */
-       list.strdup_strings = 1;
-       string_list_clear(&list, 0);
+       fetch_argv[fetch_argc] = NULL;
  
-       return result;
+       return run_command_v_opt(fetch_argv, RUN_GIT_CMD);
  }
  
  static int get_one_entry(struct remote *remote, void *priv)
diff --cc remote.c
Simple merge
Simple merge