3 #include "submodule-config.h"
6 static void die_usage(int argc, const char **argv, const char *msg)
8 fprintf(stderr, "%s\n", msg);
9 fprintf(stderr, "Usage: %s [<commit> <submodulepath>] ...\n", argv[0]);
13 static int git_test_config(const char *var, const char *value, void *cb)
15 return parse_submodule_config_option(var, value);
18 int cmd_main(int argc, const char **argv)
20 const char **arg = argv;
27 while (arg[0] && starts_with(arg[0], "--")) {
28 if (!strcmp(arg[0], "--url"))
30 if (!strcmp(arg[0], "--name"))
37 die_usage(argc, argv, "Wrong number of arguments.");
39 setup_git_directory();
41 git_config(git_test_config, NULL);
44 struct object_id commit_oid;
45 const struct submodule *submodule;
47 const char *path_or_name;
50 path_or_name = arg[1];
52 if (commit[0] == '\0')
54 else if (get_oid(commit, &commit_oid) < 0)
55 die_usage(argc, argv, "Commit not found.");
58 submodule = submodule_from_name(&commit_oid, path_or_name);
60 submodule = submodule_from_path(&commit_oid, path_or_name);
62 die_usage(argc, argv, "Submodule not found.");
65 printf("Submodule url: '%s' for path '%s'\n",
66 submodule->url, submodule->path);
68 printf("Submodule name: '%s' for path '%s'\n",
69 submodule->name, submodule->path);