]>
git.ipfire.org Git - thirdparty/git.git/blob - t/helper/test-submodule-config.c
4 #include "submodule-config.h"
7 static void die_usage(int argc
, const char **argv
, const char *msg
)
9 fprintf(stderr
, "%s\n", msg
);
10 fprintf(stderr
, "Usage: %s [<commit> <submodulepath>] ...\n", argv
[0]);
14 int cmd__submodule_config(int argc
, const char **argv
)
16 const char **arg
= argv
;
22 while (arg
[0] && starts_with(arg
[0], "--")) {
23 if (!strcmp(arg
[0], "--name"))
30 die_usage(argc
, argv
, "Wrong number of arguments.");
32 setup_git_directory();
35 struct object_id commit_oid
;
36 const struct submodule
*submodule
;
38 const char *path_or_name
;
41 path_or_name
= arg
[1];
43 if (commit
[0] == '\0')
45 else if (get_oid(commit
, &commit_oid
) < 0)
46 die_usage(argc
, argv
, "Commit not found.");
49 submodule
= submodule_from_name(the_repository
,
50 &commit_oid
, path_or_name
);
52 submodule
= submodule_from_path(the_repository
,
53 &commit_oid
, path_or_name
);
55 die_usage(argc
, argv
, "Submodule not found.");
57 printf("Submodule name: '%s' for path '%s'\n", submodule
->name
,
63 submodule_free(the_repository
);