Code

Merge branch 'jk/maint-fetch-submodule-check-fix' into maint
authorJunio C Hamano <gitster@pobox.com>
Sun, 16 Oct 2011 03:46:38 +0000 (20:46 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 16 Oct 2011 03:46:38 +0000 (20:46 -0700)
* jk/maint-fetch-submodule-check-fix:
  fetch: avoid quadratic loop checking for updated submodules

1  2 
submodule.c

diff --cc submodule.c
index ad86534ba1e1e1726fd6427c65182ba954957904,9431c42dfbce3ae6101314e653721bfb3c5cc172..08756387e207700861cfa6dac039334ecd53c7a1
@@@ -478,16 -426,17 +534,21 @@@ static void calculate_changed_submodule
  {
        struct rev_info rev;
        struct commit *commit;
-       const char *argv[] = {NULL, NULL, "--not", "--all", NULL};
-       int argc = ARRAY_SIZE(argv) - 1;
+       struct argv_array argv;
  
 +      /* No need to check if there are no submodules configured */
 +      if (!config_name_for_path.nr)
 +              return;
 +
        init_revisions(&rev, NULL);
-       argv[1] = xstrdup(sha1_to_hex(new_sha1));
-       setup_revisions(argc, argv, &rev, NULL);
+       init_argv(&argv);
+       push_argv(&argv, "--"); /* argv[0] program name */
+       sha1_array_for_each_unique(&ref_tips_after_fetch,
+                                  add_sha1_to_argv, &argv);
+       push_argv(&argv, "--not");
+       sha1_array_for_each_unique(&ref_tips_before_fetch,
+                                  add_sha1_to_argv, &argv);
+       setup_revisions(argv.argc, argv.argv, &rev, NULL);
        if (prepare_revision_walk(&rev))
                die("revision walk setup failed");