diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2016-04-13 20:22:42 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-15 10:12:19 -0700 |
commit | e6e7530d10b74d763b4311ea93e0a831b810d6c2 (patch) | |
tree | 7ac83d3fecd39d6076f24eaddd6719a24c3b6ce8 /test-submodule-config.c | |
parent | 7897d84b8240720352e23030c35db461581b68e3 (diff) | |
download | git-e6e7530d10b74d763b4311ea93e0a831b810d6c2.tar.gz |
test helpers: move test-* to t/helper/ subdirectory
This keeps top dir a bit less crowded. And because these programs are
for testing purposes, it makes sense that they stay somewhere in t/
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'test-submodule-config.c')
-rw-r--r-- | test-submodule-config.c | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/test-submodule-config.c b/test-submodule-config.c deleted file mode 100644 index dab8c27768..0000000000 --- a/test-submodule-config.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "cache.h" -#include "submodule-config.h" -#include "submodule.h" - -static void die_usage(int argc, char **argv, const char *msg) -{ - fprintf(stderr, "%s\n", msg); - fprintf(stderr, "Usage: %s [<commit> <submodulepath>] ...\n", argv[0]); - exit(1); -} - -static int git_test_config(const char *var, const char *value, void *cb) -{ - return parse_submodule_config_option(var, value); -} - -int main(int argc, char **argv) -{ - char **arg = argv; - int my_argc = argc; - int output_url = 0; - int lookup_name = 0; - - arg++; - my_argc--; - while (starts_with(arg[0], "--")) { - if (!strcmp(arg[0], "--url")) - output_url = 1; - if (!strcmp(arg[0], "--name")) - lookup_name = 1; - arg++; - my_argc--; - } - - if (my_argc % 2 != 0) - die_usage(argc, argv, "Wrong number of arguments."); - - setup_git_directory(); - gitmodules_config(); - git_config(git_test_config, NULL); - - while (*arg) { - unsigned char commit_sha1[20]; - const struct submodule *submodule; - const char *commit; - const char *path_or_name; - - commit = arg[0]; - path_or_name = arg[1]; - - if (commit[0] == '\0') - hashcpy(commit_sha1, null_sha1); - else if (get_sha1(commit, commit_sha1) < 0) - die_usage(argc, argv, "Commit not found."); - - if (lookup_name) { - submodule = submodule_from_name(commit_sha1, path_or_name); - } else - submodule = submodule_from_path(commit_sha1, path_or_name); - if (!submodule) - die_usage(argc, argv, "Submodule not found."); - - if (output_url) - printf("Submodule url: '%s' for path '%s'\n", - submodule->url, submodule->path); - else - printf("Submodule name: '%s' for path '%s'\n", - submodule->name, submodule->path); - - arg += 2; - } - - submodule_free(); - - return 0; -} |