2 #include "submodule-config.h"
5 static void die_usage(int argc
, char **argv
, const char *msg
)
7 fprintf(stderr
, "%s\n", msg
);
8 fprintf(stderr
, "Usage: %s [<commit> <submodulepath>] ...\n", argv
[0]);
12 static int git_test_config(const char *var
, const char *value
, void *cb
)
14 return parse_submodule_config_option(var
, value
);
17 int main(int argc
, char **argv
)
25 while (starts_with(arg
[0], "--")) {
26 if (!strcmp(arg
[0], "--url"))
33 die_usage(argc
, argv
, "Wrong number of arguments.");
35 setup_git_directory();
37 git_config(git_test_config
, NULL
);
40 unsigned char commit_sha1
[20];
41 const struct submodule
*submodule
;
48 if (commit
[0] == '\0')
49 hashcpy(commit_sha1
, null_sha1
);
50 else if (get_sha1(commit
, commit_sha1
) < 0)
51 die_usage(argc
, argv
, "Commit not found.");
53 submodule
= submodule_from_path(commit_sha1
, path
);
55 die_usage(argc
, argv
, "Submodule not found.");
58 printf("Submodule url: '%s' for path '%s'\n",
59 submodule
->url
, path
);
61 printf("Submodule name: '%s' for path '%s'\n",
62 submodule
->name
, path
);