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

Function handle_config

remote.c:431–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

429#endif /* WITH_BREAKING_CHANGES */
430
431static int handle_config(const char *key, const char *value,
432 const struct config_context *ctx, void *cb)
433{
434 const char *name;
435 size_t namelen;
436 const char *subkey;
437 struct remote *remote;
438 struct branch *branch;
439 struct remote_state *remote_state = cb;
440 const struct key_value_info *kvi = ctx->kvi;
441
442 if (parse_config_key(key, "branch", &name, &namelen, &subkey) >= 0) {
443 /* There is no subsection. */
444 if (!name)
445 return 0;
446 /* There is a subsection, but it is empty. */
447 if (!namelen)
448 return -1;
449 branch = make_branch(remote_state, name, namelen);
450 if (!strcmp(subkey, "remote")) {
451 FREE_AND_NULL(branch->remote_name);
452 return git_config_string(&branch->remote_name, key, value);
453 } else if (!strcmp(subkey, "pushremote")) {
454 FREE_AND_NULL(branch->pushremote_name);
455 return git_config_string(&branch->pushremote_name, key, value);
456 } else if (!strcmp(subkey, "merge")) {
457 if (!value)
458 return config_error_nonbool(key);
459 add_merge(branch, value);
460 }
461 return 0;
462 }
463 if (parse_config_key(key, "url", &name, &namelen, &subkey) >= 0) {
464 struct rewrite *rewrite;
465 if (!name)
466 return 0;
467 if (!strcmp(subkey, "insteadof")) {
468 if (!value)
469 return config_error_nonbool(key);
470 rewrite = make_rewrite(&remote_state->rewrites, name,
471 namelen);
472 add_instead_of(rewrite, xstrdup(value));
473 } else if (!strcmp(subkey, "pushinsteadof")) {
474 if (!value)
475 return config_error_nonbool(key);
476 rewrite = make_rewrite(&remote_state->rewrites_push,
477 name, namelen);
478 add_instead_of(rewrite, xstrdup(value));
479 }
480 }
481
482 if (parse_config_key(key, "remote", &name, &namelen, &subkey) < 0)
483 return 0;
484
485 /* Handle remote.* variables */
486 if (!name && !strcmp(subkey, "pushdefault")) {
487 FREE_AND_NULL(remote_state->pushremote_name);
488 return git_config_string(&remote_state->pushremote_name, key,

Callers

nothing calls this directly

Calls 15

parse_config_keyFunction · 0.85
make_branchFunction · 0.85
git_config_stringFunction · 0.85
config_error_nonboolFunction · 0.85
add_mergeFunction · 0.85
make_rewriteFunction · 0.85
add_instead_ofFunction · 0.85
xstrdupFunction · 0.85
warningFunction · 0.85
make_remoteFunction · 0.85
git_config_boolFunction · 0.85
add_urlFunction · 0.85

Tested by

no test coverage detected