MCPcopy Create free account
hub / github.com/git/git / module_get_default_remote

Function module_get_default_remote

builtin/submodule--helper.c:117–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117static 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. */
155static char *get_submodule_displaypath(const char *path, const char *prefix,

Callers

nothing calls this directly

Calls 5

parse_optionsFunction · 0.85
usage_with_optionsFunction · 0.85
is_absolute_pathFunction · 0.85
xstrfmtFunction · 0.85

Tested by

no test coverage detected