Antonio Ospite | 2b1257e | 2018-10-25 18:18:13 +0200 | [diff] [blame] | 1 | #include "test-tool.h" |
| 2 | #include "submodule-config.h" |
| 3 | |
Jeff King | e885a84 | 2020-09-30 08:28:18 -0400 | [diff] [blame] | 4 | static void die_usage(const char **argv, const char *msg) |
Antonio Ospite | 2b1257e | 2018-10-25 18:18:13 +0200 | [diff] [blame] | 5 | { |
| 6 | fprintf(stderr, "%s\n", msg); |
| 7 | fprintf(stderr, "Usage: %s <submodulepath> <config name>\n", argv[0]); |
| 8 | exit(1); |
| 9 | } |
| 10 | |
| 11 | int cmd__submodule_nested_repo_config(int argc, const char **argv) |
| 12 | { |
Stefan Beller | d5498e0 | 2018-11-28 16:27:53 -0800 | [diff] [blame] | 13 | struct repository subrepo; |
Antonio Ospite | 2b1257e | 2018-10-25 18:18:13 +0200 | [diff] [blame] | 14 | |
| 15 | if (argc < 3) |
Jeff King | e885a84 | 2020-09-30 08:28:18 -0400 | [diff] [blame] | 16 | die_usage(argv, "Wrong number of arguments."); |
Antonio Ospite | 2b1257e | 2018-10-25 18:18:13 +0200 | [diff] [blame] | 17 | |
| 18 | setup_git_directory(); |
| 19 | |
Jonathan Tan | 8eb8dcf | 2021-09-09 11:47:28 -0700 | [diff] [blame] | 20 | if (repo_submodule_init(&subrepo, the_repository, argv[1], null_oid())) { |
Jeff King | e885a84 | 2020-09-30 08:28:18 -0400 | [diff] [blame] | 21 | die_usage(argv, "Submodule not found."); |
Antonio Ospite | 2b1257e | 2018-10-25 18:18:13 +0200 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | /* Read the config of _child_ submodules. */ |
Stefan Beller | d5498e0 | 2018-11-28 16:27:53 -0800 | [diff] [blame] | 25 | print_config_from_gitmodules(&subrepo, argv[2]); |
Antonio Ospite | 2b1257e | 2018-10-25 18:18:13 +0200 | [diff] [blame] | 26 | |
| 27 | submodule_free(the_repository); |
| 28 | |
| 29 | return 0; |
| 30 | } |