18
struct hashmap for_path;
19
struct hashmap for_name;
20
unsigned initialized:1;
21
+ unsigned gitmodules_read:1;
22
};
23
24
/*
94
hashmap_free(&cache->for_path, 1);
95
hashmap_free(&cache->for_name, 1);
96
cache->initialized = 0;
97
+ cache->gitmodules_read = 0;
98
}
99
100
void submodule_cache_free(struct submodule_cache *cache)
559
struct repository *repo = data;
560
struct parse_config_parameter parameter;
561
560
- submodule_cache_check_init(repo);
561
-
562
parameter.cache = repo->submodule_cache;
563
parameter.treeish_name = NULL;
564
parameter.gitmodules_sha1 = null_sha1;
569
570
void repo_read_gitmodules(struct repository *repo)
571
{
572
+ submodule_cache_check_init(repo);
573
+
574
if (repo->worktree) {
575
char *gitmodules;
576
584
585
free(gitmodules);
586
}
587
+
588
+ repo->submodule_cache->gitmodules_read = 1;
589
}
590
591
void gitmodules_config_oid(const struct object_id *commit_oid)
593
struct strbuf rev = STRBUF_INIT;
594
struct object_id oid;
595
596
+ submodule_cache_check_init(the_repository);
597
+
598
if (gitmodule_oid_from_commit(commit_oid, &oid, &rev)) {
599
git_config_from_blob_oid(gitmodules_cb, rev.buf,
600
&oid, the_repository);
601
}
602
strbuf_release(&rev);
603
+
604
+ the_repository->submodule_cache->gitmodules_read = 1;
605
+}
606
+
607
+static void gitmodules_read_check(struct repository *repo)
608
+{
609
+ submodule_cache_check_init(repo);
610
+
611
+ /* read the repo's .gitmodules file if it hasn't been already */
612
+ if (!repo->submodule_cache->gitmodules_read)
613
+ repo_read_gitmodules(repo);
614
}
615
616
const struct submodule *submodule_from_name(const struct object_id *treeish_name,
617
const char *name)
618
{
602
- submodule_cache_check_init(the_repository);
619
+ gitmodules_read_check(the_repository);
620
return config_from(the_repository->submodule_cache, treeish_name, name, lookup_name);
621
}
622
623
const struct submodule *submodule_from_path(const struct object_id *treeish_name,
624
const char *path)
625
{
609
- submodule_cache_check_init(the_repository);
626
+ gitmodules_read_check(the_repository);
627
return config_from(the_repository->submodule_cache, treeish_name, path, lookup_path);
628
}
629
631
const struct object_id *treeish_name,
632
const char *key)
633
{
617
- submodule_cache_check_init(repo);
634
+ gitmodules_read_check(repo);
635
return config_from(repo->submodule_cache, treeish_name,
636
key, lookup_path);
637
}