author | Junio C Hamano <gitster@pobox.com> | |
Wed, 5 Oct 2011 19:35:54 +0000 (12:35 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 5 Oct 2011 19:35:54 +0000 (12:35 -0700) |
* jk/maint-fetch-submodule-check-fix:
fetch: avoid quadratic loop checking for updated submodules
fetch: avoid quadratic loop checking for updated submodules
1 | 2 | |||
---|---|---|---|---|
submodule.c | patch | | diff1 | | diff2 | | blob | history |
diff --cc submodule.c
index ad86534ba1e1e1726fd6427c65182ba954957904,9431c42dfbce3ae6101314e653721bfb3c5cc172..08756387e207700861cfa6dac039334ecd53c7a1
--- 1/submodule.c
--- 2/submodule.c
+++ b/submodule.c
{
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");