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

Function git_config_from_parameters

config.c:731–797  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

729}
730
731int git_config_from_parameters(config_fn_t fn, void *data)
732{
733 const char *env;
734 struct strbuf envvar = STRBUF_INIT;
735 struct strvec to_free = STRVEC_INIT;
736 int ret = 0;
737 char *envw = NULL;
738 struct key_value_info kvi = KVI_INIT;
739
740 kvi_from_param(&kvi);
741 env = getenv(CONFIG_COUNT_ENVIRONMENT);
742 if (env) {
743 unsigned long count;
744 char *endp;
745
746 count = strtoul(env, &endp, 10);
747 if (*endp) {
748 ret = error(_("bogus count in %s"), CONFIG_COUNT_ENVIRONMENT);
749 goto out;
750 }
751 if (count > INT_MAX) {
752 ret = error(_("too many entries in %s"), CONFIG_COUNT_ENVIRONMENT);
753 goto out;
754 }
755
756 for (unsigned long i = 0; i < count; i++) {
757 const char *key, *value;
758
759 strbuf_addf(&envvar, "GIT_CONFIG_KEY_%lu", i);
760 key = getenv_safe(&to_free, envvar.buf);
761 if (!key) {
762 ret = error(_("missing config key %s"), envvar.buf);
763 goto out;
764 }
765 strbuf_reset(&envvar);
766
767 strbuf_addf(&envvar, "GIT_CONFIG_VALUE_%lu", i);
768 value = getenv_safe(&to_free, envvar.buf);
769 if (!value) {
770 ret = error(_("missing config value %s"), envvar.buf);
771 goto out;
772 }
773 strbuf_reset(&envvar);
774
775 if (config_parse_pair(key, value, &kvi, fn, data) < 0) {
776 ret = -1;
777 goto out;
778 }
779 }
780 }
781
782 env = getenv(CONFIG_DATA_ENVIRONMENT);
783 if (env) {
784 /* sq_dequote will write over it */
785 envw = xstrdup(env);
786 if (parse_config_env_list(envw, &kvi, fn, data) < 0) {
787 ret = -1;
788 goto out;

Callers 1

do_git_config_sequenceFunction · 0.85

Calls 9

kvi_from_paramFunction · 0.85
errorFunction · 0.85
strbuf_addfFunction · 0.85
getenv_safeFunction · 0.85
config_parse_pairFunction · 0.85
xstrdupFunction · 0.85
parse_config_env_listFunction · 0.85
strbuf_releaseFunction · 0.85
strvec_clearFunction · 0.85

Tested by

no test coverage detected