mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
![Stefan Beller](/assets/img/avatar_default.png)
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>
33 lines
784 B
C
33 lines
784 B
C
#include "test-tool.h"
|
|
#include "submodule-config.h"
|
|
|
|
static void die_usage(int argc, const char **argv, const char *msg)
|
|
{
|
|
fprintf(stderr, "%s\n", msg);
|
|
fprintf(stderr, "Usage: %s <submodulepath> <config name>\n", argv[0]);
|
|
exit(1);
|
|
}
|
|
|
|
int cmd__submodule_nested_repo_config(int argc, const char **argv)
|
|
{
|
|
struct repository subrepo;
|
|
const struct submodule *sub;
|
|
|
|
if (argc < 3)
|
|
die_usage(argc, argv, "Wrong number of arguments.");
|
|
|
|
setup_git_directory();
|
|
|
|
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(&subrepo, argv[2]);
|
|
|
|
submodule_free(the_repository);
|
|
|
|
return 0;
|
|
}
|