git-2.22.0/tmp-objdir.c
/*
 * These env_* functions are for setting up the child environment; the
 * "replace" variant overrides the value of any existing variable with that
 * "key". The "append" variant puts our new value at the end of a list,
 * separated by PATH_SEP (which is what separate values in
 * GIT_ALTERNATE_OBJECT_DIRECTORIES).
 */
These env_* functions are for setting up the child environment; the
"replace" variant overrides the value of any existing variable with that
"key". The "append" variant puts our new value at the end of a list,
separated by PATH_SEP (which is what separate values in
GIT_ALTERNATE_OBJECT_DIRECTORIES).
These env_ * functions are for setting up the child environment ; the " replace " variant overrides the value of any existing variable with that " key " . The " append " variant puts our new value at the end of a list separated by PATH_SEP ( which is what separate values in GIT_ALTERNATE_OBJECT_DIRECTORIES ) .
static void env_append(struct argv_array *env, const char *key, const char *val)
{
	struct strbuf quoted = STRBUF_INIT;
	const char *old;
	if (*val == '"' || strchr(val, PATH_SEP)) {
		strbuf_addch(&quoted, '"');
		quote_c_style(val, &quoted, NULL, 1);
		strbuf_addch(&quoted, '"');
		val = quoted.buf;
	}
	old = getenv(key);
	if (!old)
		argv_array_pushf(env, "%s=%s", key, val);
	else
		argv_array_pushf(env, "%s=%s%c%s", key, old, PATH_SEP, val);
	strbuf_release(&quoted);
}
static void env_append ( struct argv_array * env , const char * key , const char * val ) { struct strbuf quoted = STRBUF_INIT ; const char * old ; if ( * val == ' ' || strchr ( val , PATH_SEP ) ) { strbuf_addch ( & quoted , ' ' ) ; quote_c_style ( val , & quoted , NULL , 1 ) ; strbuf_addch ( & quoted , ' ' ) ; val = quoted . buf ; } old = getenv ( key ) ; if ( ! old ) argv_array_pushf ( env , " " , key , val ) ; else argv_array_pushf ( env , " " , key , old , PATH_SEP , val ) ; strbuf_release ( & quoted ) ; }
These env_* functions are for setting up the child environment; the
 "replace" variant overrides the value of any existing variable with that
 "key".
These env_ * functions are for setting up the child environment ; the " replace " variant overrides the value of any existing variable with that " key " .
/*
	 * Avoid quoting if it's not necessary, for maximum compatibility
	 * with older parsers which don't understand the quoting.
	 */