]>
git.ipfire.org Git - thirdparty/git.git/blob - t/helper/test-submodule-config.c
4 #include "object-name.h"
6 #include "submodule-config.h"
9 static void die_usage(int argc
, const char **argv
, const char *msg
)
11 fprintf(stderr
, "%s\n", msg
);
12 fprintf(stderr
, "Usage: %s [<commit> <submodulepath>] ...\n", argv
[0]);
16 int cmd__submodule_config(int argc
, const char **argv
)
18 const char **arg
= argv
;
24 while (arg
[0] && starts_with(arg
[0], "--")) {
25 if (!strcmp(arg
[0], "--name"))
32 die_usage(argc
, argv
, "Wrong number of arguments.");
34 setup_git_directory();
37 struct object_id commit_oid
;
38 const struct submodule
*submodule
;
40 const char *path_or_name
;
43 path_or_name
= arg
[1];
45 if (commit
[0] == '\0')
47 else if (repo_get_oid(the_repository
, commit
, &commit_oid
) < 0)
48 die_usage(argc
, argv
, "Commit not found.");
51 submodule
= submodule_from_name(the_repository
,
52 &commit_oid
, path_or_name
);
54 submodule
= submodule_from_path(the_repository
,
55 &commit_oid
, path_or_name
);
57 die_usage(argc
, argv
, "Submodule not found.");
59 printf("Submodule name: '%s' for path '%s'\n", submodule
->name
,
65 submodule_free(the_repository
);