static int git_init_db_config(const char *k, const char *v, void *cb) { if (!strcmp(k, "init.templatedir")) return git_config_pathname(&init_db_template_dir, k, v); return 0; }
static int git_hook_config(const char *var, const char *value, void *cb) { if (!strcmp(var, "hooks.directory")) return git_config_pathname(&hook_directory, var, value); return git_diff_ui_config(var, value, cb); }
static int show_config(const char *key_, const char *value_, void *cb) { char value[256]; const char *vptr = value; int must_free_vptr = 0; int dup_error = 0; if (!use_key_regexp && strcmp(key_, key)) return 0; if (use_key_regexp && regexec(key_regexp, key_, 0, NULL, 0)) return 0; if (regexp != NULL && (do_not_match ^ !!regexec(regexp, (value_?value_:""), 0, NULL, 0))) return 0; if (show_keys) { if (value_) printf("%s%c", key_, key_delim); else printf("%s", key_); } if (seen && !do_all) dup_error = 1; if (types == TYPE_INT) sprintf(value, "%d", git_config_int(key_, value_?value_:"")); else if (types == TYPE_BOOL) vptr = git_config_bool(key_, value_) ? "true" : "false"; else if (types == TYPE_BOOL_OR_INT) { int is_bool, v; v = git_config_bool_or_int(key_, value_, &is_bool); if (is_bool) vptr = v ? "true" : "false"; else sprintf(value, "%d", v); } else if (types == TYPE_PATH) { git_config_pathname(&vptr, key_, value_); must_free_vptr = 1; } else vptr = value_?value_:""; seen++; if (dup_error) { error("More than one value for the key %s: %s", key_, vptr); } else printf("%s%c", vptr, term); if (must_free_vptr) /* If vptr must be freed, it's a pointer to a * dynamically allocated buffer, it's safe to cast to * const. */ free((char *)vptr); return 0; }
static int git_init_db_config(const char *k, const char *v, void *cb) { if (!strcmp(k, "init.templatedir")) return git_config_pathname(&init_db_template_dir, k, v); if (starts_with(k, "core.")) return platform_core_config(k, v, cb); return 0; }
static int git_commit_config(const char *k, const char *v, void *cb) { struct wt_status *s = cb; if (!strcmp(k, "commit.template")) return git_config_pathname(&template_file, k, v); if (!strcmp(k, "commit.status")) { include_status = git_config_bool(k, v); return 0; } return git_status_config(k, v, s); }
static int git_commit_config(const char *k, const char *v, void *cb) { struct wt_status *s = cb; int status; if (!strcmp(k, "commit.template")) return git_config_pathname(&template_file, k, v); if (!strcmp(k, "commit.status")) { include_status = git_config_bool(k, v); return 0; } if (!strcmp(k, "commit.cleanup")) return git_config_string(&cleanup_arg, k, v); status = git_gpg_config(k, v, NULL); if (status) return status; return git_status_config(k, v, s); }
static int fsck_config(const char *var, const char *value, void *cb) { if (strcmp(var, "fsck.skiplist") == 0) { const char *path; struct strbuf sb = STRBUF_INIT; if (git_config_pathname(&path, var, value)) return 1; strbuf_addf(&sb, "skiplist=%s", path); free((char *)path); fsck_set_msg_types(&fsck_obj_options, sb.buf); strbuf_release(&sb); return 0; } if (skip_prefix(var, "fsck.", &var)) { fsck_set_msg_type(&fsck_obj_options, var, value); return 0; } return git_default_config(var, value, cb); }
static int fetch_pack_config_cb(const char *var, const char *value, void *cb) { if (strcmp(var, "fetch.fsck.skiplist") == 0) { const char *path; if (git_config_pathname(&path, var, value)) return 1; strbuf_addf(&fsck_msg_types, "%cskiplist=%s", fsck_msg_types.len ? ',' : '=', path); free((char *)path); return 0; } if (skip_prefix(var, "fetch.fsck.", &var)) { if (is_valid_msg_type(var, value)) strbuf_addf(&fsck_msg_types, "%c%s=%s", fsck_msg_types.len ? ',' : '=', var, value); else warning("Skipping unknown msg id '%s'", var); return 0; } return git_default_config(var, value, cb); }
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 receive_pack_config(const char *var, const char *value, void *cb) { int status = parse_hide_refs_config(var, value, "receive"); if (status) return status; if (strcmp(var, "receive.denydeletes") == 0) { deny_deletes = git_config_bool(var, value); return 0; } if (strcmp(var, "receive.denynonfastforwards") == 0) { deny_non_fast_forwards = git_config_bool(var, value); return 0; } if (strcmp(var, "receive.unpacklimit") == 0) { receive_unpack_limit = git_config_int(var, value); return 0; } if (strcmp(var, "transfer.unpacklimit") == 0) { transfer_unpack_limit = git_config_int(var, value); return 0; } if (strcmp(var, "receive.fsck.skiplist") == 0) { const char *path; if (git_config_pathname(&path, var, value)) return 1; strbuf_addf(&fsck_msg_types, "%cskiplist=%s", fsck_msg_types.len ? ',' : '=', path); free((char *)path); return 0; } if (skip_prefix(var, "receive.fsck.", &var)) { if (is_valid_msg_type(var, value)) strbuf_addf(&fsck_msg_types, "%c%s=%s", fsck_msg_types.len ? ',' : '=', var, value); else warning("Skipping unknown msg id '%s'", var); return 0; } if (strcmp(var, "receive.fsckobjects") == 0) { receive_fsck_objects = git_config_bool(var, value); return 0; } if (strcmp(var, "transfer.fsckobjects") == 0) { transfer_fsck_objects = git_config_bool(var, value); return 0; } if (!strcmp(var, "receive.denycurrentbranch")) { deny_current_branch = parse_deny_action(var, value); return 0; } if (strcmp(var, "receive.denydeletecurrent") == 0) { deny_delete_current = parse_deny_action(var, value); return 0; } if (strcmp(var, "repack.usedeltabaseoffset") == 0) { prefer_ofs_delta = git_config_bool(var, value); return 0; } if (strcmp(var, "receive.updateserverinfo") == 0) { auto_update_server_info = git_config_bool(var, value); return 0; } if (strcmp(var, "receive.autogc") == 0) { auto_gc = git_config_bool(var, value); return 0; } if (strcmp(var, "receive.shallowupdate") == 0) { shallow_update = git_config_bool(var, value); return 0; } if (strcmp(var, "receive.certnonceseed") == 0) return git_config_string(&cert_nonce_seed, var, value); if (strcmp(var, "receive.certnonceslop") == 0) { nonce_stamp_slop_limit = git_config_ulong(var, value); return 0; } if (strcmp(var, "receive.advertiseatomic") == 0) { advertise_atomic_push = git_config_bool(var, value); return 0; } if (strcmp(var, "receive.advertisepushoptions") == 0) { advertise_push_options = git_config_bool(var, value); return 0; } if (strcmp(var, "receive.keepalive") == 0) { keepalive_in_sec = git_config_int(var, value); return 0; } return git_default_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; }