/*
* GIT - The information manager from hell
*
* Copyright (C) Linus Torvalds, 2005
* Copyright (C) Johannes Schindelin, 2005
*
*/
#include "cache.h"
#include "exec_cmd.h"
#include "strbuf.h"
#include "quote.h"
#define MAXNAME (256)
static FILE *config_file;
static const char *config_file_name;
static int config_linenr;
static int config_file_eof;
static int zlib_compression_seen;
const char *config_exclusive_filename = NULL;
struct config_item
{
struct config_item *next;
char *name;
char *value;
};
static struct config_item *config_parameters;
static struct config_item **config_parameters_tail = &config_parameters;
static void lowercase(char *p)
{
for (; *p; p++)
*p = tolower(*p);
}
void git_config_push_parameter(const char *text)
{
struct strbuf env = STRBUF_INIT;
const char *old = getenv(CONFIG_DATA_ENVIRONMENT);
if (old) {
strbuf_addstr(&env, old);
strbuf_addch(&env, ' ');
}
sq_quote_buf(&env, text);
setenv(CONFIG_DATA_ENVIRONMENT, env.buf, 1);
strbuf_release(&env);
}
int git_config_parse_parameter(const char *text)
{
struct config_item *ct;
struct strbuf tmp = STRBUF_INIT;
struct strbuf **pair;
strbuf_addstr(&tmp, text);
pair = strbuf_split(&tmp, '=');
if (pair[0]->len && pair[0]->buf[pair[0]->len - 1] == '=')
strbuf_setlen(pair[0], pair[0]->len - 1);
strbuf_trim(pair[0]);
if (!pair[0]->len) {
strbuf_list_free(pair);
return -1;
}
ct = xcalloc(1, sizeof(struct config_item));
ct->name = strbuf_detach(pair[0], NULL);
if (pair[1]) {
strbuf_trim(pair[1]);
ct->value = strbuf_detach(pair[1], NULL);
}
strbuf_list_free(pair);
lowercase(ct->name);
*config_parameters_tail = ct;
config_parameters_tail = &ct->next;
return 0;
}
int git_config_parse_environment(void) {
const char *env = getenv(CONFIG_DATA_ENVIRONMENT);
char *envw;
const char **argv = NULL;
int nr = 0, alloc = 0;
|