| 115 | } |
| 116 | |
| 117 | static int module_get_default_remote(int argc, const char **argv, const char *prefix, |
| 118 | struct repository *repo UNUSED) |
| 119 | { |
| 120 | const char *path; |
| 121 | char *resolved_path = NULL; |
| 122 | char *default_remote = NULL; |
| 123 | int code; |
| 124 | struct option options[] = { |
| 125 | OPT_END() |
| 126 | }; |
| 127 | const char *const usage[] = { |
| 128 | N_("git submodule--helper get-default-remote <path>"), |
| 129 | NULL |
| 130 | }; |
| 131 | |
| 132 | argc = parse_options(argc, argv, prefix, options, usage, 0); |
| 133 | if (argc != 1) |
| 134 | usage_with_options(usage, options); |
| 135 | |
| 136 | path = argv[0]; |
| 137 | if (prefix && *prefix && !is_absolute_path(path)) { |
| 138 | resolved_path = xstrfmt("%s%s", prefix, path); |
| 139 | path = resolved_path; |
| 140 | } |
| 141 | |
| 142 | code = get_default_remote_submodule(path, &default_remote); |
| 143 | if (code) { |
| 144 | free(resolved_path); |
| 145 | return code; |
| 146 | } |
| 147 | |
| 148 | printf("%s\n", default_remote); |
| 149 | free(default_remote); |
| 150 | free(resolved_path); |
| 151 | return 0; |
| 152 | } |
| 153 | |
| 154 | /* the result should be freed by the caller. */ |
| 155 | static char *get_submodule_displaypath(const char *path, const char *prefix, |
nothing calls this directly
no test coverage detected