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 int cmd_main(int argc, const char **argv)
15 const char **arg = argv;
22 while (arg[0] && starts_with(arg[0], "--")) {
23 if (!strcmp(arg[0], "--url"))
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 (get_oid(commit, &commit_oid) < 0)
48 die_usage(argc, argv, "Commit not found.");
51 submodule = submodule_from_name(&commit_oid, path_or_name);
53 submodule = submodule_from_path(&commit_oid, path_or_name);
55 die_usage(argc, argv, "Submodule not found.");
58 printf("Submodule url: '%s' for path '%s'\n",
59 submodule->url, submodule->path);
61 printf("Submodule name: '%s' for path '%s'\n",
62 submodule->name, submodule->path);