blob: dc1c14bde3741715f9dee0768f061e31ba2d7330 [file] [log] [blame]
Antonio Ospite2b1257e2018-10-25 18:18:13 +02001#include "test-tool.h"
2#include "submodule-config.h"
3
Jeff Kinge885a842020-09-30 08:28:18 -04004static void die_usage(const char **argv, const char *msg)
Antonio Ospite2b1257e2018-10-25 18:18:13 +02005{
6 fprintf(stderr, "%s\n", msg);
7 fprintf(stderr, "Usage: %s <submodulepath> <config name>\n", argv[0]);
8 exit(1);
9}
10
11int cmd__submodule_nested_repo_config(int argc, const char **argv)
12{
Stefan Bellerd5498e02018-11-28 16:27:53 -080013 struct repository subrepo;
Antonio Ospite2b1257e2018-10-25 18:18:13 +020014
15 if (argc < 3)
Jeff Kinge885a842020-09-30 08:28:18 -040016 die_usage(argv, "Wrong number of arguments.");
Antonio Ospite2b1257e2018-10-25 18:18:13 +020017
18 setup_git_directory();
19
Jonathan Tan8eb8dcf2021-09-09 11:47:28 -070020 if (repo_submodule_init(&subrepo, the_repository, argv[1], null_oid())) {
Jeff Kinge885a842020-09-30 08:28:18 -040021 die_usage(argv, "Submodule not found.");
Antonio Ospite2b1257e2018-10-25 18:18:13 +020022 }
23
24 /* Read the config of _child_ submodules. */
Stefan Bellerd5498e02018-11-28 16:27:53 -080025 print_config_from_gitmodules(&subrepo, argv[2]);
Antonio Ospite2b1257e2018-10-25 18:18:13 +020026
27 submodule_free(the_repository);
28
29 return 0;
30}