Skip to content

Commit a462bee

Browse files
orgadsgitster
authored andcommitted
submodule: suppress checking for file name and ref ambiguity for object ids
The argv argument of collect_changed_submodules() contains only 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3a238e5 commit a462bee

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

submodule.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,9 +840,16 @@ static void collect_changed_submodules(struct repository *r,
840840
{
841841
struct rev_info rev;
842842
const struct commit *commit;
843+
int save_warning;
844+
struct setup_revision_opt s_r_opt = {
845+
.assume_dashdash = 1,
846+
};
843847

848+
save_warning = warn_on_object_refname_ambiguity;
849+
warn_on_object_refname_ambiguity = 0;
844850
repo_init_revisions(r, &rev, NULL);
845-
setup_revisions(argv->nr, argv->v, &rev, NULL);
851+
setup_revisions(argv->nr, argv->v, &rev, &s_r_opt);
852+
warn_on_object_refname_ambiguity = save_warning;
846853
if (prepare_revision_walk(&rev))
847854
die(_("revision walk setup failed"));
848855

0 commit comments

Comments
 (0)