return 1;
if (!*value)
return 0;
- if (!strcasecmp(value, "true"))
+ if (!strcasecmp(value, "true") || !strcasecmp(value, "yes"))
return 1;
- if (!strcasecmp(value, "false"))
+ if (!strcasecmp(value, "false") || !strcasecmp(value, "no"))
return 0;
return git_config_int(name, value) != 0;
}
return 0;
}
+ if (!strcmp(var, "core.legacyheaders")) {
+ use_legacy_headers = git_config_bool(var, value);
+ return 0;
+ }
+
+ if (!strcmp(var, "core.compression")) {
+ int level = git_config_int(var, value);
+ if (level == -1)
+ level = Z_DEFAULT_COMPRESSION;
+ else if (level < 0 || level > Z_BEST_COMPRESSION)
+ die("bad zlib compression level %d", level);
+ zlib_compression_level = level;
+ return 0;
+ }
+
if (!strcmp(var, "user.name")) {
- safe_strncpy(git_default_name, value, sizeof(git_default_name));
+ strlcpy(git_default_name, value, sizeof(git_default_name));
return 0;
}
if (!strcmp(var, "user.email")) {
- safe_strncpy(git_default_email, value, sizeof(git_default_email));
+ strlcpy(git_default_email, value, sizeof(git_default_email));
return 0;
}
if (!strcmp(var, "i18n.commitencoding")) {
- safe_strncpy(git_commit_encoding, value, sizeof(git_commit_encoding));
+ strlcpy(git_commit_encoding, value, sizeof(git_commit_encoding));
+ return 0;
+ }
+
+ if (!strcmp(var, "pager.color")) {
+ pager_use_color = git_config_bool(var,value);
return 0;
}
int git_config(config_fn_t fn)
{
- const char *filename = git_path("config");
- /* Forward-compatibility cue: $GIT_CONFIG makes git read _only_
- * the given config file, $GIT_CONFIG_LOCAL will make it process
- * it in addition to the global config file, the same way it would
- * the per-repository config file otherwise. */
- if (getenv("GIT_CONFIG")) {
- filename = getenv("GIT_CONFIG");
- } else if (getenv("GIT_CONFIG_LOCAL")) {
+ int ret = 0;
+ char *repo_config = NULL;
+ const char *home = NULL, *filename;
+
+ /* $GIT_CONFIG makes git read _only_ the given config file,
+ * $GIT_CONFIG_LOCAL will make it process it in addition to the
+ * global config file, the same way it would the per-repository
+ * config file otherwise. */
+ filename = getenv("GIT_CONFIG");
+ if (!filename) {
+ home = getenv("HOME");
filename = getenv("GIT_CONFIG_LOCAL");
+ if (!filename)
+ filename = repo_config = strdup(git_path("config"));
+ }
+
+ if (home) {
+ char *user_config = strdup(mkpath("%s/.gitconfig", home));
+ if (!access(user_config, R_OK))
+ ret = git_config_from_file(fn, user_config);
+ free(user_config);
}
- return git_config_from_file(fn, filename);
+
+ ret += git_config_from_file(fn, filename);
+ if (repo_config)
+ free(repo_config);
+ return ret;
}
/*