summaryrefslogtreecommitdiff
path: root/t/helper
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2018-11-29 00:27:53 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-12-05 02:42:32 (GMT)
commitd5498e087175ad7bbb0460a40cfb55cc3726226d (patch)
treed3daba2aa5d3f427a345c3a4386212bbd4668492 /t/helper
parentbcd7337243f4f20091d478c71682d68dd2100207 (diff)
downloadgit-d5498e087175ad7bbb0460a40cfb55cc3726226d.zip
git-d5498e087175ad7bbb0460a40cfb55cc3726226d.tar.gz
git-d5498e087175ad7bbb0460a40cfb55cc3726226d.tar.bz2
repository: repo_submodule_init to take a submodule struct
When constructing a struct repository for a submodule for some revision of the superproject where the submodule is not contained in the index, it may not be present in the working tree currently either. In that situation giving a 'path' argument is not useful. Upgrade the repo_submodule_init function to take a struct submodule instead. The submodule struct can be obtained via submodule_from_{path, name} or an artificial submodule struct can be passed in. While we are at it, rename the repository struct in the repo_submodule_init function, which is to be initialized, to a name that is not confused with the struct submodule as easily. Perform such renames in similar functions as well. Also move its documentation into the header file. Reviewed-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/helper')
-rw-r--r--t/helper/test-submodule-nested-repo-config.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/t/helper/test-submodule-nested-repo-config.c b/t/helper/test-submodule-nested-repo-config.c
index a31e2a9..bc97929 100644
--- a/t/helper/test-submodule-nested-repo-config.c
+++ b/t/helper/test-submodule-nested-repo-config.c
@@ -10,19 +10,21 @@ static void die_usage(int argc, const char **argv, const char *msg)
int cmd__submodule_nested_repo_config(int argc, const char **argv)
{
- struct repository submodule;
+ struct repository subrepo;
+ const struct submodule *sub;
if (argc < 3)
die_usage(argc, argv, "Wrong number of arguments.");
setup_git_directory();
- if (repo_submodule_init(&submodule, the_repository, argv[1])) {
+ sub = submodule_from_path(the_repository, &null_oid, argv[1]);
+ if (repo_submodule_init(&subrepo, the_repository, sub)) {
die_usage(argc, argv, "Submodule not found.");
}
/* Read the config of _child_ submodules. */
- print_config_from_gitmodules(&submodule, argv[2]);
+ print_config_from_gitmodules(&subrepo, argv[2]);
submodule_free(the_repository);