static int git_status_config(const char *k, const char *v, void *cb) { struct wt_status *s = cb; if (!strcmp(k, "status.submodulesummary")) { int is_bool; s->submodule_summary = git_config_bool_or_int(k, v, &is_bool); if (is_bool && s->submodule_summary) s->submodule_summary = -1; return 0; } if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) { s->use_color = git_config_colorbool(k, v, -1); return 0; } if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) { int slot = parse_status_slot(k, 13); if (slot < 0) return 0; if (!v) return config_error_nonbool(k); color_parse(v, k, s->color_palette[slot]); return 0; } if (!strcmp(k, "status.relativepaths")) { s->relative_paths = git_config_bool(k, v); return 0; } if (!strcmp(k, "status.showuntrackedfiles")) { if (!v) return config_error_nonbool(k); else if (!strcmp(v, "no")) s->show_untracked_files = SHOW_NO_UNTRACKED_FILES; else if (!strcmp(v, "normal")) s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES; else if (!strcmp(v, "all")) s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES; else return error(_("Invalid untracked files mode '%s'"), v); return 0; } return git_diff_ui_config(k, v, NULL); }
/* * Read the configuration file once and store it in * the grep_defaults template. */ int grep_config(const char *var, const char *value, void *cb) { struct grep_opt *opt = &grep_defaults; char *color = NULL; if (userdiff_config(var, value) < 0) return -1; if (!strcmp(var, "grep.extendedregexp")) { if (git_config_bool(var, value)) opt->extended_regexp_option = 1; else opt->extended_regexp_option = 0; return 0; } if (!strcmp(var, "grep.patterntype")) { opt->pattern_type_option = parse_pattern_type_arg(var, value); return 0; } if (!strcmp(var, "grep.linenumber")) { opt->linenum = git_config_bool(var, value); return 0; } if (!strcmp(var, "grep.fullname")) { opt->relative = !git_config_bool(var, value); return 0; } if (!strcmp(var, "color.grep")) opt->color = git_config_colorbool(var, value); else if (!strcmp(var, "color.grep.context")) color = opt->color_context; else if (!strcmp(var, "color.grep.filename")) color = opt->color_filename; else if (!strcmp(var, "color.grep.function")) color = opt->color_function; else if (!strcmp(var, "color.grep.linenumber")) color = opt->color_lineno; else if (!strcmp(var, "color.grep.match")) color = opt->color_match; else if (!strcmp(var, "color.grep.selected")) color = opt->color_selected; else if (!strcmp(var, "color.grep.separator")) color = opt->color_sep; if (color) { if (!value) return config_error_nonbool(var); return color_parse(value, color); } return 0; }
static int git_format_config(const char *var, const char *value, void *cb) { if (!strcmp(var, "format.headers")) { if (!value) die("format.headers without value"); add_header(value); return 0; } if (!strcmp(var, "format.suffix")) return git_config_string(&fmt_patch_suffix, var, value); if (!strcmp(var, "format.cc")) { if (!value) return config_error_nonbool(var); ALLOC_GROW(extra_cc, extra_cc_nr + 1, extra_cc_alloc); extra_cc[extra_cc_nr++] = xstrdup(value); return 0; } if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) { return 0; } if (!strcmp(var, "format.numbered")) { if (value && !strcasecmp(value, "auto")) { auto_number = 1; return 0; } numbered = git_config_bool(var, value); auto_number = auto_number && numbered; return 0; } if (!strcmp(var, "format.attach")) { if (value && *value) default_attach = xstrdup(value); else default_attach = xstrdup(git_version_string); return 0; } if (!strcmp(var, "format.thread")) { if (value && !strcasecmp(value, "deep")) { thread = THREAD_DEEP; return 0; } if (value && !strcasecmp(value, "shallow")) { thread = THREAD_SHALLOW; return 0; } thread = git_config_bool(var, value) && THREAD_SHALLOW; return 0; } if (!strcmp(var, "format.signoff")) { do_signoff = git_config_bool(var, value); return 0; } return git_log_config(var, value, cb); }
static int git_gidit_config(const char *var, const char *value, void *cb) { if (!strcmp(var, "user.signingkey")) { if (!value) return config_error_nonbool(var); set_signingkey(value); return 0; } return git_default_config(var, value, cb); }
int git_commit_config(const char *k, const char *v) { if (!strcmp(k, "commit.template")) { if (!v) return config_error_nonbool(v); template_file = xstrdup(v); return 0; } return git_status_config(k, v); }
static int alias_lookup_cb(const char *k, const char *v, void *cb) { const char *name; if (skip_prefix(k, "alias.", &name) && !strcmp(name, alias_key)) { if (!v) return config_error_nonbool(k); alias_val = xstrdup(v); return 0; } return 0; }
static int git_default_user_config(const char *var, const char *value) { if (!strcmp(var, "user.name")) { if (!value) return config_error_nonbool(var); strlcpy(git_default_name, value, sizeof(git_default_name)); user_ident_explicitly_given |= IDENT_NAME_GIVEN; return 0; } if (!strcmp(var, "user.email")) { if (!value) return config_error_nonbool(var); strlcpy(git_default_email, value, sizeof(git_default_email)); user_ident_explicitly_given |= IDENT_MAIL_GIVEN; return 0; } /* Add other config variables here and to Documentation/config.txt. */ return 0; }
static int notes_display_config(const char *k, const char *v, void *cb) { int *load_refs = cb; if (*load_refs && !strcmp(k, "notes.displayref")) { if (!v) config_error_nonbool(k); string_list_add_refs_by_glob(&display_notes_refs, v); } return 0; }
int git_gpg_config(const char *var, const char *value, void *cb) { if (!strcmp(var, "user.signingkey")) { set_signing_key(value); } if (!strcmp(var, "gpg.program")) { if (!value) return config_error_nonbool(var); gpg_program = xstrdup(value); } return 0; }
static int git_push_config(const char *k, const char *v, void *cb) { int *flags = cb; int status; status = git_gpg_config(k, v, NULL); if (status) return status; if (!strcmp(k, "push.followtags")) { if (git_config_bool(k, v)) *flags |= TRANSPORT_PUSH_FOLLOW_TAGS; else *flags &= ~TRANSPORT_PUSH_FOLLOW_TAGS; return 0; } else if (!strcmp(k, "push.gpgsign")) { const char *value; if (!git_config_get_value("push.gpgsign", &value)) { switch (git_parse_maybe_bool(value)) { case 0: set_push_cert_flags(flags, SEND_PACK_PUSH_CERT_NEVER); break; case 1: set_push_cert_flags(flags, SEND_PACK_PUSH_CERT_ALWAYS); break; default: if (value && !strcasecmp(value, "if-asked")) set_push_cert_flags(flags, SEND_PACK_PUSH_CERT_IF_ASKED); else return error("Invalid value for '%s'", k); } } } else if (!strcmp(k, "push.recursesubmodules")) { const char *value; if (!git_config_get_value("push.recursesubmodules", &value)) recurse_submodules = parse_push_recurse_submodules_arg(k, value); } else if (!strcmp(k, "submodule.recurse")) { int val = git_config_bool(k, v) ? RECURSE_SUBMODULES_ON_DEMAND : RECURSE_SUBMODULES_OFF; recurse_submodules = val; } else if (!strcmp(k, "push.pushoption")) { if (!v) return config_error_nonbool(k); else if (!*v) string_list_clear(&push_options_config, 0); else string_list_append(&push_options_config, v); return 0; } return git_default_config(k, v, NULL); }
static int grep_config(const char *var, const char *value, void *cb) { struct grep_opt *opt = cb; char *color = NULL; switch (userdiff_config(var, value)) { case 0: break; case -1: return -1; default: return 0; } if (!strcmp(var, "grep.extendedregexp")) { if (git_config_bool(var, value)) opt->regflags |= REG_EXTENDED; else opt->regflags &= ~REG_EXTENDED; return 0; } if (!strcmp(var, "grep.linenumber")) { opt->linenum = git_config_bool(var, value); return 0; } if (!strcmp(var, "color.grep")) opt->color = git_config_colorbool(var, value, -1); else if (!strcmp(var, "color.grep.context")) color = opt->color_context; else if (!strcmp(var, "color.grep.filename")) color = opt->color_filename; else if (!strcmp(var, "color.grep.function")) color = opt->color_function; else if (!strcmp(var, "color.grep.linenumber")) color = opt->color_lineno; else if (!strcmp(var, "color.grep.match")) color = opt->color_match; else if (!strcmp(var, "color.grep.selected")) color = opt->color_selected; else if (!strcmp(var, "color.grep.separator")) color = opt->color_sep; else return git_color_default_config(var, value, cb); if (color) { if (!value) return config_error_nonbool(var); color_parse(value, var, color); } return 0; }
static int git_proxy_command_options(const char *var, const char *value, void *cb) { if (!strcmp(var, "core.gitproxy")) { const char *for_pos; int matchlen = -1; int hostlen; const char *rhost_name = cb; int rhost_len = strlen(rhost_name); if (git_proxy_command) return 0; if (!value) return config_error_nonbool(var); /* [core] * ;# matches www.kernel.org as well * gitproxy = netcatter-1 for kernel.org * gitproxy = netcatter-2 for sample.xz * gitproxy = netcatter-default */ for_pos = strstr(value, " for "); if (!for_pos) /* matches everybody */ matchlen = strlen(value); else { hostlen = strlen(for_pos + 5); if (rhost_len < hostlen) matchlen = -1; else if (!strncmp(for_pos + 5, rhost_name + rhost_len - hostlen, hostlen) && ((rhost_len == hostlen) || rhost_name[rhost_len - hostlen -1] == '.')) matchlen = for_pos - value; else matchlen = -1; } if (0 <= matchlen) { /* core.gitproxy = none for kernel.org */ if (matchlen == 4 && !memcmp(value, "none", 4)) matchlen = 0; git_proxy_command = xmemdupz(value, matchlen); } return 0; } return git_default_config(var, value, cb); }
static int git_branch_config(const char *var, const char *value, void *cb) { if (!strcmp(var, "color.branch")) { branch_use_color = git_config_colorbool(var, value, -1); return 0; } if (!prefixcmp(var, "color.branch.")) { int slot = parse_branch_color_slot(var, 13); if (!value) return config_error_nonbool(var); color_parse(value, var, branch_colors[slot]); return 0; } return git_color_default_config(var, value, cb); }
static int git_log_config(const char *var, const char *value, void *cb) { if (!strcmp(var, "format.pretty")) return git_config_string(&fmt_pretty, var, value); if (!strcmp(var, "format.subjectprefix")) { if (!value) config_error_nonbool(var); fmt_patch_subject_prefix = xstrdup(value); return 0; } if (!strcmp(var, "log.showroot")) { default_show_root = git_config_bool(var, value); return 0; } return git_diff_ui_config(var, value, cb); }
static int git_show_branch_config(const char *var, const char *value) { if (!strcmp(var, "showbranch.default")) { if (!value) return config_error_nonbool(var); if (default_alloc <= default_num + 1) { default_alloc = default_alloc * 3 / 2 + 20; default_arg = xrealloc(default_arg, sizeof *default_arg * default_alloc); } default_arg[default_num++] = xstrdup(value); default_arg[default_num] = NULL; return 0; } return git_default_config(var, value); }
static int tar_filter_config(const char *var, const char *value, void *data) { struct archiver *ar; const char *dot; const char *name; const char *type; int namelen; if (prefixcmp(var, "tar.")) return 0; dot = strrchr(var, '.'); if (dot == var + 9) return 0; name = var + 4; namelen = dot - name; type = dot + 1; ar = find_tar_filter(name, namelen); if (!ar) { ar = xcalloc(1, sizeof(*ar)); ar->name = xmemdupz(name, namelen); ar->write_archive = write_tar_filter_archive; ar->flags = ARCHIVER_WANT_COMPRESSION_LEVELS; ALLOC_GROW(tar_filters, nr_tar_filters + 1, alloc_tar_filters); tar_filters[nr_tar_filters++] = ar; } if (!strcmp(type, "command")) { if (!value) return config_error_nonbool(var); free(ar->data); ar->data = xstrdup(value); return 0; } if (!strcmp(type, "remote")) { if (git_config_bool(var, value)) ar->flags |= ARCHIVER_REMOTE; else ar->flags &= ~ARCHIVER_REMOTE; return 0; } return 0; }
int check_repository_format_version(const char *var, const char *value, void *cb) { int ret = check_repo_format(var, value, cb); if (ret) return ret; if (strcmp(var, "core.bare") == 0) { is_bare_repository_cfg = git_config_bool(var, value); if (is_bare_repository_cfg == 1) inside_work_tree = -1; } else if (strcmp(var, "core.worktree") == 0) { if (!value) return config_error_nonbool(var); free(git_work_tree_cfg); git_work_tree_cfg = xstrdup(value); inside_work_tree = -1; } return 0; }
static int credential_config_callback(const char *var, const char *value, void *data) { struct credential *c = data; const char *key, *dot; if (!skip_prefix(var, "credential.", &key)) return 0; if (!value) return config_error_nonbool(var); dot = strrchr(key, '.'); if (dot) { struct credential want = CREDENTIAL_INIT; char *url = xmemdupz(key, dot - key); int matched; credential_from_url(&want, url); matched = credential_match(&want, c); credential_clear(&want); free(url); if (!matched) return 0; key = dot + 1; } if (!strcmp(key, "helper")) { if (*value) string_list_append(&c->helpers, value); else string_list_clear(&c->helpers, 0); } else if (!strcmp(key, "username")) { if (!c->username) c->username = xstrdup(value); } else if (!strcmp(key, "usehttppath")) c->use_http_path = git_config_bool(var, value); return 0; }
int check_repository_format_version(const char *var, const char *value, void *cb) { if (strcmp(var, "core.repositoryformatversion") == 0) repository_format_version = git_config_int(var, value); else if (strcmp(var, "core.sharedrepository") == 0) shared_repository = git_config_perm(var, value); else if (strcmp(var, "core.bare") == 0) { is_bare_repository_cfg = git_config_bool(var, value); if (is_bare_repository_cfg == 1) inside_work_tree = -1; } else if (strcmp(var, "core.worktree") == 0) { if (!value) return config_error_nonbool(var); free(git_work_tree_cfg); git_work_tree_cfg = xstrdup(value); inside_work_tree = -1; } return 0; }
static int git_branch_config(const char *var, const char *value, void *cb) { if (starts_with(var, "column.")) return git_column_config(var, value, "branch", &colopts); if (!strcmp(var, "color.branch")) { branch_use_color = git_config_colorbool(var, value); return 0; } if (starts_with(var, "color.branch.")) { int slot = parse_branch_color_slot(var, 13); if (slot < 0) return 0; if (!value) return config_error_nonbool(var); color_parse(value, var, branch_colors[slot]); return 0; } return git_color_default_config(var, value, cb); }
static int grep_config(const char *var, const char *value, void *cb) { struct grep_opt *opt = cb; switch (userdiff_config(var, value)) { case 0: break; case -1: return -1; default: return 0; } if (!strcmp(var, "color.grep")) { opt->color = git_config_colorbool(var, value, -1); return 0; } if (!strcmp(var, "color.grep.match")) { if (!value) return config_error_nonbool(var); color_parse(value, var, opt->color_match); return 0; } return git_color_default_config(var, value, cb); }
static int git_show_branch_config(const char *var, const char *value, void *cb) { if (!strcmp(var, "showbranch.default")) { if (!value) return config_error_nonbool(var); /* * default_arg is now passed to parse_options(), so we need to * mimic the real argv a bit better. */ if (!default_args.argc) argv_array_push(&default_args, "show-branch"); argv_array_push(&default_args, value); return 0; } if (!strcmp(var, "color.showbranch")) { showbranch_use_color = git_config_colorbool(var, value); return 0; } return git_color_default_config(var, value, cb); }
int parse_hide_refs_config(const char *var, const char *value, const char *section) { const char *key; if (!strcmp("transfer.hiderefs", var) || (!parse_config_key(var, section, NULL, NULL, &key) && !strcmp(key, "hiderefs"))) { char *ref; int len; if (!value) return config_error_nonbool(var); ref = xstrdup(value); len = strlen(ref); while (len && ref[len - 1] == '/') ref[--len] = '\0'; if (!hide_refs) { hide_refs = xcalloc(1, sizeof(*hide_refs)); hide_refs->strdup_strings = 1; } string_list_append(hide_refs, ref); } return 0; }
int parse_hide_refs_config(const char *var, const char *value, const char *section) { if (!strcmp("transfer.hiderefs", var) || /* NEEDSWORK: use parse_config_key() once both are merged */ (starts_with(var, section) && var[strlen(section)] == '.' && !strcmp(var + strlen(section), ".hiderefs"))) { char *ref; int len; if (!value) return config_error_nonbool(var); ref = xstrdup(value); len = strlen(ref); while (len && ref[len - 1] == '/') ref[--len] = '\0'; if (!hide_refs) { hide_refs = xcalloc(1, sizeof(*hide_refs)); hide_refs->strdup_strings = 1; } string_list_append(hide_refs, ref); } return 0; }
static int git_tag_config(const char *var, const char *value, void *cb) { int status; struct ref_sorting **sorting_tail = (struct ref_sorting **)cb; if (!strcmp(var, "tag.sort")) { if (!value) return config_error_nonbool(var); parse_sorting_string(value, sorting_tail); return 0; } status = git_gpg_config(var, value, cb); if (status) return status; if (!strcmp(var, "tag.forcesignannotated")) { force_sign_annotate = git_config_bool(var, value); return 0; } if (starts_with(var, "column.")) return git_column_config(var, value, "tag", &colopts); return git_default_config(var, value, cb); }
static int git_default_push_config(const char *var, const char *value) { if (!strcmp(var, "push.default")) { if (!value) return config_error_nonbool(var); else if (!strcmp(value, "nothing")) push_default = PUSH_DEFAULT_NOTHING; else if (!strcmp(value, "matching")) push_default = PUSH_DEFAULT_MATCHING; else if (!strcmp(value, "tracking")) push_default = PUSH_DEFAULT_TRACKING; else if (!strcmp(value, "current")) push_default = PUSH_DEFAULT_CURRENT; else { error("Malformed value for %s: %s", var, value); return error("Must be one of nothing, matching, " "tracking or current."); } return 0; } /* Add other config variables here and to Documentation/config.txt. */ return 0; }
static int git_default_core_config(const char *var, const char *value) { /* This needs a better name */ if (!strcmp(var, "core.filemode")) { trust_executable_bit = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.trustctime")) { trust_ctime = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.quotepath")) { quote_path_fully = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.symlinks")) { has_symlinks = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.ignorecase")) { ignore_case = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.bare")) { is_bare_repository_cfg = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.ignorestat")) { assume_unchanged = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.prefersymlinkrefs")) { prefer_symlink_refs = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.logallrefupdates")) { log_all_ref_updates = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.warnambiguousrefs")) { warn_ambiguous_refs = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.loosecompression")) { 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; zlib_compression_seen = 1; 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); core_compression_level = level; core_compression_seen = 1; if (!zlib_compression_seen) zlib_compression_level = level; return 0; } if (!strcmp(var, "core.packedgitwindowsize")) { int pgsz_x2 = getpagesize() * 2; packed_git_window_size = git_config_int(var, value); /* This value must be multiple of (pagesize * 2) */ packed_git_window_size /= pgsz_x2; if (packed_git_window_size < 1) packed_git_window_size = 1; packed_git_window_size *= pgsz_x2; return 0; } if (!strcmp(var, "core.packedgitlimit")) { packed_git_limit = git_config_int(var, value); return 0; } if (!strcmp(var, "core.deltabasecachelimit")) { delta_base_cache_limit = git_config_int(var, value); return 0; } if (!strcmp(var, "core.autocrlf")) { if (value && !strcasecmp(value, "input")) { auto_crlf = -1; return 0; } auto_crlf = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.safecrlf")) { if (value && !strcasecmp(value, "warn")) { safe_crlf = SAFE_CRLF_WARN; return 0; } safe_crlf = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.pager")) return git_config_string(&pager_program, var, value); if (!strcmp(var, "core.editor")) return git_config_string(&editor_program, var, value); if (!strcmp(var, "core.excludesfile")) return git_config_string(&excludes_file, var, value); if (!strcmp(var, "core.whitespace")) { if (!value) return config_error_nonbool(var); whitespace_rule_cfg = parse_whitespace_rule(value); return 0; } if (!strcmp(var, "core.fsyncobjectfiles")) { fsync_object_files = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.preloadindex")) { core_preload_index = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.unreliablehardlinks")) { unreliable_hardlinks = git_config_bool(var, value); return 0; } /* Add other config variables here and to Documentation/config.txt. */ return 0; }
static int git_format_config(const char *var, const char *value, void *cb) { if (!strcmp(var, "format.headers")) { if (!value) die(_("format.headers without value")); add_header(value); return 0; } if (!strcmp(var, "format.suffix")) return git_config_string(&fmt_patch_suffix, var, value); if (!strcmp(var, "format.to")) { if (!value) return config_error_nonbool(var); string_list_append(&extra_to, value); return 0; } if (!strcmp(var, "format.cc")) { if (!value) return config_error_nonbool(var); string_list_append(&extra_cc, value); return 0; } if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff") || !strcmp(var, "color.ui")) { return 0; } if (!strcmp(var, "format.numbered")) { if (value && !strcasecmp(value, "auto")) { auto_number = 1; return 0; } numbered = git_config_bool(var, value); auto_number = auto_number && numbered; return 0; } if (!strcmp(var, "format.attach")) { if (value && *value) default_attach = xstrdup(value); else default_attach = xstrdup(git_version_string); return 0; } if (!strcmp(var, "format.thread")) { if (value && !strcasecmp(value, "deep")) { thread = THREAD_DEEP; return 0; } if (value && !strcasecmp(value, "shallow")) { thread = THREAD_SHALLOW; return 0; } thread = git_config_bool(var, value) && THREAD_SHALLOW; return 0; } if (!strcmp(var, "format.signoff")) { do_signoff = git_config_bool(var, value); return 0; } if (!strcmp(var, "format.signature")) return git_config_string(&signature, var, value); if (!strcmp(var, "format.signaturefile")) return git_config_pathname(&signature_file, var, value); if (!strcmp(var, "format.coverletter")) { if (value && !strcasecmp(value, "auto")) { config_cover_letter = COVER_AUTO; return 0; } config_cover_letter = git_config_bool(var, value) ? COVER_ON : COVER_OFF; return 0; } return git_log_config(var, value, cb); }
static int git_default_core_config(const char *var, const char *value) { /* This needs a better name */ if (!strcmp(var, "core.filemode")) { trust_executable_bit = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.trustctime")) { trust_ctime = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.quotepath")) { quote_path_fully = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.symlinks")) { has_symlinks = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.ignorecase")) { ignore_case = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.abbrevguard")) { unique_abbrev_extra_length = git_config_int(var, value); if (unique_abbrev_extra_length < 0) unique_abbrev_extra_length = 0; return 0; } if (!strcmp(var, "core.bare")) { is_bare_repository_cfg = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.ignorestat")) { assume_unchanged = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.prefersymlinkrefs")) { prefer_symlink_refs = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.logallrefupdates")) { log_all_ref_updates = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.warnambiguousrefs")) { warn_ambiguous_refs = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.loosecompression")) { 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; zlib_compression_seen = 1; 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); core_compression_level = level; core_compression_seen = 1; if (!zlib_compression_seen) zlib_compression_level = level; return 0; } if (!strcmp(var, "core.packedgitwindowsize")) { int pgsz_x2 = getpagesize() * 2; packed_git_window_size = git_config_int(var, value); /* This value must be multiple of (pagesize * 2) */ packed_git_window_size /= pgsz_x2; if (packed_git_window_size < 1) packed_git_window_size = 1; packed_git_window_size *= pgsz_x2; return 0; } if (!strcmp(var, "core.packedgitlimit")) { packed_git_limit = git_config_int(var, value); return 0; } if (!strcmp(var, "core.deltabasecachelimit")) { delta_base_cache_limit = git_config_int(var, value); return 0; } if (!strcmp(var, "core.autocrlf")) { if (value && !strcasecmp(value, "input")) { if (eol == EOL_CRLF) return error("core.autocrlf=input conflicts with core.eol=crlf"); auto_crlf = AUTO_CRLF_INPUT; return 0; } auto_crlf = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.safecrlf")) { if (value && !strcasecmp(value, "warn")) { safe_crlf = SAFE_CRLF_WARN; return 0; } safe_crlf = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.eol")) { if (value && !strcasecmp(value, "lf")) eol = EOL_LF; else if (value && !strcasecmp(value, "crlf")) eol = EOL_CRLF; else if (value && !strcasecmp(value, "native")) eol = EOL_NATIVE; else eol = EOL_UNSET; if (eol == EOL_CRLF && auto_crlf == AUTO_CRLF_INPUT) return error("core.autocrlf=input conflicts with core.eol=crlf"); return 0; } if (!strcmp(var, "core.notesref")) { notes_ref_name = xstrdup(value); return 0; } if (!strcmp(var, "core.pager")) return git_config_string(&pager_program, var, value); if (!strcmp(var, "core.editor")) return git_config_string(&editor_program, var, value); if (!strcmp(var, "core.askpass")) return git_config_string(&askpass_program, var, value); if (!strcmp(var, "core.excludesfile")) return git_config_pathname(&excludes_file, var, value); if (!strcmp(var, "core.whitespace")) { if (!value) return config_error_nonbool(var); whitespace_rule_cfg = parse_whitespace_rule(value); return 0; } if (!strcmp(var, "core.fsyncobjectfiles")) { fsync_object_files = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.preloadindex")) { core_preload_index = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.createobject")) { if (!strcmp(value, "rename")) object_creation_mode = OBJECT_CREATION_USES_RENAMES; else if (!strcmp(value, "link")) object_creation_mode = OBJECT_CREATION_USES_HARDLINKS; else die("Invalid mode for object creation: %s", value); return 0; } if (!strcmp(var, "core.sparsecheckout")) { core_apply_sparse_checkout = git_config_bool(var, value); return 0; } /* Add other config variables here and to Documentation/config.txt. */ return 0; }
int git_default_config(const char *var, const char *value) { /* This needs a better name */ if (!strcmp(var, "core.filemode")) { trust_executable_bit = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.quotepath")) { quote_path_fully = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.symlinks")) { has_symlinks = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.ignorecase")) { ignore_case = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.bare")) { is_bare_repository_cfg = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.ignorestat")) { assume_unchanged = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.prefersymlinkrefs")) { prefer_symlink_refs = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.logallrefupdates")) { log_all_ref_updates = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.warnambiguousrefs")) { warn_ambiguous_refs = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.loosecompression")) { 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; zlib_compression_seen = 1; 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); core_compression_level = level; core_compression_seen = 1; if (!zlib_compression_seen) zlib_compression_level = level; return 0; } if (!strcmp(var, "core.packedgitwindowsize")) { int pgsz_x2 = getpagesize() * 2; packed_git_window_size = git_config_int(var, value); /* This value must be multiple of (pagesize * 2) */ packed_git_window_size /= pgsz_x2; if (packed_git_window_size < 1) packed_git_window_size = 1; packed_git_window_size *= pgsz_x2; return 0; } if (!strcmp(var, "core.packedgitlimit")) { packed_git_limit = git_config_int(var, value); return 0; } if (!strcmp(var, "core.deltabasecachelimit")) { delta_base_cache_limit = git_config_int(var, value); return 0; } if (!strcmp(var, "core.autocrlf")) { if (value && !strcasecmp(value, "input")) { auto_crlf = -1; return 0; } auto_crlf = git_config_bool(var, value); return 0; } if (!strcmp(var, "core.safecrlf")) { if (value && !strcasecmp(value, "warn")) { safe_crlf = SAFE_CRLF_WARN; return 0; } safe_crlf = git_config_bool(var, value); return 0; } if (!strcmp(var, "user.name")) { if (!value) return config_error_nonbool(var); strlcpy(git_default_name, value, sizeof(git_default_name)); if (git_default_email[0]) user_ident_explicitly_given = 1; return 0; } if (!strcmp(var, "user.email")) { if (!value) return config_error_nonbool(var); strlcpy(git_default_email, value, sizeof(git_default_email)); if (git_default_name[0]) user_ident_explicitly_given = 1; return 0; } if (!strcmp(var, "i18n.commitencoding")) return git_config_string(&git_commit_encoding, var, value); if (!strcmp(var, "i18n.logoutputencoding")) return git_config_string(&git_log_output_encoding, var, value); if (!strcmp(var, "pager.color") || !strcmp(var, "color.pager")) { pager_use_color = git_config_bool(var,value); return 0; } if (!strcmp(var, "core.pager")) return git_config_string(&pager_program, var, value); if (!strcmp(var, "core.editor")) return git_config_string(&editor_program, var, value); if (!strcmp(var, "core.excludesfile")) return git_config_string(&excludes_file, var, value); if (!strcmp(var, "core.whitespace")) { if (!value) return config_error_nonbool(var); whitespace_rule_cfg = parse_whitespace_rule(value); return 0; } if (!strcmp(var, "branch.autosetupmerge")) { if (value && !strcasecmp(value, "always")) { git_branch_track = BRANCH_TRACK_ALWAYS; return 0; } git_branch_track = git_config_bool(var, value); return 0; } if (!strcmp(var, "branch.autosetuprebase")) { if (!value) return config_error_nonbool(var); else if (!strcmp(value, "never")) autorebase = AUTOREBASE_NEVER; else if (!strcmp(value, "local")) autorebase = AUTOREBASE_LOCAL; else if (!strcmp(value, "remote")) autorebase = AUTOREBASE_REMOTE; else if (!strcmp(value, "always")) autorebase = AUTOREBASE_ALWAYS; else return error("Malformed value for %s", var); return 0; } /* Add other config variables here and to Documentation/config.txt. */ return 0; }