diff mbox series

[v4] submodule: suppress checking for file name and ref ambiguity for object ids

Message ID pull.725.v4.git.1599425636107.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit 2ce9d4e5c7186e15f2e2f7be06a9db52b5e61bde
Headers show
Series [v4] submodule: suppress checking for file name and ref ambiguity for object ids | expand

Commit Message

Linus Arver via GitGitGadget Sept. 6, 2020, 8:53 p.m. UTC
From: Orgad Shaneh <orgads@gmail.com>

The argv argument of collect_changed_submodules() contains obly object ids
(the objects references of all the refs).

Notify setup_revisions() that the input is not filenames by passing
assume_dashdash, so it can avoid redundant stat for each ref.

Also suppress refname_ambiguity flag to avoid filesystem lookups for
each object. Similar logic can be found in cat-file, pack-objects and more.

This change reduces the time for git fetch in my repo from 25s to 6s.

Signed-off-by: Orgad Shaneh <orgads@gmail.com>
---
    submodule: suppress checking for file name and ref ambiguity for object
    ids
    
    The argv argument of collect_changed_submodules() contains obly object
    ids (submodule references).
    
    Notify setup_revisions() that the input is not filenames by passing
    assume_dashdash, so it can avoid redundant stat for each ref.
    
    A better improvement would be to pass oid_array instead of stringified
    argv, but that will require a larger change, which can be done later.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-725%2Forgads%2Fsubmodule-not-filename-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-725/orgads/submodule-not-filename-v4
Pull-Request: https://github.com/gitgitgadget/git/pull/725

Range-diff vs v3:

 1:  128a7244f9 ! 1:  7134a87921 submodule: suppress checking for file name and ref ambiguity for object ids
     @@ Commit message
          Also suppress refname_ambiguity flag to avoid filesystem lookups for
          each object. Similar logic can be found in cat-file, pack-objects and more.
      
     +    This change reduces the time for git fetch in my repo from 25s to 6s.
     +
          Signed-off-by: Orgad Shaneh <orgads@gmail.com>
      
       ## submodule.c ##


 submodule.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)


base-commit: 3a238e539bcdfe3f9eb5010fd218640c1b499f7a

Comments

Ramsay Jones Sept. 6, 2020, 8:59 p.m. UTC | #1
On 06/09/2020 21:53, Orgad Shaneh via GitGitGadget wrote:
> From: Orgad Shaneh <orgads@gmail.com>
> 
> The argv argument of collect_changed_submodules() contains obly object ids

s/obly/only/

ATB,
Ramsay Jones
diff mbox series

Patch

diff --git a/submodule.c b/submodule.c
index 3cbcf40dfc..e48710e423 100644
--- a/submodule.c
+++ b/submodule.c
@@ -840,9 +840,16 @@  static void collect_changed_submodules(struct repository *r,
 {
 	struct rev_info rev;
 	const struct commit *commit;
+	int save_warning;
+	struct setup_revision_opt s_r_opt = {
+		.assume_dashdash = 1,
+	};
 
+	save_warning = warn_on_object_refname_ambiguity;
+	warn_on_object_refname_ambiguity = 0;
 	repo_init_revisions(r, &rev, NULL);
-	setup_revisions(argv->nr, argv->v, &rev, NULL);
+	setup_revisions(argv->nr, argv->v, &rev, &s_r_opt);
+	warn_on_object_refname_ambiguity = save_warning;
 	if (prepare_revision_walk(&rev))
 		die(_("revision walk setup failed"));