MCPcopy Index your code
hub / github.com/git/git / handle_options

Function handle_options

git.c:157–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157static int handle_options(const char ***argv, int *argc, int *envchanged)
158{
159 const char **orig_argv = *argv;
160
161 while (*argc > 0) {
162 const char *cmd = (*argv)[0];
163 if (cmd[0] != '-')
164 break;
165
166 /*
167 * For legacy reasons, the "version" and "help"
168 * commands can be written with "--" prepended
169 * to make them look like flags.
170 */
171 if (!strcmp(cmd, "--help") || !strcmp(cmd, "-h") ||
172 !strcmp(cmd, "--version") || !strcmp(cmd, "-v"))
173 break;
174
175 /*
176 * Check remaining flags.
177 */
178 if (skip_prefix(cmd, "--exec-path", &cmd)) {
179 if (*cmd == '=')
180 git_set_exec_path(cmd + 1);
181 else {
182 puts(git_exec_path());
183 trace2_cmd_name("_query_");
184 exit(0);
185 }
186 } else if (!strcmp(cmd, "--html-path")) {
187 print_system_path(GIT_HTML_PATH);
188 trace2_cmd_name("_query_");
189 exit(0);
190 } else if (!strcmp(cmd, "--man-path")) {
191 print_system_path(GIT_MAN_PATH);
192 trace2_cmd_name("_query_");
193 exit(0);
194 } else if (!strcmp(cmd, "--info-path")) {
195 print_system_path(GIT_INFO_PATH);
196 trace2_cmd_name("_query_");
197 exit(0);
198 } else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
199 use_pager = 1;
200 } else if (!strcmp(cmd, "-P") || !strcmp(cmd, "--no-pager")) {
201 use_pager = 0;
202 if (envchanged)
203 *envchanged = 1;
204 } else if (!strcmp(cmd, "--no-lazy-fetch")) {
205 fetch_if_missing = 0;
206 setenv(NO_LAZY_FETCH_ENVIRONMENT, "1", 1);
207 if (envchanged)
208 *envchanged = 1;
209 } else if (!strcmp(cmd, "--no-replace-objects")) {
210 disable_replace_refs();
211 setenv(NO_REPLACE_OBJECTS_ENVIRONMENT, "1", 1);
212 if (envchanged)
213 *envchanged = 1;
214 } else if (!strcmp(cmd, "--git-dir")) {

Callers 2

handle_aliasFunction · 0.85
cmd_mainFunction · 0.85

Calls 15

git_set_exec_pathFunction · 0.85
git_exec_pathFunction · 0.85
print_system_pathFunction · 0.85
disable_replace_refsFunction · 0.85
xgetcwdFunction · 0.85
git_config_push_envFunction · 0.85
chdirFunction · 0.85
die_errnoFunction · 0.85
list_builtinsFunction · 0.85
string_list_clearFunction · 0.85

Tested by

no test coverage detected