From e67a57fc5187f93ced9631edf80fc09eefb3fed9 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Wed, 14 Jun 2017 11:07:34 -0700 Subject: config: create config.h Move all config related declarations from cache.h to a new config.h header file. This makes cache.h smaller and allows for the opportunity in a following patch to only include config.h when needed. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- cache.h | 190 +------------------------------------------------------------ config.h | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+), 189 deletions(-) create mode 100644 config.h diff --git a/cache.h b/cache.h index e1f0e182a..67efb47a1 100644 --- a/cache.h +++ b/cache.h @@ -11,6 +11,7 @@ #include "string-list.h" #include "pack-revindex.h" #include "hash.h" +#include "config.h" #ifndef platform_SHA_CTX /* @@ -1865,188 +1866,9 @@ extern int packed_object_info(struct packed_git *pack, off_t offset, struct obje /* Dumb servers support */ extern int update_server_info(int); -/* git_config_parse_key() returns these negated: */ -#define CONFIG_INVALID_KEY 1 -#define CONFIG_NO_SECTION_OR_NAME 2 -/* git_config_set_gently(), git_config_set_multivar_gently() return the above or these: */ -#define CONFIG_NO_LOCK -1 -#define CONFIG_INVALID_FILE 3 -#define CONFIG_NO_WRITE 4 -#define CONFIG_NOTHING_SET 5 -#define CONFIG_INVALID_PATTERN 6 -#define CONFIG_GENERIC_ERROR 7 - -#define CONFIG_REGEX_NONE ((void *)1) - -struct git_config_source { - unsigned int use_stdin:1; - const char *file; - const char *blob; -}; - -enum config_origin_type { - CONFIG_ORIGIN_BLOB, - CONFIG_ORIGIN_FILE, - CONFIG_ORIGIN_STDIN, - CONFIG_ORIGIN_SUBMODULE_BLOB, - CONFIG_ORIGIN_CMDLINE -}; - -struct config_options { - unsigned int respect_includes : 1; - const char *git_dir; -}; - -typedef int (*config_fn_t)(const char *, const char *, void *); -extern int git_default_config(const char *, const char *, void *); -extern int git_config_from_file(config_fn_t fn, const char *, void *); -extern int git_config_from_mem(config_fn_t fn, const enum config_origin_type, - const char *name, const char *buf, size_t len, void *data); -extern int git_config_from_blob_sha1(config_fn_t fn, const char *name, - const unsigned char *sha1, void *data); -extern void git_config_push_parameter(const char *text); -extern int git_config_from_parameters(config_fn_t fn, void *data); -extern void read_early_config(config_fn_t cb, void *data); -extern void git_config(config_fn_t fn, void *); -extern int git_config_with_options(config_fn_t fn, void *, - struct git_config_source *config_source, - const struct config_options *opts); -extern int git_parse_ulong(const char *, unsigned long *); -extern int git_parse_maybe_bool(const char *); -extern int git_config_int(const char *, const char *); -extern int64_t git_config_int64(const char *, const char *); -extern unsigned long git_config_ulong(const char *, const char *); -extern ssize_t git_config_ssize_t(const char *, const char *); -extern int git_config_bool_or_int(const char *, const char *, int *); -extern int git_config_bool(const char *, const char *); -extern int git_config_maybe_bool(const char *, const char *); -extern int git_config_string(const char **, const char *, const char *); -extern int git_config_pathname(const char **, const char *, const char *); -extern int git_config_set_in_file_gently(const char *, const char *, const char *); -extern void git_config_set_in_file(const char *, const char *, const char *); -extern int git_config_set_gently(const char *, const char *); -extern void git_config_set(const char *, const char *); -extern int git_config_parse_key(const char *, char **, int *); -extern int git_config_key_is_valid(const char *key); -extern int git_config_set_multivar_gently(const char *, const char *, const char *, int); -extern void git_config_set_multivar(const char *, const char *, const char *, int); -extern int git_config_set_multivar_in_file_gently(const char *, const char *, const char *, const char *, int); -extern void git_config_set_multivar_in_file(const char *, const char *, const char *, const char *, int); -extern int git_config_rename_section(const char *, const char *); -extern int git_config_rename_section_in_file(const char *, const char *, const char *); -extern const char *git_etc_gitconfig(void); -extern int git_env_bool(const char *, int); -extern unsigned long git_env_ulong(const char *, unsigned long); -extern int git_config_system(void); -extern int config_error_nonbool(const char *); -#if defined(__GNUC__) -#define config_error_nonbool(s) (config_error_nonbool(s), const_error()) -#endif extern const char *get_log_output_encoding(void); extern const char *get_commit_output_encoding(void); -extern int git_config_parse_parameter(const char *, config_fn_t fn, void *data); - -enum config_scope { - CONFIG_SCOPE_UNKNOWN = 0, - CONFIG_SCOPE_SYSTEM, - CONFIG_SCOPE_GLOBAL, - CONFIG_SCOPE_REPO, - CONFIG_SCOPE_CMDLINE, -}; - -extern enum config_scope current_config_scope(void); -extern const char *current_config_origin_type(void); -extern const char *current_config_name(void); - -struct config_include_data { - int depth; - config_fn_t fn; - void *data; - const struct config_options *opts; -}; -#define CONFIG_INCLUDE_INIT { 0 } -extern int git_config_include(const char *name, const char *value, void *data); - -/* - * Match and parse a config key of the form: - * - * section.(subsection.)?key - * - * (i.e., what gets handed to a config_fn_t). The caller provides the section; - * we return -1 if it does not match, 0 otherwise. The subsection and key - * out-parameters are filled by the function (and *subsection is NULL if it is - * missing). - * - * If the subsection pointer-to-pointer passed in is NULL, returns 0 only if - * there is no subsection at all. - */ -extern int parse_config_key(const char *var, - const char *section, - const char **subsection, int *subsection_len, - const char **key); - -struct config_set_element { - struct hashmap_entry ent; - char *key; - struct string_list value_list; -}; - -struct configset_list_item { - struct config_set_element *e; - int value_index; -}; - -/* - * the contents of the list are ordered according to their - * position in the config files and order of parsing the files. - * (i.e. key-value pair at the last position of .git/config will - * be at the last item of the list) - */ -struct configset_list { - struct configset_list_item *items; - unsigned int nr, alloc; -}; - -struct config_set { - struct hashmap config_hash; - int hash_initialized; - struct configset_list list; -}; - -extern void git_configset_init(struct config_set *cs); -extern int git_configset_add_file(struct config_set *cs, const char *filename); -extern int git_configset_get_value(struct config_set *cs, const char *key, const char **value); -extern const struct string_list *git_configset_get_value_multi(struct config_set *cs, const char *key); -extern void git_configset_clear(struct config_set *cs); -extern int git_configset_get_string_const(struct config_set *cs, const char *key, const char **dest); -extern int git_configset_get_string(struct config_set *cs, const char *key, char **dest); -extern int git_configset_get_int(struct config_set *cs, const char *key, int *dest); -extern int git_configset_get_ulong(struct config_set *cs, const char *key, unsigned long *dest); -extern int git_configset_get_bool(struct config_set *cs, const char *key, int *dest); -extern int git_configset_get_bool_or_int(struct config_set *cs, const char *key, int *is_bool, int *dest); -extern int git_configset_get_maybe_bool(struct config_set *cs, const char *key, int *dest); -extern int git_configset_get_pathname(struct config_set *cs, const char *key, const char **dest); - -extern int git_config_get_value(const char *key, const char **value); -extern const struct string_list *git_config_get_value_multi(const char *key); -extern void git_config_clear(void); -extern void git_config_iter(config_fn_t fn, void *data); -extern int git_config_get_string_const(const char *key, const char **dest); -extern int git_config_get_string(const char *key, char **dest); -extern int git_config_get_int(const char *key, int *dest); -extern int git_config_get_ulong(const char *key, unsigned long *dest); -extern int git_config_get_bool(const char *key, int *dest); -extern int git_config_get_bool_or_int(const char *key, int *is_bool, int *dest); -extern int git_config_get_maybe_bool(const char *key, int *dest); -extern int git_config_get_pathname(const char *key, const char **dest); -extern int git_config_get_untracked_cache(void); -extern int git_config_get_split_index(void); -extern int git_config_get_max_percent_split_change(void); - -/* This dies if the configured or default date is in the future */ -extern int git_config_get_expiry(const char *key, const char **output); - /* * This is a hack for test programs like test-dump-untracked-cache to * ensure that they do not modify the untracked cache when reading it. @@ -2054,16 +1876,6 @@ extern int git_config_get_expiry(const char *key, const char **output); */ extern int ignore_untracked_cache_config; -struct key_value_info { - const char *filename; - int linenr; - enum config_origin_type origin_type; - enum config_scope scope; -}; - -extern NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3))); -extern NORETURN void git_die_config_linenr(const char *key, const char *filename, int linenr); - extern int committer_ident_sufficiently_given(void); extern int author_ident_sufficiently_given(void); diff --git a/config.h b/config.h new file mode 100644 index 000000000..f7f8b66c5 --- /dev/null +++ b/config.h @@ -0,0 +1,194 @@ +#ifndef CONFIG_H +#define CONFIG_H + +/* git_config_parse_key() returns these negated: */ +#define CONFIG_INVALID_KEY 1 +#define CONFIG_NO_SECTION_OR_NAME 2 +/* git_config_set_gently(), git_config_set_multivar_gently() return the above or these: */ +#define CONFIG_NO_LOCK -1 +#define CONFIG_INVALID_FILE 3 +#define CONFIG_NO_WRITE 4 +#define CONFIG_NOTHING_SET 5 +#define CONFIG_INVALID_PATTERN 6 +#define CONFIG_GENERIC_ERROR 7 + +#define CONFIG_REGEX_NONE ((void *)1) + +struct git_config_source { + unsigned int use_stdin:1; + const char *file; + const char *blob; +}; + +enum config_origin_type { + CONFIG_ORIGIN_BLOB, + CONFIG_ORIGIN_FILE, + CONFIG_ORIGIN_STDIN, + CONFIG_ORIGIN_SUBMODULE_BLOB, + CONFIG_ORIGIN_CMDLINE +}; + +struct config_options { + unsigned int respect_includes : 1; + const char *git_dir; +}; + +typedef int (*config_fn_t)(const char *, const char *, void *); +extern int git_default_config(const char *, const char *, void *); +extern int git_config_from_file(config_fn_t fn, const char *, void *); +extern int git_config_from_mem(config_fn_t fn, const enum config_origin_type, + const char *name, const char *buf, size_t len, void *data); +extern int git_config_from_blob_sha1(config_fn_t fn, const char *name, + const unsigned char *sha1, void *data); +extern void git_config_push_parameter(const char *text); +extern int git_config_from_parameters(config_fn_t fn, void *data); +extern void read_early_config(config_fn_t cb, void *data); +extern void git_config(config_fn_t fn, void *); +extern int git_config_with_options(config_fn_t fn, void *, + struct git_config_source *config_source, + const struct config_options *opts); +extern int git_parse_ulong(const char *, unsigned long *); +extern int git_parse_maybe_bool(const char *); +extern int git_config_int(const char *, const char *); +extern int64_t git_config_int64(const char *, const char *); +extern unsigned long git_config_ulong(const char *, const char *); +extern ssize_t git_config_ssize_t(const char *, const char *); +extern int git_config_bool_or_int(const char *, const char *, int *); +extern int git_config_bool(const char *, const char *); +extern int git_config_maybe_bool(const char *, const char *); +extern int git_config_string(const char **, const char *, const char *); +extern int git_config_pathname(const char **, const char *, const char *); +extern int git_config_set_in_file_gently(const char *, const char *, const char *); +extern void git_config_set_in_file(const char *, const char *, const char *); +extern int git_config_set_gently(const char *, const char *); +extern void git_config_set(const char *, const char *); +extern int git_config_parse_key(const char *, char **, int *); +extern int git_config_key_is_valid(const char *key); +extern int git_config_set_multivar_gently(const char *, const char *, const char *, int); +extern void git_config_set_multivar(const char *, const char *, const char *, int); +extern int git_config_set_multivar_in_file_gently(const char *, const char *, const char *, const char *, int); +extern void git_config_set_multivar_in_file(const char *, const char *, const char *, const char *, int); +extern int git_config_rename_section(const char *, const char *); +extern int git_config_rename_section_in_file(const char *, const char *, const char *); +extern const char *git_etc_gitconfig(void); +extern int git_env_bool(const char *, int); +extern unsigned long git_env_ulong(const char *, unsigned long); +extern int git_config_system(void); +extern int config_error_nonbool(const char *); +#if defined(__GNUC__) +#define config_error_nonbool(s) (config_error_nonbool(s), const_error()) +#endif + +extern int git_config_parse_parameter(const char *, config_fn_t fn, void *data); + +enum config_scope { + CONFIG_SCOPE_UNKNOWN = 0, + CONFIG_SCOPE_SYSTEM, + CONFIG_SCOPE_GLOBAL, + CONFIG_SCOPE_REPO, + CONFIG_SCOPE_CMDLINE, +}; + +extern enum config_scope current_config_scope(void); +extern const char *current_config_origin_type(void); +extern const char *current_config_name(void); + +struct config_include_data { + int depth; + config_fn_t fn; + void *data; + const struct config_options *opts; +}; +#define CONFIG_INCLUDE_INIT { 0 } +extern int git_config_include(const char *name, const char *value, void *data); + +/* + * Match and parse a config key of the form: + * + * section.(subsection.)?key + * + * (i.e., what gets handed to a config_fn_t). The caller provides the section; + * we return -1 if it does not match, 0 otherwise. The subsection and key + * out-parameters are filled by the function (and *subsection is NULL if it is + * missing). + * + * If the subsection pointer-to-pointer passed in is NULL, returns 0 only if + * there is no subsection at all. + */ +extern int parse_config_key(const char *var, + const char *section, + const char **subsection, int *subsection_len, + const char **key); + +struct config_set_element { + struct hashmap_entry ent; + char *key; + struct string_list value_list; +}; + +struct configset_list_item { + struct config_set_element *e; + int value_index; +}; + +/* + * the contents of the list are ordered according to their + * position in the config files and order of parsing the files. + * (i.e. key-value pair at the last position of .git/config will + * be at the last item of the list) + */ +struct configset_list { + struct configset_list_item *items; + unsigned int nr, alloc; +}; + +struct config_set { + struct hashmap config_hash; + int hash_initialized; + struct configset_list list; +}; + +extern void git_configset_init(struct config_set *cs); +extern int git_configset_add_file(struct config_set *cs, const char *filename); +extern int git_configset_get_value(struct config_set *cs, const char *key, const char **value); +extern const struct string_list *git_configset_get_value_multi(struct config_set *cs, const char *key); +extern void git_configset_clear(struct config_set *cs); +extern int git_configset_get_string_const(struct config_set *cs, const char *key, const char **dest); +extern int git_configset_get_string(struct config_set *cs, const char *key, char **dest); +extern int git_configset_get_int(struct config_set *cs, const char *key, int *dest); +extern int git_configset_get_ulong(struct config_set *cs, const char *key, unsigned long *dest); +extern int git_configset_get_bool(struct config_set *cs, const char *key, int *dest); +extern int git_configset_get_bool_or_int(struct config_set *cs, const char *key, int *is_bool, int *dest); +extern int git_configset_get_maybe_bool(struct config_set *cs, const char *key, int *dest); +extern int git_configset_get_pathname(struct config_set *cs, const char *key, const char **dest); + +extern int git_config_get_value(const char *key, const char **value); +extern const struct string_list *git_config_get_value_multi(const char *key); +extern void git_config_clear(void); +extern void git_config_iter(config_fn_t fn, void *data); +extern int git_config_get_string_const(const char *key, const char **dest); +extern int git_config_get_string(const char *key, char **dest); +extern int git_config_get_int(const char *key, int *dest); +extern int git_config_get_ulong(const char *key, unsigned long *dest); +extern int git_config_get_bool(const char *key, int *dest); +extern int git_config_get_bool_or_int(const char *key, int *is_bool, int *dest); +extern int git_config_get_maybe_bool(const char *key, int *dest); +extern int git_config_get_pathname(const char *key, const char **dest); +extern int git_config_get_untracked_cache(void); +extern int git_config_get_split_index(void); +extern int git_config_get_max_percent_split_change(void); + +/* This dies if the configured or default date is in the future */ +extern int git_config_get_expiry(const char *key, const char **output); + +struct key_value_info { + const char *filename; + int linenr; + enum config_origin_type origin_type; + enum config_scope scope; +}; + +extern NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3))); +extern NORETURN void git_die_config_linenr(const char *key, const char *filename, int linenr); + +#endif /* CONFIG_H */ -- cgit v1.2.1 From f1c985da05c136414c10f034cdc09bdb6939cb8f Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Wed, 14 Jun 2017 11:07:35 -0700 Subject: config: remove git_config_iter Since there is no implementation of the function 'git_config_iter', let's stop exporting it and remove the prototype from config.h. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/config.h b/config.h index f7f8b66c5..c70599bd5 100644 --- a/config.h +++ b/config.h @@ -165,7 +165,6 @@ extern int git_configset_get_pathname(struct config_set *cs, const char *key, co extern int git_config_get_value(const char *key, const char **value); extern const struct string_list *git_config_get_value_multi(const char *key); extern void git_config_clear(void); -extern void git_config_iter(config_fn_t fn, void *data); extern int git_config_get_string_const(const char *key, const char **dest); extern int git_config_get_string(const char *key, char **dest); extern int git_config_get_int(const char *key, int *dest); -- cgit v1.2.1 From b2141fc1d20e659810245ec6ca1c143c60e033ec Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Wed, 14 Jun 2017 11:07:36 -0700 Subject: config: don't include config.h by default Stop including config.h by default in cache.h. Instead only include config.h in those files which require use of the config system. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- advice.c | 1 + alias.c | 1 + apply.c | 1 + archive-tar.c | 1 + archive-zip.c | 1 + archive.c | 1 + attr.c | 1 + bisect.c | 1 + branch.c | 1 + builtin/add.c | 1 + builtin/am.c | 1 + builtin/blame.c | 1 + builtin/branch.c | 1 + builtin/cat-file.c | 1 + builtin/check-attr.c | 1 + builtin/check-ignore.c | 1 + builtin/check-mailmap.c | 1 + builtin/checkout-index.c | 1 + builtin/checkout.c | 1 + builtin/clean.c | 1 + builtin/clone.c | 1 + builtin/column.c | 1 + builtin/commit-tree.c | 1 + builtin/commit.c | 1 + builtin/config.c | 1 + builtin/count-objects.c | 1 + builtin/describe.c | 1 + builtin/diff-files.c | 1 + builtin/diff-index.c | 1 + builtin/diff-tree.c | 1 + builtin/diff.c | 1 + builtin/difftool.c | 1 + builtin/fast-export.c | 1 + builtin/fetch.c | 1 + builtin/fmt-merge-msg.c | 1 + builtin/for-each-ref.c | 1 + builtin/fsck.c | 1 + builtin/gc.c | 1 + builtin/grep.c | 1 + builtin/hash-object.c | 1 + builtin/help.c | 1 + builtin/index-pack.c | 1 + builtin/init-db.c | 1 + builtin/log.c | 1 + builtin/ls-files.c | 1 + builtin/ls-tree.c | 1 + builtin/merge-base.c | 1 + builtin/merge-file.c | 1 + builtin/merge.c | 1 + builtin/mv.c | 1 + builtin/name-rev.c | 1 + builtin/notes.c | 1 + builtin/pack-objects.c | 1 + builtin/patch-id.c | 1 + builtin/pull.c | 1 + builtin/push.c | 1 + builtin/read-tree.c | 1 + builtin/rebase--helper.c | 1 + builtin/receive-pack.c | 1 + builtin/reflog.c | 1 + builtin/remote.c | 1 + builtin/repack.c | 1 + builtin/replace.c | 1 + builtin/rerere.c | 1 + builtin/reset.c | 1 + builtin/rev-list.c | 1 + builtin/rev-parse.c | 1 + builtin/revert.c | 1 + builtin/rm.c | 1 + builtin/send-pack.c | 1 + builtin/shortlog.c | 1 + builtin/show-branch.c | 1 + builtin/stripspace.c | 1 + builtin/submodule--helper.c | 1 + builtin/symbolic-ref.c | 1 + builtin/tag.c | 1 + builtin/unpack-file.c | 1 + builtin/unpack-objects.c | 1 + builtin/update-index.c | 1 + builtin/update-ref.c | 1 + builtin/update-server-info.c | 1 + builtin/var.c | 1 + builtin/verify-commit.c | 1 + builtin/verify-pack.c | 1 + builtin/verify-tag.c | 1 + builtin/worktree.c | 1 + builtin/write-tree.c | 1 + cache.h | 1 - color.c | 1 + column.c | 1 + compat/precompose_utf8.c | 1 + config.c | 1 + connect.c | 1 + convert.c | 1 + credential-cache--daemon.c | 1 + credential.c | 1 + daemon.c | 1 + diff.c | 1 + dir.c | 1 + environment.c | 1 + fast-import.c | 1 + fetch-pack.c | 1 + git.c | 1 + gpg-interface.c | 1 + graph.c | 1 + grep.c | 1 + help.c | 1 + http-backend.c | 1 + http-fetch.c | 1 + http.c | 1 + ident.c | 1 + imap-send.c | 1 + ll-merge.c | 1 + log-tree.c | 1 + mailinfo.c | 1 + merge-recursive.c | 1 + notes-utils.c | 1 + notes.c | 1 + pager.c | 1 + parse-options.c | 1 + pathspec.c | 1 + pretty.c | 1 + prompt.c | 1 + read-cache.c | 1 + refs.c | 1 + refs/files-backend.c | 1 + remote-curl.c | 1 + remote.c | 1 + rerere.c | 1 + send-pack.c | 1 + sequencer.c | 1 + setup.c | 1 + sha1_file.c | 1 + sha1_name.c | 1 + submodule-config.c | 1 + submodule.c | 1 + t/helper/test-config.c | 1 + t/helper/test-submodule-config.c | 1 + trailer.c | 1 + transport.c | 1 + unpack-trees.c | 1 + upload-pack.c | 1 + userdiff.c | 1 + versioncmp.c | 1 + wrapper.c | 1 + xdiff-interface.c | 1 + 146 files changed, 145 insertions(+), 1 deletion(-) diff --git a/advice.c b/advice.c index b84ae4960..3fa04fca0 100644 --- a/advice.c +++ b/advice.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" int advice_push_update_rejected = 1; int advice_push_non_ff_current = 1; diff --git a/alias.c b/alias.c index 052630466..de8e6a3f4 100644 --- a/alias.c +++ b/alias.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" struct config_alias_data { const char *alias; diff --git a/apply.c b/apply.c index e6dbab26a..5b442860d 100644 --- a/apply.c +++ b/apply.c @@ -8,6 +8,7 @@ */ #include "cache.h" +#include "config.h" #include "blob.h" #include "delta.h" #include "diff.h" diff --git a/archive-tar.c b/archive-tar.c index 380e3aedd..d65ac016d 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -2,6 +2,7 @@ * Copyright (c) 2005, 2006 Rene Scharfe */ #include "cache.h" +#include "config.h" #include "tar.h" #include "archive.h" #include "streaming.h" diff --git a/archive-zip.c b/archive-zip.c index b429a8d97..04fcd8687 100644 --- a/archive-zip.c +++ b/archive-zip.c @@ -2,6 +2,7 @@ * Copyright (c) 2006 Rene Scharfe */ #include "cache.h" +#include "config.h" #include "archive.h" #include "streaming.h" #include "utf8.h" diff --git a/archive.c b/archive.c index 60b889198..0cba5b409 100644 --- a/archive.c +++ b/archive.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "refs.h" #include "commit.h" #include "tree-walk.h" diff --git a/attr.c b/attr.c index 7e2134471..9f8b02936 100644 --- a/attr.c +++ b/attr.c @@ -9,6 +9,7 @@ #define NO_THE_INDEX_COMPATIBILITY_MACROS #include "cache.h" +#include "config.h" #include "exec_cmd.h" #include "attr.h" #include "dir.h" diff --git a/bisect.c b/bisect.c index 08c9fb726..e8f03a08c 100644 --- a/bisect.c +++ b/bisect.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "commit.h" #include "diff.h" #include "revision.h" diff --git a/branch.c b/branch.c index ad5a2299b..5532b4218 100644 --- a/branch.c +++ b/branch.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "cache.h" +#include "config.h" #include "branch.h" #include "refs.h" #include "remote.h" diff --git a/builtin/add.c b/builtin/add.c index 9f53f020d..55759a6a7 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -4,6 +4,7 @@ * Copyright (C) 2006 Linus Torvalds */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "lockfile.h" #include "dir.h" diff --git a/builtin/am.c b/builtin/am.c index a95dd8b4e..59f46a29e 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -4,6 +4,7 @@ * Based on git-am.sh by Junio C Hamano. */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "exec_cmd.h" #include "parse-options.h" diff --git a/builtin/blame.c b/builtin/blame.c index 07506a3e4..1a7371808 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -6,6 +6,7 @@ */ #include "cache.h" +#include "config.h" #include "refs.h" #include "builtin.h" #include "blob.h" diff --git a/builtin/branch.c b/builtin/branch.c index 48a513a84..50b59238d 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -6,6 +6,7 @@ */ #include "cache.h" +#include "config.h" #include "color.h" #include "refs.h" #include "commit.h" diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 1890d7a63..12451205c 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -4,6 +4,7 @@ * Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "parse-options.h" #include "userdiff.h" diff --git a/builtin/check-attr.c b/builtin/check-attr.c index 4d01ca0c8..91444dc04 100644 --- a/builtin/check-attr.c +++ b/builtin/check-attr.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "attr.h" #include "quote.h" #include "parse-options.h" diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c index 1d73d3ca3..a2da09f4a 100644 --- a/builtin/check-ignore.c +++ b/builtin/check-ignore.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "dir.h" #include "quote.h" #include "pathspec.h" diff --git a/builtin/check-mailmap.c b/builtin/check-mailmap.c index cf0f54f6b..cdce144f3 100644 --- a/builtin/check-mailmap.c +++ b/builtin/check-mailmap.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "config.h" #include "mailmap.h" #include "parse-options.h" #include "string-list.h" diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c index 07631d0c9..39c8be05d 100644 --- a/builtin/checkout-index.c +++ b/builtin/checkout-index.c @@ -5,6 +5,7 @@ * */ #include "builtin.h" +#include "config.h" #include "lockfile.h" #include "quote.h" #include "cache-tree.h" diff --git a/builtin/checkout.c b/builtin/checkout.c index bfa5419f3..e0b58ddc0 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "config.h" #include "lockfile.h" #include "parse-options.h" #include "refs.h" diff --git a/builtin/clean.c b/builtin/clean.c index d861f836a..57093db8b 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -8,6 +8,7 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "dir.h" #include "parse-options.h" #include "string-list.h" diff --git a/builtin/clone.c b/builtin/clone.c index de85b8525..eaacac221 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -9,6 +9,7 @@ */ #include "builtin.h" +#include "config.h" #include "lockfile.h" #include "parse-options.h" #include "fetch-pack.h" diff --git a/builtin/column.c b/builtin/column.c index 33314b4d7..0c3223d64 100644 --- a/builtin/column.c +++ b/builtin/column.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "strbuf.h" #include "parse-options.h" #include "string-list.h" diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c index 605017261..e1c17ba64 100644 --- a/builtin/commit-tree.c +++ b/builtin/commit-tree.c @@ -4,6 +4,7 @@ * Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "commit.h" #include "tree.h" #include "builtin.h" diff --git a/builtin/commit.c b/builtin/commit.c index 1d805f5da..929a45abe 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -6,6 +6,7 @@ */ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "cache-tree.h" #include "color.h" diff --git a/builtin/config.c b/builtin/config.c index 3a554ad50..b2045cd6c 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "color.h" #include "parse-options.h" #include "urlmatch.h" diff --git a/builtin/count-objects.c b/builtin/count-objects.c index acb05940f..1d82e61f2 100644 --- a/builtin/count-objects.c +++ b/builtin/count-objects.c @@ -5,6 +5,7 @@ */ #include "cache.h" +#include "config.h" #include "dir.h" #include "builtin.h" #include "parse-options.h" diff --git a/builtin/describe.c b/builtin/describe.c index a5cd8c513..3eddfd370 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "commit.h" #include "tag.h" diff --git a/builtin/diff-files.c b/builtin/diff-files.c index 15c61fd8d..29d3e4f41 100644 --- a/builtin/diff-files.c +++ b/builtin/diff-files.c @@ -4,6 +4,7 @@ * Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "diff.h" #include "commit.h" #include "revision.h" diff --git a/builtin/diff-index.c b/builtin/diff-index.c index 1af373d00..e3d418361 100644 --- a/builtin/diff-index.c +++ b/builtin/diff-index.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "diff.h" #include "commit.h" #include "revision.h" diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c index 326f88b65..c81063d53 100644 --- a/builtin/diff-tree.c +++ b/builtin/diff-tree.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "diff.h" #include "commit.h" #include "log-tree.h" diff --git a/builtin/diff.c b/builtin/diff.c index d184aafab..1ce40c63b 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -4,6 +4,7 @@ * Copyright (c) 2006 Junio C Hamano */ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "color.h" #include "commit.h" diff --git a/builtin/difftool.c b/builtin/difftool.c index 1354d0e46..538b0187f 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -12,6 +12,7 @@ * Copyright (C) 2016 Johannes Schindelin */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "run-command.h" #include "exec_cmd.h" diff --git a/builtin/fast-export.c b/builtin/fast-export.c index e0220630d..e4304e2dd 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -5,6 +5,7 @@ */ #include "builtin.h" #include "cache.h" +#include "config.h" #include "refs.h" #include "commit.h" #include "object.h" diff --git a/builtin/fetch.c b/builtin/fetch.c index 5f2c2ab23..1fe8f6238 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -2,6 +2,7 @@ * "git fetch" */ #include "cache.h" +#include "config.h" #include "refs.h" #include "commit.h" #include "builtin.h" diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c index 6faa3c0d2..2e30b514f 100644 --- a/builtin/fmt-merge-msg.c +++ b/builtin/fmt-merge-msg.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "refs.h" #include "commit.h" #include "diff.h" diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index eca365bf8..52be99cba 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "refs.h" #include "object.h" #include "parse-options.h" diff --git a/builtin/fsck.c b/builtin/fsck.c index b5e13a455..0c63f6259 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "tree.h" #include "blob.h" diff --git a/builtin/gc.c b/builtin/gc.c index 91f7696a8..0a6790d71 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -11,6 +11,7 @@ */ #include "builtin.h" +#include "config.h" #include "tempfile.h" #include "lockfile.h" #include "parse-options.h" diff --git a/builtin/grep.c b/builtin/grep.c index 3ffb5b4e8..3df9e08f0 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -4,6 +4,7 @@ * Copyright (c) 2006 Junio C Hamano */ #include "cache.h" +#include "config.h" #include "blob.h" #include "tree.h" #include "commit.h" diff --git a/builtin/hash-object.c b/builtin/hash-object.c index bbeaf20bc..d04baf999 100644 --- a/builtin/hash-object.c +++ b/builtin/hash-object.c @@ -5,6 +5,7 @@ * Copyright (C) Junio C Hamano, 2005 */ #include "builtin.h" +#include "config.h" #include "blob.h" #include "quote.h" #include "parse-options.h" diff --git a/builtin/help.c b/builtin/help.c index 49f7a07f8..334a8494a 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -2,6 +2,7 @@ * Builtin help command */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "exec_cmd.h" #include "parse-options.h" diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 4ff567db4..dfb3d1296 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "config.h" #include "delta.h" #include "pack.h" #include "csum-file.h" diff --git a/builtin/init-db.c b/builtin/init-db.c index 8a6acb0ec..47823f9aa 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -4,6 +4,7 @@ * Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "refs.h" #include "builtin.h" #include "exec_cmd.h" diff --git a/builtin/log.c b/builtin/log.c index b3b10cc1e..b333d4fea 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -5,6 +5,7 @@ * 2006 Junio Hamano */ #include "cache.h" +#include "config.h" #include "refs.h" #include "color.h" #include "commit.h" diff --git a/builtin/ls-files.c b/builtin/ls-files.c index a6c70dbe9..975101078 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -6,6 +6,7 @@ * Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "quote.h" #include "dir.h" #include "builtin.h" diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c index d7ebeb4ce..4b53a8282 100644 --- a/builtin/ls-tree.c +++ b/builtin/ls-tree.c @@ -4,6 +4,7 @@ * Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "blob.h" #include "tree.h" #include "commit.h" diff --git a/builtin/merge-base.c b/builtin/merge-base.c index cfe2a796f..9c201cbfc 100644 --- a/builtin/merge-base.c +++ b/builtin/merge-base.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "diff.h" diff --git a/builtin/merge-file.c b/builtin/merge-file.c index 47dde7c39..b08803e61 100644 --- a/builtin/merge-file.c +++ b/builtin/merge-file.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "xdiff/xdiff.h" #include "xdiff-interface.h" #include "parse-options.h" diff --git a/builtin/merge.c b/builtin/merge.c index 703827f00..9bdd577e0 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -7,6 +7,7 @@ */ #include "cache.h" +#include "config.h" #include "parse-options.h" #include "builtin.h" #include "lockfile.h" diff --git a/builtin/mv.c b/builtin/mv.c index 61d20037a..dcf6736b5 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -4,6 +4,7 @@ * Copyright (C) 2006 Johannes Schindelin */ #include "builtin.h" +#include "config.h" #include "pathspec.h" #include "lockfile.h" #include "dir.h" diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 92a5d8a5d..c222daaa1 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "tag.h" #include "refs.h" diff --git a/builtin/notes.c b/builtin/notes.c index 7b891471c..dceb681ba 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -8,6 +8,7 @@ */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "notes.h" #include "blob.h" diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 0fe35d1b5..0e1718435 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "attr.h" #include "object.h" #include "blob.h" diff --git a/builtin/patch-id.c b/builtin/patch-id.c index 81552e02e..970d0d30b 100644 --- a/builtin/patch-id.c +++ b/builtin/patch-id.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "config.h" static void flush_current_id(int patchlen, struct object_id *id, struct object_id *result) { diff --git a/builtin/pull.c b/builtin/pull.c index dd1a4a94e..3632921f0 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -6,6 +6,7 @@ * Fetch one or more remote refs and merge it/them into the current HEAD. */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "parse-options.h" #include "exec_cmd.h" diff --git a/builtin/push.c b/builtin/push.c index a597759d8..76aa713d2 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -2,6 +2,7 @@ * "git push" */ #include "cache.h" +#include "config.h" #include "refs.h" #include "run-command.h" #include "builtin.h" diff --git a/builtin/read-tree.c b/builtin/read-tree.c index 23e212ee8..0a85b6d93 100644 --- a/builtin/read-tree.c +++ b/builtin/read-tree.c @@ -5,6 +5,7 @@ */ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "object.h" #include "tree.h" diff --git a/builtin/rebase--helper.c b/builtin/rebase--helper.c index ca1ebb2fa..c82b4dce6 100644 --- a/builtin/rebase--helper.c +++ b/builtin/rebase--helper.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "parse-options.h" #include "sequencer.h" diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index f96834f42..01ae7154e 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "config.h" #include "lockfile.h" #include "pack.h" #include "refs.h" diff --git a/builtin/reflog.c b/builtin/reflog.c index 747277577..6e9a8213e 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "config.h" #include "lockfile.h" #include "commit.h" #include "refs.h" diff --git a/builtin/remote.c b/builtin/remote.c index addf97ad2..a470ed7c6 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "config.h" #include "parse-options.h" #include "transport.h" #include "remote.h" diff --git a/builtin/repack.c b/builtin/repack.c index 677bc7c81..c01ff7c30 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "dir.h" #include "parse-options.h" #include "run-command.h" diff --git a/builtin/replace.c b/builtin/replace.c index ab17668f4..905b1759a 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -9,6 +9,7 @@ */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "refs.h" #include "parse-options.h" diff --git a/builtin/rerere.c b/builtin/rerere.c index 1bf72423b..ffb66e290 100644 --- a/builtin/rerere.c +++ b/builtin/rerere.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "dir.h" #include "parse-options.h" #include "string-list.h" diff --git a/builtin/reset.c b/builtin/reset.c index fc3b906c4..fdd5e5e00 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -8,6 +8,7 @@ * Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano */ #include "builtin.h" +#include "config.h" #include "lockfile.h" #include "tag.h" #include "object.h" diff --git a/builtin/rev-list.c b/builtin/rev-list.c index bcf77f0b8..f9e2caee1 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "commit.h" #include "diff.h" #include "revision.h" diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index 051333091..9d18bbd64 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -4,6 +4,7 @@ * Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "quote.h" diff --git a/builtin/revert.c b/builtin/revert.c index 345d9586a..16028b9ea 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "builtin.h" #include "parse-options.h" #include "diff.h" diff --git a/builtin/rm.c b/builtin/rm.c index fb79dcab1..b1adf1c96 100644 --- a/builtin/rm.c +++ b/builtin/rm.c @@ -4,6 +4,7 @@ * Copyright (C) Linus Torvalds 2006 */ #include "builtin.h" +#include "config.h" #include "lockfile.h" #include "dir.h" #include "cache-tree.h" diff --git a/builtin/send-pack.c b/builtin/send-pack.c index b8e2e74fe..633e0c3cd 100644 --- a/builtin/send-pack.c +++ b/builtin/send-pack.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "pkt-line.h" diff --git a/builtin/shortlog.c b/builtin/shortlog.c index 7cff1839f..43c4799ea 100644 --- a/builtin/shortlog.c +++ b/builtin/shortlog.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "diff.h" #include "string-list.h" diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 19756595d..682543997 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "builtin.h" diff --git a/builtin/stripspace.c b/builtin/stripspace.c index 1e62a008c..bdf032886 100644 --- a/builtin/stripspace.c +++ b/builtin/stripspace.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "parse-options.h" #include "strbuf.h" diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 566a5b6a6..700460c34 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "parse-options.h" #include "quote.h" #include "pathspec.h" diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c index 70addef15..df75cb9d4 100644 --- a/builtin/symbolic-ref.c +++ b/builtin/symbolic-ref.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "config.h" #include "cache.h" #include "refs.h" #include "parse-options.h" diff --git a/builtin/tag.c b/builtin/tag.c index bdf1e88e9..b85bcf680 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -7,6 +7,7 @@ */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "refs.h" #include "tag.h" diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c index 6fc6bcdf7..73f133419 100644 --- a/builtin/unpack-file.c +++ b/builtin/unpack-file.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "config.h" static char *create_temp_file(unsigned char *sha1) { diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c index 4532aa083..9da06548f 100644 --- a/builtin/unpack-objects.c +++ b/builtin/unpack-objects.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "object.h" #include "delta.h" #include "pack.h" diff --git a/builtin/update-index.c b/builtin/update-index.c index ebfc09faa..0a4c23648 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -4,6 +4,7 @@ * Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "quote.h" #include "cache-tree.h" diff --git a/builtin/update-ref.c b/builtin/update-ref.c index 0b2ecf41a..40ccfc193 100644 --- a/builtin/update-ref.c +++ b/builtin/update-ref.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "refs.h" #include "builtin.h" #include "parse-options.h" diff --git a/builtin/update-server-info.c b/builtin/update-server-info.c index 6c8cc3edc..873070e51 100644 --- a/builtin/update-server-info.c +++ b/builtin/update-server-info.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "builtin.h" #include "parse-options.h" diff --git a/builtin/var.c b/builtin/var.c index aedbb53a2..6c6f46b4a 100644 --- a/builtin/var.c +++ b/builtin/var.c @@ -4,6 +4,7 @@ * Copyright (C) Eric Biederman, 2005 */ #include "builtin.h" +#include "config.h" static const char var_usage[] = "git var (-l | )"; diff --git a/builtin/verify-commit.c b/builtin/verify-commit.c index 38bedf8f9..d5e9a17a7 100644 --- a/builtin/verify-commit.c +++ b/builtin/verify-commit.c @@ -6,6 +6,7 @@ * Based on git-verify-tag */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "commit.h" #include "run-command.h" diff --git a/builtin/verify-pack.c b/builtin/verify-pack.c index c94e15693..c2a1a5c50 100644 --- a/builtin/verify-pack.c +++ b/builtin/verify-pack.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "config.h" #include "run-command.h" #include "parse-options.h" diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c index 5199553d9..f9a5f7535 100644 --- a/builtin/verify-tag.c +++ b/builtin/verify-tag.c @@ -6,6 +6,7 @@ * Based on git-verify-tag.sh */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "tag.h" #include "run-command.h" diff --git a/builtin/worktree.c b/builtin/worktree.c index 1722a9bdc..d414b6870 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "builtin.h" #include "dir.h" #include "parse-options.h" diff --git a/builtin/write-tree.c b/builtin/write-tree.c index 084c0df78..bd0a78aa3 100644 --- a/builtin/write-tree.c +++ b/builtin/write-tree.c @@ -5,6 +5,7 @@ */ #include "builtin.h" #include "cache.h" +#include "config.h" #include "tree.h" #include "cache-tree.h" #include "parse-options.h" diff --git a/cache.h b/cache.h index 67efb47a1..160ff81aa 100644 --- a/cache.h +++ b/cache.h @@ -11,7 +11,6 @@ #include "string-list.h" #include "pack-revindex.h" #include "hash.h" -#include "config.h" #ifndef platform_SHA_CTX /* diff --git a/color.c b/color.c index dee61557e..31b6207a0 100644 --- a/color.c +++ b/color.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "color.h" static int git_use_color_default = GIT_COLOR_AUTO; diff --git a/column.c b/column.c index d55ead18e..ff7bdab1a 100644 --- a/column.c +++ b/column.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "column.h" #include "string-list.h" #include "parse-options.h" diff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c index 4293b53b1..de61c15d3 100644 --- a/compat/precompose_utf8.c +++ b/compat/precompose_utf8.c @@ -6,6 +6,7 @@ #define PRECOMPOSE_UNICODE_C #include "cache.h" +#include "config.h" #include "utf8.h" #include "precompose_utf8.h" diff --git a/config.c b/config.c index 3df7515db..eec7613e0 100644 --- a/config.c +++ b/config.c @@ -6,6 +6,7 @@ * */ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "exec_cmd.h" #include "strbuf.h" diff --git a/connect.c b/connect.c index cd21a1b6f..efddb30ea 100644 --- a/connect.c +++ b/connect.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "cache.h" +#include "config.h" #include "pkt-line.h" #include "quote.h" #include "refs.h" diff --git a/convert.c b/convert.c index 8d652bf27..69f23cfca 100644 --- a/convert.c +++ b/convert.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "attr.h" #include "run-command.h" #include "quote.h" diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c index 46c593752..2787b29c0 100644 --- a/credential-cache--daemon.c +++ b/credential-cache--daemon.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "tempfile.h" #include "credential.h" #include "unix-socket.h" diff --git a/credential.c b/credential.c index aa996669f..67a523353 100644 --- a/credential.c +++ b/credential.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "credential.h" #include "string-list.h" #include "run-command.h" diff --git a/daemon.c b/daemon.c index ac7181a48..30747075f 100644 --- a/daemon.c +++ b/daemon.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "pkt-line.h" #include "run-command.h" #include "strbuf.h" diff --git a/diff.c b/diff.c index 74283d900..4f9b9f838 100644 --- a/diff.c +++ b/diff.c @@ -2,6 +2,7 @@ * Copyright (C) 2005 Junio C Hamano */ #include "cache.h" +#include "config.h" #include "tempfile.h" #include "quote.h" #include "diff.h" diff --git a/dir.c b/dir.c index f451bfa48..42beb65be 100644 --- a/dir.c +++ b/dir.c @@ -8,6 +8,7 @@ * Junio Hamano, 2005-2006 */ #include "cache.h" +#include "config.h" #include "dir.h" #include "attr.h" #include "refs.h" diff --git a/environment.c b/environment.c index ff6e4f06e..9d9b36792 100644 --- a/environment.c +++ b/environment.c @@ -8,6 +8,7 @@ * are. */ #include "cache.h" +#include "config.h" #include "refs.h" #include "fmt-merge-msg.h" #include "commit.h" diff --git a/fast-import.c b/fast-import.c index cf58f875b..bbc3e79ea 100644 --- a/fast-import.c +++ b/fast-import.c @@ -154,6 +154,7 @@ Format of STDIN stream: #include "builtin.h" #include "cache.h" +#include "config.h" #include "lockfile.h" #include "object.h" #include "blob.h" diff --git a/fetch-pack.c b/fetch-pack.c index afb8b0502..963d45db9 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "refs.h" #include "pkt-line.h" diff --git a/git.c b/git.c index 58ef57029..c03de2c09 100644 --- a/git.c +++ b/git.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "config.h" #include "exec_cmd.h" #include "help.h" #include "run-command.h" diff --git a/gpg-interface.c b/gpg-interface.c index e44cc27da..8ab32df45 100644 --- a/gpg-interface.c +++ b/gpg-interface.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "run-command.h" #include "strbuf.h" #include "gpg-interface.h" diff --git a/graph.c b/graph.c index 8b9049dd2..e7e20650d 100644 --- a/graph.c +++ b/graph.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "commit.h" #include "color.h" #include "graph.h" diff --git a/grep.c b/grep.c index 47cee4506..d5211fc5a 100644 --- a/grep.c +++ b/grep.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "grep.h" #include "userdiff.h" #include "xdiff-interface.h" diff --git a/help.c b/help.c index 91ec8ab36..b8f3a98e4 100644 --- a/help.c +++ b/help.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "builtin.h" #include "exec_cmd.h" #include "levenshtein.h" diff --git a/http-backend.c b/http-backend.c index eef0a361f..109df44e3 100644 --- a/http-backend.c +++ b/http-backend.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "refs.h" #include "pkt-line.h" #include "object.h" diff --git a/http-fetch.c b/http-fetch.c index 3b556d661..8af380050 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "exec_cmd.h" #include "http.h" #include "walker.h" diff --git a/http.c b/http.c index d2e11ec6f..013bb0cc6 100644 --- a/http.c +++ b/http.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "http.h" +#include "config.h" #include "pack.h" #include "sideband.h" #include "run-command.h" diff --git a/ident.c b/ident.c index bea871c8e..d41fc9119 100644 --- a/ident.c +++ b/ident.c @@ -6,6 +6,7 @@ * Copyright (C) 2005 Linus Torvalds */ #include "cache.h" +#include "config.h" static struct strbuf git_default_name = STRBUF_INIT; static struct strbuf git_default_email = STRBUF_INIT; diff --git a/imap-send.c b/imap-send.c index 857591660..59e9b12d2 100644 --- a/imap-send.c +++ b/imap-send.c @@ -23,6 +23,7 @@ */ #include "cache.h" +#include "config.h" #include "credential.h" #include "exec_cmd.h" #include "run-command.h" diff --git a/ll-merge.c b/ll-merge.c index ac0d4a5d7..24ff94e1d 100644 --- a/ll-merge.c +++ b/ll-merge.c @@ -5,6 +5,7 @@ */ #include "cache.h" +#include "config.h" #include "attr.h" #include "xdiff-interface.h" #include "run-command.h" diff --git a/log-tree.c b/log-tree.c index 4618dd04c..282510b10 100644 --- a/log-tree.c +++ b/log-tree.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "diff.h" #include "commit.h" #include "tag.h" diff --git a/mailinfo.c b/mailinfo.c index 68037758f..aaed3870a 100644 --- a/mailinfo.c +++ b/mailinfo.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "utf8.h" #include "strbuf.h" #include "mailinfo.h" diff --git a/merge-recursive.c b/merge-recursive.c index 62decd51c..a85144c23 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -4,6 +4,7 @@ * The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006 */ #include "cache.h" +#include "config.h" #include "advice.h" #include "lockfile.h" #include "cache-tree.h" diff --git a/notes-utils.c b/notes-utils.c index 24a33616a..9d7fdd635 100644 --- a/notes-utils.c +++ b/notes-utils.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "notes-utils.h" diff --git a/notes.c b/notes.c index 542563b28..dbcfef4d7 100644 --- a/notes.c +++ b/notes.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "notes.h" #include "blob.h" #include "tree.h" diff --git a/pager.c b/pager.c index c113d898a..4dd9e1b26 100644 --- a/pager.c +++ b/pager.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "run-command.h" #include "sigchain.h" diff --git a/parse-options.c b/parse-options.c index a23a1e67f..cbf84a604 100644 --- a/parse-options.c +++ b/parse-options.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "parse-options.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "color.h" #include "utf8.h" diff --git a/pathspec.c b/pathspec.c index 50f76fff4..e4659b144 100644 --- a/pathspec.c +++ b/pathspec.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "dir.h" #include "pathspec.h" #include "attr.h" diff --git a/pretty.c b/pretty.c index d0f86f5d8..06a1f13c6 100644 --- a/pretty.c +++ b/pretty.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "commit.h" #include "utf8.h" #include "diff.h" diff --git a/prompt.c b/prompt.c index 75406390c..6d5885d00 100644 --- a/prompt.c +++ b/prompt.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "run-command.h" #include "strbuf.h" #include "prompt.h" diff --git a/read-cache.c b/read-cache.c index 0d0081a11..e623e075d 100644 --- a/read-cache.c +++ b/read-cache.c @@ -5,6 +5,7 @@ */ #define NO_THE_INDEX_COMPATIBILITY_MACROS #include "cache.h" +#include "config.h" #include "tempfile.h" #include "lockfile.h" #include "cache-tree.h" diff --git a/refs.c b/refs.c index df75f8e0d..c0cd25914 100644 --- a/refs.c +++ b/refs.c @@ -3,6 +3,7 @@ */ #include "cache.h" +#include "config.h" #include "hashmap.h" #include "lockfile.h" #include "iterator.h" diff --git a/refs/files-backend.c b/refs/files-backend.c index 83ea080e0..1d530f602 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -1,4 +1,5 @@ #include "../cache.h" +#include "../config.h" #include "../refs.h" #include "refs-internal.h" #include "ref-cache.h" diff --git a/remote-curl.c b/remote-curl.c index ece45993d..0053b0954 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "remote.h" #include "strbuf.h" #include "walker.h" diff --git a/remote.c b/remote.c index 801137c72..6ef03bb73 100644 --- a/remote.c +++ b/remote.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "remote.h" #include "refs.h" #include "commit.h" diff --git a/rerere.c b/rerere.c index 3bd55caf3..344d6aa81 100644 --- a/rerere.c +++ b/rerere.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "string-list.h" #include "rerere.h" diff --git a/send-pack.c b/send-pack.c index 78bb34ebe..ed3cee321 100644 --- a/send-pack.c +++ b/send-pack.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "pkt-line.h" diff --git a/sequencer.c b/sequencer.c index 10c3b4ff8..7356a9356 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "sequencer.h" #include "dir.h" diff --git a/setup.c b/setup.c index ba3241bf0..c45443f69 100644 --- a/setup.c +++ b/setup.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "dir.h" #include "string-list.h" diff --git a/sha1_file.c b/sha1_file.c index 59a4ed2ed..44561e0b9 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -7,6 +7,7 @@ * creation etc. */ #include "cache.h" +#include "config.h" #include "string-list.h" #include "lockfile.h" #include "delta.h" diff --git a/sha1_name.c b/sha1_name.c index 8eec9f7c1..7e1e86c97 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "tag.h" #include "commit.h" #include "tree.h" diff --git a/submodule-config.c b/submodule-config.c index 4f58491dd..d8f8d5ea3 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "submodule-config.h" #include "submodule.h" #include "strbuf.h" diff --git a/submodule.c b/submodule.c index d3299e29c..8cfcb3bed 100644 --- a/submodule.c +++ b/submodule.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "submodule-config.h" #include "submodule.h" #include "dir.h" diff --git a/t/helper/test-config.c b/t/helper/test-config.c index 8e3ed6a76..1a7b8bd3d 100644 --- a/t/helper/test-config.c +++ b/t/helper/test-config.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "string-list.h" /* diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c index 2f144d539..c6c57bba0 100644 --- a/t/helper/test-submodule-config.c +++ b/t/helper/test-submodule-config.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "submodule-config.h" #include "submodule.h" diff --git a/trailer.c b/trailer.c index 11f0b9fb4..751b56c00 100644 --- a/trailer.c +++ b/trailer.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "string-list.h" #include "run-command.h" #include "commit.h" diff --git a/transport.c b/transport.c index 4d33138a7..6096f8258 100644 --- a/transport.c +++ b/transport.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "transport.h" #include "run-command.h" #include "pkt-line.h" diff --git a/unpack-trees.c b/unpack-trees.c index aa15111fe..e7b5a21ef 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1,5 +1,6 @@ #define NO_THE_INDEX_COMPATIBILITY_MACROS #include "cache.h" +#include "config.h" #include "dir.h" #include "tree.h" #include "tree-walk.h" diff --git a/upload-pack.c b/upload-pack.c index ffb028d62..7581a5196 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "refs.h" #include "pkt-line.h" #include "sideband.h" diff --git a/userdiff.c b/userdiff.c index 8b732e40b..2c1502f71 100644 --- a/userdiff.c +++ b/userdiff.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "userdiff.h" #include "attr.h" diff --git a/versioncmp.c b/versioncmp.c index 9f81dc106..069ee94a4 100644 --- a/versioncmp.c +++ b/versioncmp.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "string-list.h" /* diff --git a/wrapper.c b/wrapper.c index d83741770..487a9f753 100644 --- a/wrapper.c +++ b/wrapper.c @@ -2,6 +2,7 @@ * Various trivial helper wrappers around standard functions */ #include "cache.h" +#include "config.h" static void do_nothing(size_t size) { diff --git a/xdiff-interface.c b/xdiff-interface.c index 060038c2d..5ac07d734 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "xdiff-interface.h" #include "xdiff/xtypes.h" #include "xdiff/xdiffi.h" -- cgit v1.2.1 From d3fb71b3cb36971608a46744261e6b5f8802e784 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Wed, 14 Jun 2017 11:07:37 -0700 Subject: setup: teach discover_git_directory to respect the commondir Currently 'discover_git_directory' only looks at the gitdir to determine if a git directory was discovered. This causes a problem in the event that the gitdir which was discovered was in fact a per-worktree git directory and not the common git directory. This is because the repository config, which is checked to verify the repository's format, is stored in the commondir and not in the per-worktree gitdir. Correct this behavior by checking the config stored in the commondir. It will also be of use for callers to have access to the commondir, so lets also return that upon successfully discovering a git directory. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- cache.h | 15 +++++++++------ config.c | 10 ++++++---- setup.c | 17 +++++++++++------ 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/cache.h b/cache.h index 160ff81aa..82f39f7a9 100644 --- a/cache.h +++ b/cache.h @@ -525,12 +525,15 @@ extern void set_git_work_tree(const char *tree); extern void setup_work_tree(void); /* - * Find GIT_DIR of the repository that contains the current working directory, - * without changing the working directory or other global state. The result is - * appended to gitdir. The return value is either NULL if no repository was - * found, or pointing to the path inside gitdir's buffer. - */ -extern const char *discover_git_directory(struct strbuf *gitdir); + * Find the commondir and gitdir of the repository that contains the current + * working directory, without changing the working directory or other global + * state. The result is appended to commondir and gitdir. If the discovered + * gitdir does not correspond to a worktree, then 'commondir' and 'gitdir' will + * both have the same result appended to the buffer. The return value is + * either 0 upon success and non-zero if no repository was found. + */ +extern int discover_git_directory(struct strbuf *commondir, + struct strbuf *gitdir); extern const char *setup_git_directory_gently(int *); extern const char *setup_git_directory(void); extern char *prefix_path(const char *prefix, int len, const char *path); diff --git a/config.c b/config.c index eec7613e0..e8dbf9e64 100644 --- a/config.c +++ b/config.c @@ -1639,7 +1639,8 @@ static void configset_iter(struct config_set *cs, config_fn_t fn, void *data) void read_early_config(config_fn_t cb, void *data) { struct config_options opts = {0}; - struct strbuf buf = STRBUF_INIT; + struct strbuf commondir = STRBUF_INIT; + struct strbuf gitdir = STRBUF_INIT; opts.respect_includes = 1; @@ -1653,12 +1654,13 @@ void read_early_config(config_fn_t cb, void *data) * notably, the current working directory is still the same after the * call). */ - else if (discover_git_directory(&buf)) - opts.git_dir = buf.buf; + else if (!discover_git_directory(&commondir, &gitdir)) + opts.git_dir = gitdir.buf; git_config_with_options(cb, data, NULL, &opts); - strbuf_release(&buf); + strbuf_release(&commondir); + strbuf_release(&gitdir); } static void git_config_check_init(void); diff --git a/setup.c b/setup.c index c45443f69..4e38cf2a4 100644 --- a/setup.c +++ b/setup.c @@ -941,19 +941,21 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir, } } -const char *discover_git_directory(struct strbuf *gitdir) +int discover_git_directory(struct strbuf *commondir, + struct strbuf *gitdir) { struct strbuf dir = STRBUF_INIT, err = STRBUF_INIT; size_t gitdir_offset = gitdir->len, cwd_len; + size_t commondir_offset = commondir->len; struct repository_format candidate; if (strbuf_getcwd(&dir)) - return NULL; + return -1; cwd_len = dir.len; if (setup_git_directory_gently_1(&dir, gitdir, 0) <= 0) { strbuf_release(&dir); - return NULL; + return -1; } /* @@ -969,8 +971,10 @@ const char *discover_git_directory(struct strbuf *gitdir) strbuf_insert(gitdir, gitdir_offset, dir.buf, dir.len); } + get_common_dir(commondir, gitdir->buf + gitdir_offset); + strbuf_reset(&dir); - strbuf_addf(&dir, "%s/config", gitdir->buf + gitdir_offset); + strbuf_addf(&dir, "%s/config", commondir->buf + commondir_offset); read_repository_format(&candidate, dir.buf); strbuf_release(&dir); @@ -978,11 +982,12 @@ const char *discover_git_directory(struct strbuf *gitdir) warning("ignoring git dir '%s': %s", gitdir->buf + gitdir_offset, err.buf); strbuf_release(&err); + strbuf_setlen(commondir, commondir_offset); strbuf_setlen(gitdir, gitdir_offset); - return NULL; + return -1; } - return gitdir->buf + gitdir_offset; + return 0; } const char *setup_git_directory_gently(int *nongit_ok) -- cgit v1.2.1 From a577fb5fdc53a4729eeedc2922d1461350b92f73 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Wed, 14 Jun 2017 11:07:38 -0700 Subject: config: respect commondir Worktrees present an interesting problem when it comes to the config. Historically we could assume that the per-repository config lives at 'gitdir/config', but since worktrees were introduced this isn't the case anymore. There is currently no way to specify per-worktree configuration, and as such the repository config is shared with all worktrees and is located at 'commondir/config'. Many users of the config machinery correctly set 'config_options.git_dir' with the repository's commondir, allowing the config to be properly loaded when operating in a worktree. But other's, like 'read_early_config()', set 'config_options.git_dir' with the repository's gitdir which can be incorrect when using worktrees. To fix this issue, and to make things less ambiguous, lets add a 'commondir' field to the 'config_options' struct and have all callers properly set both the 'git_dir' and 'commondir' fields so that the config machinery is able to properly find the repository's config. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- config.c | 11 +++++++---- config.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config.c b/config.c index e8dbf9e64..edc0d1770 100644 --- a/config.c +++ b/config.c @@ -1531,8 +1531,8 @@ static int do_git_config_sequence(const struct config_options *opts, char *user_config = expand_user_path("~/.gitconfig", 0); char *repo_config; - if (opts->git_dir) - repo_config = mkpathdup("%s/config", opts->git_dir); + if (opts->commondir) + repo_config = mkpathdup("%s/config", opts->commondir); else if (have_git_dir()) repo_config = git_pathdup("config"); else @@ -1644,7 +1644,8 @@ void read_early_config(config_fn_t cb, void *data) opts.respect_includes = 1; - if (have_git_dir()) + if (have_git_dir()) { + opts.commondir = get_git_common_dir(); opts.git_dir = get_git_dir(); /* * When setup_git_directory() was not yet asked to discover the @@ -1654,8 +1655,10 @@ void read_early_config(config_fn_t cb, void *data) * notably, the current working directory is still the same after the * call). */ - else if (!discover_git_directory(&commondir, &gitdir)) + } else if (!discover_git_directory(&commondir, &gitdir)) { + opts.commondir = commondir.buf; opts.git_dir = gitdir.buf; + } git_config_with_options(cb, data, NULL, &opts); diff --git a/config.h b/config.h index c70599bd5..63b92784c 100644 --- a/config.h +++ b/config.h @@ -30,6 +30,7 @@ enum config_origin_type { struct config_options { unsigned int respect_includes : 1; + const char *commondir; const char *git_dir; }; -- cgit v1.2.1 From dc8441fdb4598f54865a5c783d1f86c1e0bcb6dc Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Wed, 14 Jun 2017 11:07:39 -0700 Subject: config: don't implicitly use gitdir or commondir 'git_config_with_options()' takes a 'config_options' struct which contains feilds for 'git_dir' and 'commondir'. If those feilds happen to be NULL the config machinery falls back to querying global repository state. Let's change this and instead use these fields in the 'config_options' struct explicilty all the time. Since the API is slightly changing to require these two fields to be set if callers want the config machinery to load the repository's config, let's change the name to 'config_with_optison()'. This allows the config machinery to not implicitly rely on any global repository state. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- builtin/config.c | 26 +++++++++++++++----------- config.c | 21 +++++++++++---------- config.h | 6 +++--- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/builtin/config.c b/builtin/config.c index b2045cd6c..1fc6471f3 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -243,8 +243,8 @@ static int get_value(const char *key_, const char *regex_) } } - git_config_with_options(collect_config, &values, - &given_config_source, &config_options); + config_with_options(collect_config, &values, + &given_config_source, &config_options); ret = !values.nr; @@ -321,8 +321,8 @@ static void get_color(const char *var, const char *def_color) get_color_slot = var; get_color_found = 0; parsed_color[0] = '\0'; - git_config_with_options(git_get_color_config, NULL, - &given_config_source, &config_options); + config_with_options(git_get_color_config, NULL, + &given_config_source, &config_options); if (!get_color_found && def_color) { if (color_parse(def_color, parsed_color) < 0) @@ -353,8 +353,8 @@ static int get_colorbool(const char *var, int print) get_colorbool_found = -1; get_diff_color_found = -1; get_color_ui_found = -1; - git_config_with_options(git_get_colorbool_config, NULL, - &given_config_source, &config_options); + config_with_options(git_get_colorbool_config, NULL, + &given_config_source, &config_options); if (get_colorbool_found < 0) { if (!strcmp(get_colorbool_slot, "color.diff")) @@ -442,8 +442,8 @@ static int get_urlmatch(const char *var, const char *url) show_keys = 1; } - git_config_with_options(urlmatch_config_entry, &config, - &given_config_source, &config_options); + config_with_options(urlmatch_config_entry, &config, + &given_config_source, &config_options); ret = !values.nr; @@ -536,6 +536,10 @@ int cmd_config(int argc, const char **argv, const char *prefix) config_options.respect_includes = !given_config_source.file; else config_options.respect_includes = respect_includes_opt; + if (!nongit) { + config_options.commondir = get_git_common_dir(); + config_options.git_dir = get_git_dir(); + } if (end_null) { term = '\0'; @@ -580,9 +584,9 @@ int cmd_config(int argc, const char **argv, const char *prefix) if (actions == ACTION_LIST) { check_argc(argc, 0, 0); - if (git_config_with_options(show_all_config, NULL, - &given_config_source, - &config_options) < 0) { + if (config_with_options(show_all_config, NULL, + &given_config_source, + &config_options) < 0) { if (given_config_source.file) die_errno("unable to read config file '%s'", given_config_source.file); diff --git a/config.c b/config.c index edc0d1770..ca9e9efec 100644 --- a/config.c +++ b/config.c @@ -218,8 +218,6 @@ static int include_by_gitdir(const struct config_options *opts, if (opts->git_dir) git_dir = opts->git_dir; - else if (have_git_dir()) - git_dir = get_git_dir(); else goto done; @@ -1533,8 +1531,6 @@ static int do_git_config_sequence(const struct config_options *opts, if (opts->commondir) repo_config = mkpathdup("%s/config", opts->commondir); - else if (have_git_dir()) - repo_config = git_pathdup("config"); else repo_config = NULL; @@ -1565,9 +1561,9 @@ static int do_git_config_sequence(const struct config_options *opts, return ret; } -int git_config_with_options(config_fn_t fn, void *data, - struct git_config_source *config_source, - const struct config_options *opts) +int config_with_options(config_fn_t fn, void *data, + struct git_config_source *config_source, + const struct config_options *opts) { struct config_include_data inc = CONFIG_INCLUDE_INIT; @@ -1598,9 +1594,14 @@ static void git_config_raw(config_fn_t fn, void *data) struct config_options opts = {0}; opts.respect_includes = 1; - if (git_config_with_options(fn, data, NULL, &opts) < 0) + if (have_git_dir()) { + opts.commondir = get_git_common_dir(); + opts.git_dir = get_git_dir(); + } + + if (config_with_options(fn, data, NULL, &opts) < 0) /* - * git_config_with_options() normally returns only + * config_with_options() normally returns only * zero, as most errors are fatal, and * non-fatal potential errors are guarded by "if" * statements that are entered only when no error is @@ -1660,7 +1661,7 @@ void read_early_config(config_fn_t cb, void *data) opts.git_dir = gitdir.buf; } - git_config_with_options(cb, data, NULL, &opts); + config_with_options(cb, data, NULL, &opts); strbuf_release(&commondir); strbuf_release(&gitdir); diff --git a/config.h b/config.h index 63b92784c..9e038cce2 100644 --- a/config.h +++ b/config.h @@ -45,9 +45,9 @@ extern void git_config_push_parameter(const char *text); extern int git_config_from_parameters(config_fn_t fn, void *data); extern void read_early_config(config_fn_t cb, void *data); extern void git_config(config_fn_t fn, void *); -extern int git_config_with_options(config_fn_t fn, void *, - struct git_config_source *config_source, - const struct config_options *opts); +extern int config_with_options(config_fn_t fn, void *, + struct git_config_source *config_source, + const struct config_options *opts); extern int git_parse_ulong(const char *, unsigned long *); extern int git_parse_maybe_bool(const char *); extern int git_config_int(const char *, const char *); -- cgit v1.2.1