From 18322badc2b3b7f49f79da5273e003e9c0c4f549 Mon Sep 17 00:00:00 2001 From: Jens Lehmann Date: Fri, 9 Sep 2011 20:22:03 +0200 Subject: fetch: skip on-demand checking when no submodules are configured It makes no sense to do the - possibly very expensive - call to "rev-list --not --all" in check_for_new_submodule_commits() when there aren't any submodules configured. Leave check_for_new_submodule_commits() early when no name <-> path mappings for submodules are found in the configuration. To make that work reading the configuration had to be moved further up in cmd_fetch(), as doing that after the actual fetch of the superproject was too late. Reported-by: Martin Fick Signed-off-by: Jens Lehmann Signed-off-by: Junio C Hamano --- builtin/fetch.c | 15 +++++++++------ submodule.c | 4 ++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index 93c99385a9..e422ced929 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -941,6 +941,15 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, builtin_fetch_options, builtin_fetch_usage, 0); + if (recurse_submodules != RECURSE_SUBMODULES_OFF) { + if (recurse_submodules_default) { + int arg = parse_fetch_recurse_submodules_arg("--recurse-submodules-default", recurse_submodules_default); + set_config_fetch_recurse_submodules(arg); + } + gitmodules_config(); + git_config(submodule_config, NULL); + } + if (all) { if (argc == 1) die(_("fetch --all does not take a repository argument")); @@ -976,12 +985,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) if (!result && (recurse_submodules != RECURSE_SUBMODULES_OFF)) { const char *options[10]; int num_options = 0; - if (recurse_submodules_default) { - int arg = parse_fetch_recurse_submodules_arg("--recurse-submodules-default", recurse_submodules_default); - set_config_fetch_recurse_submodules(arg); - } - gitmodules_config(); - git_config(submodule_config, NULL); add_options_to_argv(&num_options, options); result = fetch_populated_submodules(num_options, options, submodule_prefix, diff --git a/submodule.c b/submodule.c index b6dec70bd1..e0d5dcfedd 100644 --- a/submodule.c +++ b/submodule.c @@ -373,6 +373,10 @@ void check_for_new_submodule_commits(unsigned char new_sha1[20]) const char *argv[] = {NULL, NULL, "--not", "--all", NULL}; int argc = ARRAY_SIZE(argv) - 1; + /* 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); -- cgit v1.2.3 From 740a8fc2249cf7d8b39ab50a25bbf86554158ae7 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 12 Sep 2011 10:33:03 -0700 Subject: Git 1.7.6.3 Signed-off-by: Junio C Hamano --- Documentation/RelNotes/1.7.6.3.txt | 4 ++++ Documentation/git.txt | 3 ++- GIT-VERSION-GEN | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Documentation/RelNotes/1.7.6.3.txt b/Documentation/RelNotes/1.7.6.3.txt index c05efb2439..95971831b9 100644 --- a/Documentation/RelNotes/1.7.6.3.txt +++ b/Documentation/RelNotes/1.7.6.3.txt @@ -7,6 +7,10 @@ Fixes since v1.7.6.2 * "git -c var=value subcmd" misparsed the custom configuration when value contained an equal sign. + * "git fetch" had a major performance regression, wasting many + needless cycles in a repository where there is no submodules + present. This was especially bad, when there were many refs. + * "git reflog $refname" did not default to the "show" subcommand as the documentation advertised the command to do. diff --git a/Documentation/git.txt b/Documentation/git.txt index 167ad5e9d3..3562da85e9 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -44,9 +44,10 @@ unreleased) version of git, that is available from 'master' branch of the `git.git` repository. Documentation for older releases are available here: -* link:v1.7.6.2/git.html[documentation for release 1.7.6.2] +* link:v1.7.6.3/git.html[documentation for release 1.7.6.3] * release notes for + link:RelNotes/1.7.6.3.txt[1.7.6.3], link:RelNotes/1.7.6.2.txt[1.7.6.2], link:RelNotes/1.7.6.1.txt[1.7.6.1], link:RelNotes/1.7.6.txt[1.7.6]. diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 3b15c1779d..b74b21f7dd 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v1.7.6.2 +DEF_VER=v1.7.6.3 LF=' ' -- cgit v1.2.3