config.h
cover config.h
After some discussion I realized that my 'repository object' series was getting to be rather long and increase in scope. So I've decided to break off these couple patches into their own series so they can be reviewed more easily. This should also let them be merged in faster as I suspect it'll take a while for my 'repository object' series to be reviewed thourouly and these couple patches could result in a lot of merge conflicts as it touches a lot of files.
Brandon Williams (4):
config: create config.h
config: remove git_config_iter
config: don't include config.h by default
config: don't implicitly use gitdir
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 | 2 + 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 | 3 + 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 | 189 -------------------------------------- color.c | 1 + column.c | 1 + config.c | 7 +- config.h | 193 +++++++++++++++++++++++++++++++++++++++ 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, 342 insertions(+), 193 deletions(-) create mode 100644 config.h
Signature · 1 line
2.13.1.518.g3df882009-goog
PATCH 1/4 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.
--- cache.h | 190 +------------------------------------------------------------ config.h | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+), 189 deletions(-) create mode 100644 config.h
cache.h +1 -189
@@ -11,6 +11,7 @@#include "string-list.h" #include "pack-revindex.h" #include "hash.h" +#include "config.h" #ifndef platform_SHA_CTX/*
@@ -1872,188 +1873,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.
@@ -2061,16 +1883,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 );
config.h new file +194 -0
194 lines not on this page · raw message
Signature · 1 line
2.13.1.518.g3df882009-goog
PATCH 2/4 config: remove git_config_iter
In reply to Brandon WilliamsSince there is no implementation of the function 'git_config_iter' lets stop exporting it and remove the prototype from config.h.
--- config.h | 1 - 1 file changed, 1 deletion(-)
config.h +0 -1
@@ -165,7 +165,6 @@ extern int git_configset_get_pathname(struct config_set *cs, const char *key, coextern 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);
Signature · 1 line
2.13.1.518.g3df882009-goog
Re: [PATCH 2/4] config: remove git_config_iter
(+tanayabh)
Hi,
Quoted 7 lines · Brandon Williams
Since there is no implementation of the function '
git_config_iter' lets stop exporting it and remove the prototype fromconfig.h.Signed-off-by Brandon Williams <[email protected]>--- config.h | 1 - 1 file changed, 1 deletion(-)
Good eyes. Looks like the function never existed.
Quoted 12 lines
config.h +0
-1@@ -165,7 +165,6 @@ extern int git_configset_get_pathname(struct config_set *cs, const char *key, coextern 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);
Re: [PATCH 2/4] config: remove git_config_iter
Quoted 9 lines · Jonathan Nieder
Quoted 7 lines
Since there is no implementation of the function '
git_config_iter' lets stop exporting it and remove the prototype fromconfig.h.Signed-off-by Brandon Williams <[email protected]>--- config.h | 1 - 1 file changed, 1 deletion(-)Good eyes. Looks like the function never existed.
You can find mention of it on the list[1,2] in early versions of Tanay's patches. I think it was originally intended to be a variant of git_config() that used the cache. But in the end, we made git_config() do that by default (and added git_config_raw as its underlying helper).
I just looked that up to satisfy my curiosity. You are right that its implementation never actually got committed, and clearly removing the declaration is the right thing.
-Peff
PATCH 3/4 config: don't include config.h by default
In reply to Brandon WilliamsStop including config.h by default in cache.h. Instead only include config.h in those files which require use of the config system.
--- 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 | 2 ++ 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 + 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 + 145 files changed, 145 insertions(+), 1 deletion(-)
advice.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" int advice_push_update_rejected =1 ;int advice_push_non_ff_current =1 ;
alias.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" char *alias_lookup (const char *alias) {
apply.c +1 -0
@@ -8,6 +8,7 @@*/ #include "cache.h" +#include "config.h" #include "blob.h" #include "delta.h" #include "diff.h"
archive-tar.c +1 -0
@@ -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"
archive-zip.c +1 -0
@@ -2,6 +2,7 @@* Copyright (c) 2006 Rene Scharfe */ #include "cache.h" +#include "config.h" #include "archive.h" #include "streaming.h" #include "utf8.h"
archive.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "refs.h" #include "commit.h" #include "tree-walk.h"
attr.c +1 -0
@@ -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"
bisect.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "diff.h" #include "revision.h"
branch.c +1 -0
@@ -1,5 +1,6 @@#include "git-compat-util.h" #include "cache.h" +#include "config.h" #include "branch.h" #include "refs.h" #include "remote.h"
builtin/add.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) 2006 Linus Torvalds */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "lockfile.h" #include "dir.h"
builtin/am.c +1 -0
@@ -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"
builtin/blame.c +2 -0
@@ -6,6 +6,8 @@*/ #include "cache.h" +#include "config.h" +#include "refs.h" #include "builtin.h" #include "commit.h" #include "diff.h"
builtin/branch.c +1 -0
@@ -6,6 +6,7 @@*/ #include "cache.h" +#include "config.h" #include "color.h" #include "refs.h" #include "commit.h"
builtin/cat-file.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "diff.h" #include "parse-options.h"
builtin/check-attr.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "attr.h" #include "quote.h" #include "parse-options.h"
builtin/check-ignore.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "dir.h" #include "quote.h" #include "pathspec.h"
builtin/check-mailmap.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "mailmap.h" #include "parse-options.h" #include "string-list.h"
builtin/checkout-index.c +1 -0
@@ -5,6 +5,7 @@* */ #include "builtin.h" +#include "config.h" #include "lockfile.h" #include "quote.h" #include "cache-tree.h"
builtin/checkout.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "lockfile.h" #include "parse-options.h" #include "refs.h"
builtin/clean.c +1 -0
@@ -8,6 +8,7 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "dir.h" #include "parse-options.h" #include "string-list.h"
builtin/clone.c +1 -0
@@ -9,6 +9,7 @@*/ #include "builtin.h" +#include "config.h" #include "lockfile.h" #include "parse-options.h" #include "fetch-pack.h"
builtin/column.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "strbuf.h" #include "parse-options.h" #include "string-list.h"
builtin/commit-tree.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "commit.h" #include "tree.h" #include "builtin.h"
builtin/commit.c +1 -0
@@ -6,6 +6,7 @@*/ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "cache-tree.h" #include "color.h"
builtin/config.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "color.h" #include "parse-options.h" #include "urlmatch.h"
builtin/count-objects.c +1 -0
@@ -5,6 +5,7 @@*/ #include "cache.h" +#include "config.h" #include "dir.h" #include "builtin.h" #include "parse-options.h"
builtin/describe.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "lockfile.h" #include "commit.h" #include "tag.h"
builtin/diff-files.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "diff.h" #include "commit.h" #include "revision.h"
builtin/diff-index.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "diff.h" #include "commit.h" #include "revision.h"
builtin/diff-tree.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "diff.h" #include "commit.h" #include "log-tree.h"
builtin/diff.c +1 -0
@@ -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"
builtin/difftool.c +1 -0
@@ -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"
builtin/fast-export.c +1 -0
@@ -5,6 +5,7 @@*/ #include "builtin.h" #include "cache.h" +#include "config.h" #include "refs.h" #include "commit.h" #include "object.h"
builtin/fetch.c +1 -0
@@ -2,6 +2,7 @@* "git fetch" */ #include "cache.h" +#include "config.h" #include "refs.h" #include "commit.h" #include "builtin.h"
builtin/fmt-merge-msg.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "refs.h" #include "commit.h" #include "diff.h"
builtin/for-each-ref.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "refs.h" #include "object.h" #include "parse-options.h"
builtin/fsck.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "tree.h" #include "blob.h"
builtin/gc.c +1 -0
@@ -11,6 +11,7 @@*/ #include "builtin.h" +#include "config.h" #include "tempfile.h" #include "lockfile.h" #include "parse-options.h"
builtin/grep.c +1 -0
@@ -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"
builtin/hash-object.c +1 -0
@@ -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"
builtin/help.c +1 -0
@@ -2,6 +2,7 @@* Builtin help command */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "exec_cmd.h" #include "parse-options.h"
builtin/index-pack.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "delta.h" #include "pack.h" #include "csum-file.h"
builtin/init-db.c +1 -0
@@ -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"
builtin/log.c +1 -0
@@ -5,6 +5,7 @@* 2006 Junio Hamano */ #include "cache.h" +#include "config.h" #include "refs.h" #include "color.h" #include "commit.h"
builtin/ls-files.c +1 -0
@@ -6,6 +6,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "quote.h" #include "dir.h" #include "builtin.h"
builtin/ls-tree.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "blob.h" #include "tree.h" #include "commit.h"
builtin/merge-base.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "diff.h"
builtin/merge-file.c +1 -0
@@ -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"
builtin/merge.c +1 -0
@@ -7,6 +7,7 @@*/ #include "cache.h" +#include "config.h" #include "parse-options.h" #include "builtin.h" #include "lockfile.h"
builtin/mv.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) 2006 Johannes Schindelin */ #include "builtin.h" +#include "config.h" #include "pathspec.h" #include "lockfile.h" #include "dir.h"
builtin/name-rev.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "tag.h" #include "refs.h"
builtin/notes.c +1 -0
@@ -8,6 +8,7 @@*/ #include "cache.h" +#include "config.h" #include "builtin.h" #include "notes.h" #include "blob.h"
builtin/pack-objects.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "attr.h" #include "object.h" #include "blob.h"
builtin/patch-id.c +1 -0
@@ -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) {
builtin/pull.c +1 -0
@@ -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"
builtin/push.c +1 -0
@@ -2,6 +2,7 @@* "git push" */ #include "cache.h" +#include "config.h" #include "refs.h" #include "run-command.h" #include "builtin.h"
builtin/read-tree.c +1 -0
@@ -5,6 +5,7 @@*/ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "object.h" #include "tree.h"
builtin/rebase--helper.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "parse-options.h" #include "sequencer.h"
builtin/receive-pack.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "lockfile.h" #include "pack.h" #include "refs.h"
builtin/reflog.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "lockfile.h" #include "commit.h" #include "refs.h"
builtin/remote.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "parse-options.h" #include "transport.h" #include "remote.h"
builtin/repack.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "dir.h" #include "parse-options.h" #include "run-command.h"
builtin/replace.c +1 -0
@@ -9,6 +9,7 @@*/ #include "cache.h" +#include "config.h" #include "builtin.h" #include "refs.h" #include "parse-options.h"
builtin/rerere.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "dir.h" #include "parse-options.h" #include "string-list.h"
builtin/reset.c +1 -0
@@ -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"
builtin/rev-list.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "diff.h" #include "revision.h"
builtin/rev-parse.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "quote.h"
builtin/revert.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "builtin.h" #include "parse-options.h" #include "diff.h"
builtin/rm.c +1 -0
@@ -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"
builtin/send-pack.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "pkt-line.h"
builtin/shortlog.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "diff.h" #include "string-list.h"
builtin/show-branch.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "builtin.h"
builtin/stripspace.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "parse-options.h" #include "strbuf.h"
builtin/submodule--helper.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "parse-options.h" #include "quote.h" #include "pathspec.h"
builtin/symbolic-ref.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "cache.h" #include "refs.h" #include "parse-options.h"
builtin/tag.c +1 -0
@@ -7,6 +7,7 @@*/ #include "cache.h" +#include "config.h" #include "builtin.h" #include "refs.h" #include "tag.h"
builtin/unpack-file.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" static char *create_temp_file (unsigned char *sha1) {
builtin/unpack-objects.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "object.h" #include "delta.h" #include "pack.h"
builtin/update-index.c +1 -0
@@ -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"
builtin/update-ref.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "refs.h" #include "builtin.h" #include "parse-options.h"
builtin/update-server-info.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "builtin.h" #include "parse-options.h"
builtin/var.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Eric Biederman, 2005 */ #include "builtin.h" +#include "config.h" static const char var_usage[] ="git var (-l | <variable>)" ;
builtin/verify-commit.c +1 -0
@@ -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"
builtin/verify-pack.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "run-command.h" #include "parse-options.h"
builtin/verify-tag.c +1 -0
@@ -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"
builtin/worktree.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "builtin.h" #include "dir.h" #include "parse-options.h"
builtin/write-tree.c +1 -0
@@ -5,6 +5,7 @@*/ #include "builtin.h" #include "cache.h" +#include "config.h" #include "tree.h" #include "cache-tree.h" #include "parse-options.h"
cache.h +0 -1
@@ -11,7 +11,6 @@#include "string-list.h" #include "pack-revindex.h" #include "hash.h" -#include "config.h" #ifndef platform_SHA_CTX/*
color.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "color.h" static int git_use_color_default =GIT_COLOR_AUTO ;
column.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "column.h" #include "string-list.h" #include "parse-options.h"
config.c +1 -0
@@ -6,6 +6,7 @@* */ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "exec_cmd.h" #include "strbuf.h"
connect.c +1 -0
@@ -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"
convert.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "attr.h" #include "run-command.h" #include "quote.h"
credential-cache--daemon.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "tempfile.h" #include "credential.h" #include "unix-socket.h"
credential.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "credential.h" #include "string-list.h" #include "run-command.h"
daemon.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "pkt-line.h" #include "run-command.h" #include "strbuf.h"
diff.c +1 -0
@@ -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"
dir.c +1 -0
@@ -9,6 +9,7 @@*/ #define NO_THE_INDEX_COMPATIBILITY_MACROS #include "cache.h" +#include "config.h" #include "dir.h" #include "attr.h" #include "refs.h"
environment.c +1 -0
@@ -8,6 +8,7 @@* are. */ #include "cache.h" +#include "config.h" #include "refs.h" #include "fmt-merge-msg.h" #include "commit.h"
fast-import.c +1 -0
@@ -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"
fetch-pack.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "lockfile.h" #include "refs.h" #include "pkt-line.h"
git.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "exec_cmd.h" #include "help.h" #include "run-command.h"
gpg-interface.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "run-command.h" #include "strbuf.h" #include "gpg-interface.h"
graph.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "color.h" #include "graph.h"
grep.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "grep.h" #include "userdiff.h" #include "xdiff-interface.h"
help.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "builtin.h" #include "exec_cmd.h" #include "run-command.h"
http-backend.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "refs.h" #include "pkt-line.h" #include "object.h"
http-fetch.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "exec_cmd.h" #include "http.h" #include "walker.h"
http.c +1 -0
@@ -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"
ident.c +1 -0
@@ -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 ;
imap-send.c +1 -0
@@ -23,6 +23,7 @@*/ #include "cache.h" +#include "config.h" #include "credential.h" #include "exec_cmd.h" #include "run-command.h"
ll-merge.c +1 -0
@@ -5,6 +5,7 @@*/ #include "cache.h" +#include "config.h" #include "attr.h" #include "xdiff-interface.h" #include "run-command.h"
log-tree.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "diff.h" #include "commit.h" #include "tag.h"
mailinfo.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "utf8.h" #include "strbuf.h" #include "mailinfo.h"
merge-recursive.c +1 -0
@@ -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"
notes-utils.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "notes-utils.h"
notes.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "notes.h" #include "blob.h" #include "tree.h"
pager.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "run-command.h" #include "sigchain.h"
parse-options.c +1 -0
@@ -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"
pathspec.c +1 -0
@@ -1,5 +1,6 @@#define NO_THE_INDEX_COMPATIBILITY_MACROS #include "cache.h" +#include "config.h" #include "dir.h" #include "pathspec.h" #include "attr.h"
pretty.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "utf8.h" #include "diff.h"
prompt.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "run-command.h" #include "strbuf.h" #include "prompt.h"
read-cache.c +1 -0
@@ -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"
refs.c +1 -0
@@ -3,6 +3,7 @@*/ #include "cache.h" +#include "config.h" #include "hashmap.h" #include "lockfile.h" #include "iterator.h"
refs/files-backend.c +1 -0
@@ -1,4 +1,5 @@#include "../cache.h" +#include "../config.h" #include "../refs.h" #include "refs-internal.h" #include "ref-cache.h"
remote-curl.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "remote.h" #include "strbuf.h" #include "walker.h"
remote.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "remote.h" #include "refs.h" #include "commit.h"
rerere.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "lockfile.h" #include "string-list.h" #include "rerere.h"
send-pack.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "pkt-line.h"
sequencer.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "lockfile.h" #include "sequencer.h" #include "dir.h"
setup.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "dir.h" #include "string-list.h"
sha1_file.c +1 -0
@@ -7,6 +7,7 @@* creation etc. */ #include "cache.h" +#include "config.h" #include "string-list.h" #include "lockfile.h" #include "delta.h"
sha1_name.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "tag.h" #include "commit.h" #include "tree.h"
submodule-config.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "submodule-config.h" #include "submodule.h" #include "strbuf.h"
submodule.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "submodule-config.h" #include "submodule.h" #include "dir.h"
t/helper/test-config.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "string-list.h" /*
t/helper/test-submodule-config.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "submodule-config.h" #include "submodule.h"
trailer.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "string-list.h" #include "run-command.h" #include "commit.h"
transport.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "transport.h" #include "run-command.h" #include "pkt-line.h"
unpack-trees.c +1 -0
@@ -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"
upload-pack.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "refs.h" #include "pkt-line.h" #include "sideband.h"
userdiff.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "userdiff.h" #include "attr.h"
versioncmp.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "string-list.h" /*
wrapper.c +1 -0
@@ -2,6 +2,7 @@* Various trivial helper wrappers around standard functions */ #include "cache.h" +#include "config.h" static void do_nothing (size_t size) {
xdiff-interface.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "xdiff-interface.h" #include "xdiff/xtypes.h" #include "xdiff/xdiffi.h"
Signature · 1 line
2.13.1.518.g3df882009-goog
PATCH 4/4 config: don't implicitly use gitdir
In reply to Brandon WilliamsCommit 2185fde56 (config: handle conditional include when $GIT_DIR is not set up) added a 'git_dir' field to the config_options struct. Let's use this option field explicitly all the time instead of occasionally falling back to calling 'git_pathdup("config")' to get the path to the local repository configuration. This allows 'do_git_config_sequence()' to not implicitly rely on global repository state.
--- builtin/config.c | 2 ++ config.c | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-)
builtin/config.c +2 -0
@@ -539,6 +539,8 @@ 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 (have_git_dir ()) + config_options.git_dir =get_git_common_dir ();if (end_null) { term ='\0' ;
config.c +2 -4
@@ -219,8 +219,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;
@@ -1548,8 +1546,6 @@ static int do_git_config_sequence(const struct config_options *opts,if (opts->git_dir) repo_config =mkpathdup ("%s/config" , opts->git_dir); -else if (have_git_dir ()) - repo_config =git_pathdup ("config" );else repo_config =NULL ;
@@ -1613,6 +1609,8 @@ static void git_config_raw(config_fn_t fn, void *data)struct config_options opts = {0 }; opts.respect_includes =1 ; +if (have_git_dir ()) + opts.git_dir =get_git_common_dir ();if (git_config_with_options (fn, data,NULL , &opts) <0 )/* * git_config_with_options() normally returns only
Signature · 1 line
2.13.1.518.g3df882009-goog
Re: [PATCH 4/4] config: don't implicitly use gitdir
Hi,
Quoted 7 lines · Brandon Williams
Commit
2185fde56(config: handle conditional include when $GIT_DIR is not set up) added a 'git_dir' field to theconfig_optionsstruct. Let's use this option field explicitly all the time instead of occasionally falling back to calling 'git_pathdup("config")' to get the path to the local repository configuration. This allows 'do_git_config_sequence()' to not implicitly rely on global repository state.
Quoted 5 lines
Signed-off-by Brandon Williams <[email protected]>--- builtin/config.c | 2 ++ config.c | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-)
Unlike the previous 3, this one makes me pause for a moment: it means that "gitdir:" includes and .git/config discovery would stop working if the caller does not remember to set git_dir in their config_options.
So we have to inspect callers.
Callers that set respect_includes = 1:
- read_early_config carefully sets git_dir *phew*
- git_config_raw doesn't and is used approximately everywhere.
do_git_config_sequence call chain:
- called by git_config_with_options, which is called by
- read_early_config
- git_config_raw
- various callers in builtin/config.c, using &config_options
builtin/config.c int cmd_config(int argc, const char **argv, const char *prefix) · line 543
Quoted 8 lines
builtin/config.c +2
-0@@ -539,6 +539,8 @@ 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 (have_git_dir ()) + config_options.git_dir =get_git_common_dir ();
nit: because of the context, this 'if' can be "if (!nongit)".
[...]
config.c static int include_by_gitdir(const struct config_options *opts, · line 223
Quoted 10 lines
config.c +0
-2@@ -219,8 +219,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;
I wonder if this should have a sanity-check:
else if (have_git_dir())
BUG("caller forgot to set opts->git_dir");Alternatively, could this patch rename git_config_with_options? That way any other patch in flight that calls git_config_with_options would conflict with this patch, giving us an opportunity to make sure it also sets git_dir. As another nice side benefit it would make it easy for someone reading the patch to verify it didn't miss any callers.
config.c static int do_git_config_sequence(const struct config_options *opts, · line 1550
Quoted 8 lines
config.c +0
-2@@ -1548,8 +1546,6 @@ static int do_git_config_sequence(const struct config_options *opts,if (opts->git_dir) repo_config =mkpathdup ("%s/config" , opts->git_dir); -else if (have_git_dir ()) - repo_config =git_pathdup ("config" );else repo_config =NULL ;
Likewise: either this should get a sanity check
else if (have_git_dir())
BUG("caller forgot to set opts->git_dir");or the public interface git_config_with_options should be renamed.
config.c static void git_config_raw(config_fn_t fn, void *data) · line 1613
Quoted 6 lines
config.c +2
-0@@ -1613,6 +1609,8 @@ static void git_config_raw(config_fn_t fn, void *data)struct config_options opts = {0 }; opts.respect_includes =1 ; +if (have_git_dir ()) + opts.git_dir =get_git_common_dir ();
curious: Why get_git_common_dir() instead of get_git_dir()?
Thanks,
Jonathan
Re: [PATCH 4/4] config: don't implicitly use gitdir
Quoted 35 lines · Jonathan Nieder
Hi,
Quoted 7 lines · Brandon Williams
Commit
2185fde56(config: handle conditional include when $GIT_DIR is not set up) added a 'git_dir' field to theconfig_optionsstruct. Let's use this option field explicitly all the time instead of occasionally falling back to calling 'git_pathdup("config")' to get the path to the local repository configuration. This allows 'do_git_config_sequence()' to not implicitly rely on global repository state.Quoted 5 lines
Signed-off-by Brandon Williams <[email protected]>--- builtin/config.c | 2 ++ config.c | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-)Unlike the previous 3, this one makes me pause for a moment: it means that "gitdir:" includes and .git/config discovery would stop working if the caller does not remember to set
git_dirin theirconfig_options.So we have to inspect callers.
Callers that set
respect_includes= 1:-
read_early_configcarefully setsgit_dir*phew*
-git_config_rawdoesn't and is used approximately everywhere.
do_git_config_sequencecall chain:
- called bygit_config_with_options, which is called by
-read_early_config
-git_config_raw
- various callers inbuiltin/config.c, using&config_options
Quoted 10 lines
builtin/config.c int cmd_config(int argc, const char **argv, const char *prefix) · line 543
Quoted 8 lines
builtin/config.c +2
-0@@ -539,6 +539,8 @@ 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 (have_git_dir ()) + config_options.git_dir =get_git_common_dir ();nit: because of the context, this 'if' can be "if (!nongit)".
Will do.
Quoted 15 lines
[...]
config.c static int include_by_gitdir(const struct config_options *opts, · line 223
Quoted 10 lines
config.c +0
-2@@ -219,8 +219,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;I wonder if this should have a sanity-check:
Quoted 8 lines
else if (have_git_dir()) BUG("caller forgot to set opts->git_dir");Alternatively, could this patch rename
git_config_with_options? That way any other patch in flight that callsgit_config_with_optionswould conflict with this patch, giving us an opportunity to make sure it also setsgit_dir. As another nice side benefit it would make it easy for someone reading the patch to verify it didn't miss any callers.
That kind of defeats the purpose of the patch. The point is to not rely on global repository state and with the BUG statement we still are relying on global state.
And I don't know if I agree with renaming a function just to rename it.
Quoted 17 lines
config.c static int do_git_config_sequence(const struct config_options *opts, · line 1550
Quoted 9 lines
config.c +0
-2@@ -1548,8 +1546,6 @@ static int do_git_config_sequence(const struct config_options *opts,if (opts->git_dir) repo_config =mkpathdup ("%s/config" , opts->git_dir); -else if (have_git_dir ()) - repo_config =git_pathdup ("config" );else repo_config =NULL ;Likewise: either this should get a sanity check
else if (have_git_dir()) BUG("caller forgot to set opts->git_dir");or the public interface
git_config_with_optionsshould be renamed.
Quoted 8 lines
config.c static void git_config_raw(config_fn_t fn, void *data) · line 1613
Quoted 6 lines
config.c +2
-0@@ -1613,6 +1609,8 @@ static void git_config_raw(config_fn_t fn, void *data)struct config_options opts = {0 }; opts.respect_includes =1 ; +if (have_git_dir ()) + opts.git_dir =get_git_common_dir ();curious: Why
get_git_common_dir()instead ofget_git_dir()?
Needs to be commondir since the config is stored in the common git directory and not a per worktree git directory.
Signature · 1 line
Brandon Williams
Re: [PATCH 4/4] config: don't implicitly use gitdir
Quoted 11 lines · Brandon Williams
Quoted 10 lines · Jonathan Nieder
Quoted 8 lines · Brandon Williams
Commit
2185fde56(config: handle conditional include when $GIT_DIR is not set up) added a 'git_dir' field to theconfig_optionsstruct. Let's use this option field explicitly all the time instead of occasionally falling back to calling 'git_pathdup("config")' to get the path to the local repository configuration. This allows 'do_git_config_sequence()' to not implicitly rely on global repository state.Signed-off-by Brandon Williams <[email protected]>
[...]
Quoted 6 lines
Quoted 6 lines
Unlike the previous 3, this one makes me pause for a moment: it means that "gitdir:" includes and .git/config discovery would stop working if the caller does not remember to set
git_dirin theirconfig_options.So we have to inspect callers.
[...]
Quoted 3 lines
Quoted 1 line
nit: because of the context, this 'if' can be "if (!nongit)".
Will do.
Thanks.
[...]
Quoted 21 lines
Quoted 12 lines
config.c static int include_by_gitdir(const struct config_options *opts, · line 223
Quoted 9 lines
+++
b/config.cconfig.c +0
-2@@ -219,8 +219,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;I wonder if this should have a sanity-check:
Quoted 8 lines
else if (have_git_dir()) BUG("caller forgot to set opts->git_dir");Alternatively, could this patch rename
git_config_with_options? That way any other patch in flight that callsgit_config_with_optionswould conflict with this patch, giving us an opportunity to make sure it also setsgit_dir. As another nice side benefit it would make it easy for someone reading the patch to verify it didn't miss any callers.
Quoted 3 lines
That kind of defeats the purpose of the patch. The point is to not rely on global repository state and with the BUG statement we still are relying on global state.
By "that" are you referring to the BUG()? I agree --- I'd prefer renaming the function over adding a BUG() to catch mistaken old callers, so I shouldn't have mentioned the idea. I mentioned it to give another example of how to make this kind of change safely.
Quoted 1 line
And I don't know if I agree with renaming a function just to rename it.
It is not renaming just to rename: this is approximately the only safe way that the Git project has to make a significant breaking change to the API of a function. In a project where people push directly to the repository in a fast-forward way, it may be possible to make such a change by announcing it loudly and relying on patch authors keeping track of what is happening in the repository. But in a project like Git that juggles multiple patches in flight, some more explicit coordination, for example by renaming the identifier, is needed.
Sorry.
Do you have another method in mind?
Thanks,
Jonathan
Re: [PATCH 4/4] config: don't implicitly use gitdir
In reply to Brandon WilliamsHi again,
Quoted 7 lines · Brandon Williams
Quoted 5 lines · Jonathan Nieder
Alternatively, could this patch rename
git_config_with_options? That way any other patch in flight that callsgit_config_with_optionswould conflict with this patch, giving us an opportunity to make sure it also setsgit_dir. As another nice side benefit it would make it easy for someone reading the patch to verify it didn't miss any callers.
[...]
Quoted 1 line
And I don't know if I agree with renaming a function just to rename it.
I forgot to say: another way to accomplish the same thing can be to reorder the function's arguments. The relevant thing is to make code that calls the function without being aware of the new requirements fail to compile.
[...]
Quoted 10 lines
Quoted 7 lines
config.c static void git_config_raw(config_fn_t fn, void *data) · line 1613
Quoted 3 lines · Brandon Williams
config.c +2
-0opts.respect_includes =1 ; +if (have_git_dir ()) + opts.git_dir =get_git_common_dir ();curious: Why
get_git_common_dir()instead ofget_git_dir()?Needs to be commondir since the config is stored in the common git directory and not a per worktree git directory.
*puzzled* Why wasn't this needed before, then? The rest of the patch should result in no functional change, but this part seems different.
Please add some explanation to the commit message.
Thanks,
Jonathan
Re: [PATCH 4/4] config: don't implicitly use gitdir
Quoted 8 lines · Jonathan Nieder
Quoted 7 lines · Brandon Williams
Quoted 5 lines · Jonathan Nieder
Alternatively, could this patch rename
git_config_with_options? That way any other patch in flight that callsgit_config_with_optionswould conflict with this patch, giving us an opportunity to make sure it also setsgit_dir. As another nice side benefit it would make it easy for someone reading the patch to verify it didn't miss any callers.
Quoted 7 lines
[...]
Quoted 1 line
And I don't know if I agree with renaming a function just to rename it.
I forgot to say: another way to accomplish the same thing can be to reorder the function's arguments. The relevant thing is to make code that calls the function without being aware of the new requirements fail to compile.
If the parameter is now required, then it might make sense for it to become an actual function parameter instead of being stuffed into the config_options struct. That would give you your breaking change, plus make it more obvious to the reader that it is not optional.
The downside is that has to get shuttled around manually through the callstack. Most of the damage is in builtin/config.c, where we call git_config_with_options() a lot.
include_by_gitdir is also a bit annoying, as we pass around the config_options struct through our void-pointer callbacks. But we can solve that by sticking the git_dir into the include_data struct (whose exact purpose is to carry the information we need to handle includes).
The patch below (on top of Brandon's series does that).
Quoted 10 lines
Quoted 7 lines
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (have_git_dir()) + opts.git_dir = get_git_common_dir();curious: Why
get_git_common_dir()instead ofget_git_dir()?Needs to be commondir since the config is stored in the common git directory and not a per worktree git directory.
*puzzled* Why wasn't this needed before, then? The rest of the patch should result in no functional change, but this part seems different.
Now I'm puzzled, too. The original that got filled in lazily by the config functions was always get_git_dir(). I can buy the argument that this was a bug (I'm not familiar enough with worktree to say one way or the other), but if it's a fix it should definitely go into another patch.
--- builtin/config.c | 17 ++++++++++---- config.c | 43 +++++++++++++++++++---------------- config.h | 4 ++-- 3 files changed, 37 insertions(+), 27 deletions(-)
builtin/config.c +12 -5
@@ -29,6 +29,7 @@ static int actions, types;static int end_null;static int respect_includes_opt =-1 ;static struct config_options config_options; +const char *config_git_dir;static int show_origin;#define ACTION_GET (1<<0)
@@ -244,7 +245,9 @@ static int get_value(const char *key_, const char *regex_) }git_config_with_options (collect_config, &values, - &given_config_source, &config_options); + &given_config_source, + config_git_dir, + &config_options); ret = !values.nr;
@@ -322,7 +325,8 @@ static void get_color(const char *var, const char *def_color) get_color_found =0 ; parsed_color[0 ] ='\0' ;git_config_with_options (git_get_color_config,NULL , - &given_config_source, &config_options); + &given_config_source, + config_git_dir, &config_options);if (!get_color_found && def_color) {if (color_parse (def_color, parsed_color) <0 )
@@ -354,7 +358,8 @@ static int get_colorbool(const char *var, int print) get_diff_color_found =-1 ; get_color_ui_found =-1 ;git_config_with_options (git_get_colorbool_config,NULL , - &given_config_source, &config_options); + &given_config_source, + config_git_dir, &config_options);if (get_colorbool_found <0 ) {if (!strcmp (get_colorbool_slot,"color.diff" ))
@@ -443,7 +448,8 @@ static int get_urlmatch(const char *var, const char *url) }git_config_with_options (urlmatch_config_entry, &config, - &given_config_source, &config_options); + &given_config_source, config_git_dir, + &config_options); ret = !values.nr;
@@ -540,7 +546,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)else config_options.respect_includes = respect_includes_opt;if (have_git_dir ()) - config_options.git_dir =get_git_common_dir (); + config_git_dir =get_git_common_dir ();if (end_null) { term ='\0' ;
@@ -587,6 +593,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)check_argc (argc,0 ,0 );if (git_config_with_options (show_all_config,NULL , &given_config_source, + config_git_dir, &config_options) <0 ) {if (given_config_source.file) die_errno("unable to read config file '%s'",
config.c +23 -20
136 lines not on this page · raw message
config.h +2 -2
@@ -30,7 +30,6 @@ enum config_origin_type {struct config_options {unsigned int respect_includes :1 ; -const char *git_dir; };typedef int (*config_fn_t )(const char *,const char *,void *);
@@ -46,6 +45,7 @@ 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 char *git_dir,const struct config_options *opts);extern int git_parse_ulong (const char *,unsigned long *);extern int git_parse_maybe_bool (const char *);
@@ -97,7 +97,7 @@ struct config_include_data {int depth;config_fn_t fn;void *data; -const struct config_options *opts; +const char *git_dir; };#define CONFIG_INCLUDE_INIT { 0 }extern int git_config_include (const char *name,const char *value,void *data);
Re: [PATCH 4/4] config: don't implicitly use gitdir
Quoted 27 lines · Jeff King
Quoted 8 lines · Jonathan Nieder
Quoted 7 lines · Brandon Williams
Quoted 5 lines · Jonathan Nieder
Alternatively, could this patch rename
git_config_with_options? That way any other patch in flight that callsgit_config_with_optionswould conflict with this patch, giving us an opportunity to make sure it also setsgit_dir. As another nice side benefit it would make it easy for someone reading the patch to verify it didn't miss any callers.Quoted 7 lines
[...]
Quoted 1 line
And I don't know if I agree with renaming a function just to rename it.
I forgot to say: another way to accomplish the same thing can be to reorder the function's arguments. The relevant thing is to make code that calls the function without being aware of the new requirements fail to compile.
If the parameter is now required, then it might make sense for it to become an actual function parameter instead of being stuffed into the
config_optionsstruct. That would give you your breaking change, plus make it more obvious to the reader that it is not optional.The downside is that has to get shuttled around manually through the callstack. Most of the damage is in
builtin/config.c, where we callgit_config_with_options()a lot.
Quoted 6 lines
include_by_gitdiris also a bit annoying, as we pass around theconfig_optionsstruct through our void-pointer callbacks. But we can solve that by sticking thegit_dirinto theinclude_datastruct (whose exact purpose is to carry the information we need to handle includes).The patch below (on top of Brandon's series does that).
I really don't understand why this has to be so difficult and why a 'breaking change' is even needed. Duy just added the 'git_dir' field to the config_options struct in April of this year (2185fde56 config:
handle conditional include when $GIT_DIR is not set up) and now we want to strip it out again? That's not even two months. Seems very counter productive and makes the api more unwieldy.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ if (have_git_dir()) + opts.git_dir = get_git_common_dir();curious: Why
get_git_common_dir()instead ofget_git_dir()?Needs to be commondir since the config is stored in the common git directory and not a per worktree git directory.
Quoted 8 lines
Quoted 2 lines
*puzzled* Why wasn't this needed before, then? The rest of the patch should result in no functional change, but this part seems different.
Now I'm puzzled, too. The original that got filled in lazily by the config functions was always
get_git_dir(). I can buy the argument that this was a bug (I'm not familiar enough with worktree to say one way or the other), but if it's a fix it should definitely go into another patch.
Well actually... in do_git_config_sequence 'git_path("config")' is called which will convert gitdir to commondir under the hood. you can't use vanilla gitdir because the config isn't stored in a worktree's gitdir but rather in the commondir as the config is shared by all worktrees.
So maybe we actually need to add a field to the 'config_options' struct of 'commondir' such that the commondir can be used to load the actual config file and 'gitdir' can be used to handle the 'IncludeIf' stuff.
Quoted 257 lines
--- builtin/config.c | 17 ++++++++++---- config.c | 43 +++++++++++++++++++---------------- config.h | 4 ++-- 3 files changed, 37 insertions(+), 27 deletions(-)builtin/config.c +12
-5@@ -29,6 +29,7 @@ static int actions, types;static int end_null;static int respect_includes_opt =-1 ;static struct config_options config_options; +const char *config_git_dir;static int show_origin;#define ACTION_GET (1<<0)@@ -244,7 +245,9 @@ static int get_value(const char *key_, const char *regex_) }git_config_with_options (collect_config, &values, - &given_config_source, &config_options); + &given_config_source, + config_git_dir, + &config_options); ret = !values.nr;@@ -322,7 +325,8 @@ static void get_color(const char *var, const char *def_color) get_color_found =0 ; parsed_color[0 ] ='\0' ;git_config_with_options (git_get_color_config,NULL , - &given_config_source, &config_options); + &given_config_source, + config_git_dir, &config_options);if (!get_color_found && def_color) {if (color_parse (def_color, parsed_color) <0 )@@ -354,7 +358,8 @@ static int get_colorbool(const char *var, int print) get_diff_color_found =-1 ; get_color_ui_found =-1 ;git_config_with_options (git_get_colorbool_config,NULL , - &given_config_source, &config_options); + &given_config_source, + config_git_dir, &config_options);if (get_colorbool_found <0 ) {if (!strcmp (get_colorbool_slot,"color.diff" ))@@ -443,7 +448,8 @@ static int get_urlmatch(const char *var, const char *url) }git_config_with_options (urlmatch_config_entry, &config, - &given_config_source, &config_options); + &given_config_source, config_git_dir, + &config_options); ret = !values.nr;@@ -540,7 +546,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)else config_options.respect_includes = respect_includes_opt;if (have_git_dir ()) - config_options.git_dir =get_git_common_dir (); + config_git_dir =get_git_common_dir ();if (end_null) { term ='\0' ;@@ -587,6 +593,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)check_argc (argc,0 ,0 );if (git_config_with_options (show_all_config,NULL , &given_config_source, + config_git_dir, &config_options) <0 ) {if (given_config_source.file) die_errno("unable to read config file '%s'",config.c +23
-20@@ -208,21 +208,18 @@ static int prepare_include_condition_pattern(struct strbuf *pat)return prefix; } -static int include_by_gitdir (const struct config_options *opts, +static int include_by_gitdir (const struct config_include_data *inc,const char *cond,size_t cond_len,int icase) {struct strbuf text =STRBUF_INIT ;struct strbuf pattern =STRBUF_INIT ;int ret =0 , prefix; -const char *git_dir;int already_tried_absolute =0 ; -if (opts->git_dir) - git_dir = opts->git_dir; -else +if (!inc->git_dir) goto done; -strbuf_realpath (&text, git_dir,1 ); +strbuf_realpath (&text, inc->git_dir,1 );strbuf_add (&pattern, cond, cond_len); prefix =prepare_include_condition_pattern (&pattern);@@ -256,7 +253,7 @@ static int include_by_gitdir(const struct config_options *opts,* which'll do the right thing */ strbuf_reset (&text); -strbuf_add_absolute_path (&text, git_dir); +strbuf_add_absolute_path (&text, inc->git_dir); already_tried_absolute =1 ; goto again; }@@ -266,14 +263,14 @@ static int include_by_gitdir(const struct config_options *opts,return ret; } -static int include_condition_is_true (const struct config_options *opts, +static int include_condition_is_true (const struct config_include_data *inc,const char *cond,size_t cond_len) {if (skip_prefix_mem (cond, cond_len,"gitdir:" , &cond, &cond_len)) -return include_by_gitdir (opts, cond, cond_len,0 ); +return include_by_gitdir (inc, cond, cond_len,0 );else if (skip_prefix_mem (cond, cond_len,"gitdir/i:" , &cond, &cond_len)) -return include_by_gitdir (opts, cond, cond_len,1 ); +return include_by_gitdir (inc, cond, cond_len,1 );/* unknown conditionals are always false */ return 0 ;@@ -298,7 +295,7 @@ int git_config_include(const char *var, const char *value, void *data) ret =handle_path_include (value, inc);if (!parse_config_key (var,"includeif" , &cond, &cond_len, &key) && - (cond &&include_condition_is_true (inc->opts, cond, cond_len)) && + (cond &&include_condition_is_true (inc, cond, cond_len)) && !strcmp (key,"path" )) ret =handle_path_include (value, inc);@@ -1537,6 +1534,7 @@ int git_config_system(void) }static int do_git_config_sequence (const struct config_options *opts, +const char *git_dir,config_fn_t fn,void *data) {int ret =0 ;@@ -1544,8 +1542,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 (git_dir) + repo_config =mkpathdup ("%s/config" , git_dir);else repo_config =NULL ;@@ -1578,6 +1576,7 @@ static int do_git_config_sequence(const struct config_options *opts,int git_config_with_options (config_fn_t fn,void *data,struct git_config_source *config_source, +const char *git_dir,const struct config_options *opts) {struct config_include_data inc =CONFIG_INCLUDE_INIT ;@@ -1585,7 +1584,7 @@ int git_config_with_options(config_fn_t fn, void *data,if (opts->respect_includes) { inc.fn = fn; inc.data = data; - inc.opts = opts; + inc.git_dir = git_dir; fn = git_config_include; data = &inc; }@@ -1601,17 +1600,18 @@ int git_config_with_options(config_fn_t fn, void *data,else if (config_source && config_source->blob)return git_config_from_blob_ref (fn, config_source->blob, data); -return do_git_config_sequence (opts, fn, data); +return do_git_config_sequence (opts, git_dir, fn, data); }static void git_config_raw (config_fn_t fn,void *data) {struct config_options opts = {0 }; +const char *git_dir; opts.respect_includes =1 ;if (have_git_dir ()) - opts.git_dir =get_git_common_dir (); -if (git_config_with_options (fn, data,NULL , &opts) <0 ) + git_dir =get_git_common_dir (); +if (git_config_with_options (fn, data,NULL , git_dir, &opts) <0 )/* * git_config_with_options() normally returns only * zero, as most errors are fatal, and @@ -1653,11 +1653,12 @@ void read_early_config(config_fn_t cb, void *data) {struct config_options opts = {0 };struct strbuf buf =STRBUF_INIT ; +const char *git_dir; opts.respect_includes =1 ;if (have_git_dir ()) - opts.git_dir =get_git_dir (); + git_dir =get_git_dir ();/* * When setup_git_directory() was not yet asked to discover the * GIT_DIR, we ask discover_git_directory() to figure out whether there @@ -1667,9 +1668,11 @@ void read_early_config(config_fn_t cb, void *data)* call). */ else if (discover_git_directory(&buf)) - opts.git_dir = buf.buf; + git_dir = buf.buf; + else + git_dir =NULL ; -git_config_with_options (cb, data,NULL , &opts); +git_config_with_options (cb, data,NULL , git_dir, &opts);strbuf_release (&buf); }config.h +2
-2@@ -30,7 +30,6 @@ enum config_origin_type {struct config_options {unsigned int respect_includes :1 ; -const char *git_dir; };typedef int (*config_fn_t )(const char *,const char *,void *);@@ -46,6 +45,7 @@ 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 char *git_dir,const struct config_options *opts);extern int git_parse_ulong (const char *,unsigned long *);extern int git_parse_maybe_bool (const char *);@@ -97,7 +97,7 @@ struct config_include_data {int depth;config_fn_t fn;void *data; -const struct config_options *opts; +const char *git_dir; };#define CONFIG_INCLUDE_INIT { 0 }extern int git_config_include (const char *name,const char *value,void *data);
Signature · 1 line
Brandon Williams
Re: [PATCH 4/4] config: don't implicitly use gitdir
Quoted 14 lines · Brandon Williams
Quoted 14 lines
If the parameter is now required, then it might make sense for it to become an actual function parameter instead of being stuffed into the
config_optionsstruct. That would give you your breaking change, plus make it more obvious to the reader that it is not optional.The downside is that has to get shuttled around manually through the callstack. Most of the damage is in
builtin/config.c, where we callgit_config_with_options()a lot.
include_by_gitdiris also a bit annoying, as we pass around theconfig_optionsstruct through our void-pointer callbacks. But we can solve that by sticking thegit_dirinto theinclude_datastruct (whose exact purpose is to carry the information we need to handle includes).
Quoted 8 lines
Quoted 1 line
The patch below (on top of Brandon's series does that).
I really don't understand why this has to be so difficult and why a 'breaking change' is even needed. Duy just added the '
git_dir' field to theconfig_optionsstruct in April of this year (2185fde56config:
handle conditional include when $GIT_DIR is not set up) and now we want to strip it out again? That's not even two months. Seems very counter productive and makes the api more unwieldy.
I could go either way on it. But note that you're not just changing the existing opt->git_dir behavior.
If I call git_config_with_options() without having set opt->git_dir, the call will now quietly ignore repo config. But even before opt->git_dir existed, calling that function would always have read from repo config (when we're in one, of course). So if there's a patch in flight that adds a call to git_config_with_options(), it's now very subtly broken.
The reason I say "I could go either way" is that we can make a guess as to whether there are any topics in flight that add such a call.
There aren't any in pu right now. That's not the whole world, of course; people may have topics they haven't yet published. Or they may have long running forks. Git for Windows is one, and I maintain one that GitHub uses internally. But GfW is public and doesn't have any new calls (and nor does my fork). In general, it's kind of an unlikely call for a fork or a new branch to add.
So at some point I think we say "good enough, it's not worth the hassle" and this may be such a case.
-Peff
Re: [PATCH 4/4] config: don't implicitly use gitdir
In reply to Brandon WilliamsQuoted 9 lines · Brandon Williams
Quoted 8 lines
Quoted 2 lines
*puzzled* Why wasn't this needed before, then? The rest of the patch should result in no functional change, but this part seems different.
Now I'm puzzled, too. The original that got filled in lazily by the config functions was always
get_git_dir(). I can buy the argument that this was a bug (I'm not familiar enough with worktree to say one way or the other), but if it's a fix it should definitely go into another patch.
Quoted 5 lines
Well actually... in
do_git_config_sequence'git_path("config")' is called which will convert gitdir to commondir under the hood. you can't use vanilla gitdir because the config isn't stored in a worktree's gitdir but rather in the commondir as the config is shared by all worktrees.
Sorry, I missed the fact that there were two sites changed on the first read.
Quoted 3 lines
So maybe we actually need to add a field to the '
config_options' struct of 'commondir' such that the commondir can be used to load the actual config file and 'gitdir' can be used to handle the 'IncludeIf' stuff.
On reflection, I suspect that probably is the case. If you have a workdir in ~/foo, you probably want to match IncludeIf against that instead of wherever the common dir happens to be.
-Peff
Re: [PATCH 4/4] config: don't implicitly use gitdir
Quoted 11 lines · Jeff King
Quoted 9 lines · Brandon Williams
Quoted 8 lines
Quoted 2 lines
*puzzled* Why wasn't this needed before, then? The rest of the patch should result in no functional change, but this part seems different.
Now I'm puzzled, too. The original that got filled in lazily by the config functions was always
get_git_dir(). I can buy the argument that this was a bug (I'm not familiar enough with worktree to say one way or the other), but if it's a fix it should definitely go into another patch.
Quoted 8 lines
Quoted 5 lines
Well actually... in
do_git_config_sequence'git_path("config")' is called which will convert gitdir to commondir under the hood. you can't use vanilla gitdir because the config isn't stored in a worktree's gitdir but rather in the commondir as the config is shared by all worktrees.Sorry, I missed the fact that there were two sites changed on the first read.
Well I missed that fact when I first wrote these patches too :)
Quoted 8 lines
Quoted 4 lines
So maybe we actually need to add a field to the '
config_options' struct of 'commondir' such that the commondir can be used to load the actual config file and 'gitdir' can be used to handle the 'IncludeIf' stuff.On reflection, I suspect that probably is the case. If you have a workdir in ~/foo, you probably want to match IncludeIf against that instead of wherever the common dir happens to be.
K I'll look into adding that then. I will say keeping track of 'commondir' vs 'gitdir' does get slightly confusing.
Signature · 1 line
Brandon Williams
Re: [PATCH 4/4] config: don't implicitly use gitdir
In reply to Jeff KingQuoted 17 lines · Jeff King
Quoted 8 lines · Jonathan Nieder
Quoted 7 lines · Brandon Williams
Quoted 5 lines · Jonathan Nieder
Alternatively, could this patch rename
git_config_with_options? That way any other patch in flight that callsgit_config_with_optionswould conflict with this patch, giving us an opportunity to make sure it also setsgit_dir. As another nice side benefit it would make it easy for someone reading the patch to verify it didn't miss any callers.Quoted 7 lines
[...]
Quoted 1 line
And I don't know if I agree with renaming a function just to rename it.
I forgot to say: another way to accomplish the same thing can be to reorder the function's arguments. The relevant thing is to make code that calls the function without being aware of the new requirements fail to compile.
Quoted 4 lines
If the parameter is now required, then it might make sense for it to become an actual function parameter instead of being stuffed into the
config_optionsstruct. That would give you your breaking change, plus make it more obvious to the reader that it is not optional.
I like it. I also like that in your proposed patch the no longer necessary local git_dir goes away.
What's the next step? The discussion of get_git_common_dir() reveals that switching from git_path() to mkpathdup() loses the adjust_git_path() step and everything becomes complicated. So perhaps adding opts.git_common_dir and using that instead of git_path should happen as a preliminary patch, making this patch afterward a more straightforward refactoring.
Thanks,
Jonathan
Re: [PATCH 4/4] config: don't implicitly use gitdir
In reply to Jonathan NiederQuoted 27 lines · Jonathan Nieder
Hi again,
Quoted 7 lines · Brandon Williams
Quoted 5 lines · Jonathan Nieder
Alternatively, could this patch rename
git_config_with_options? That way any other patch in flight that callsgit_config_with_optionswould conflict with this patch, giving us an opportunity to make sure it also setsgit_dir. As another nice side benefit it would make it easy for someone reading the patch to verify it didn't miss any callers.[...]
Quoted 1 line
And I don't know if I agree with renaming a function just to rename it.
I forgot to say: another way to accomplish the same thing can be to reorder the function's arguments. The relevant thing is to make code that calls the function without being aware of the new requirements fail to compile.
[...]
Quoted 8 lines
Quoted 7 lines
config.c static void git_config_raw(config_fn_t fn, void *data) · line 1613
Quoted 3 lines · Brandon Williams
config.c +2
-0opts.respect_includes =1 ; +if (have_git_dir ()) + opts.git_dir =get_git_common_dir ();curious: Why
get_git_common_dir()instead ofget_git_dir()?
Quoted 5 lines
Quoted 2 lines
Needs to be commondir since the config is stored in the common git directory and not a per worktree git directory.
*puzzled* Why wasn't this needed before, then? The rest of the patch should result in no functional change, but this part seems different.
there is no functional change, this is what always happened. git_path("config") will replace gitdir with commondir under the hood.
Quoted 5 lines
Please add some explanation to the commit message.
Thanks,
Jonathan
Signature · 1 line
Brandon Williams
Re: [PATCH 4/4] config: don't implicitly use gitdir
Quoted 10 lines · Brandon Williams
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
curious: Why
get_git_common_dir()instead ofget_git_dir()?Needs to be commondir since the config is stored in the common git directory and not a per worktree git directory.
*puzzled* Why wasn't this needed before, then? The rest of the patch should result in no functional change, but this part seems different.
there is no functional change, this is what always happened.
git_path("config")will replace gitdir with commondir under the hood.
Of the two callsites you removed, one is git_pathdup(), and the other is get_git_dir(). So they weren't matched, though I suspect the one in include_by_gitdir probably ought to have been commondir?
-Peff
Re: [PATCH 4/4] config: don't implicitly use gitdir
Quoted 10 lines · Jeff King
Quoted 8 lines · Brandon Williams
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
curious: Why
get_git_common_dir()instead ofget_git_dir()?Needs to be commondir since the config is stored in the common git directory and not a per worktree git directory.
*puzzled* Why wasn't this needed before, then? The rest of the patch should result in no functional change, but this part seems different.
Quoted 6 lines
Quoted 2 lines
there is no functional change, this is what always happened.
git_path("config")will replace gitdir with commondir under the hood.Of the two callsites you removed, one is
git_pathdup(), and the other isget_git_dir(). So they weren't matched, though I suspect the one ininclude_by_gitdirprobably ought to have been commondir?
Good point, I hope my reply on the other part of the thread answers this.
Signature · 1 line
Brandon Williams
Quoted 7 lines · Brandon Williams
After some discussion I realized that my 'repository object' series was getting to be rather long and increase in scope. So I've decided to break off these couple patches into their own series so they can be reviewed more easily. This should also let them be merged in faster as I suspect it'll take a while for my 'repository object' series to be reviewed thourouly and these couple patches could result in a lot of merge conflicts as it touches a lot of files.
Quoted 5 lines
Brandon Williams (4):
config: createconfig.h
config: removegit_config_iter
config: don't includeconfig.hby default
config: don't implicitly use gitdir
These all seem reasonable to me. Patch 3 made me shrug a little, because it seems like the majority of C files end up including it anyway. I suspect you could break config.h down into two files: the few things that everybody needs (git_config() and the few parsing functions needed in callbacks) and the ones for commands that actually manipulate the config.
That would reduce the surface area of the module that most callers look at, but I don't think there's a huge benefit to doing so (mostly it just makes re-compiling faster by decreasing the chance that a dependent header has changed for each file).
-Peff
Quoted 22 lines · Jeff King
Quoted 7 lines · Brandon Williams
After some discussion I realized that my 'repository object' series was getting to be rather long and increase in scope. So I've decided to break off these couple patches into their own series so they can be reviewed more easily. This should also let them be merged in faster as I suspect it'll take a while for my 'repository object' series to be reviewed thourouly and these couple patches could result in a lot of merge conflicts as it touches a lot of files.
Quoted 5 lines
Brandon Williams (4):
config: createconfig.h
config: removegit_config_iter
config: don't includeconfig.hby default
config: don't implicitly use gitdirThese all seem reasonable to me. Patch 3 made me shrug a little, because it seems like the majority of C files end up including it anyway. I suspect you could break
config.hdown into two files: the few things that everybody needs (git_config()and the few parsing functions needed in callbacks) and the ones for commands that actually manipulate the config.
Quoted 4 lines
That would reduce the surface area of the module that most callers look at, but I don't think there's a huge benefit to doing so (mostly it just makes re-compiling faster by decreasing the chance that a dependent header has changed for each file).
Yes, ultimately I think it would be a good thing to break config.c down into at least 2 more files (the file parsing logic and the config_set logic) but that can be done at a later point. I started looking at doing that now but that logic is a little more entangled than I thought it was.
Thanks for taking a look Jeff!
Signature · 1 line
Brandon Williams
Quoted 12 lines · Brandon Williams
Quoted 11 lines
These all seem reasonable to me. Patch 3 made me shrug a little, because it seems like the majority of C files end up including it anyway. I suspect you could break
config.hdown into two files: the few things that everybody needs (git_config()and the few parsing functions needed in callbacks) and the ones for commands that actually manipulate the config.That would reduce the surface area of the module that most callers look at, but I don't think there's a huge benefit to doing so (mostly it just makes re-compiling faster by decreasing the chance that a dependent header has changed for each file).
Quoted 5 lines
Yes, ultimately I think it would be a good thing to break
config.cdown into at least 2 more files (the file parsing logic and theconfig_setlogic) but that can be done at a later point. I started looking at doing that now but that logic is a little more entangled than I thought it was.
To be clear, I don't mind that sort of module refactoring and like the results. But it almost certainly isn't the biggest bang-for-buck in terms of the time it takes versus the benefit it brings. So take my comment as "we could also do..." but not "we should not take your patch because it does not go far enough".
-Peff
Quoted 20 lines · Jeff King
Quoted 12 lines · Brandon Williams
Quoted 11 lines
These all seem reasonable to me. Patch 3 made me shrug a little, because it seems like the majority of C files end up including it anyway. I suspect you could break
config.hdown into two files: the few things that everybody needs (git_config()and the few parsing functions needed in callbacks) and the ones for commands that actually manipulate the config.That would reduce the surface area of the module that most callers look at, but I don't think there's a huge benefit to doing so (mostly it just makes re-compiling faster by decreasing the chance that a dependent header has changed for each file).
Quoted 5 lines
Yes, ultimately I think it would be a good thing to break
config.cdown into at least 2 more files (the file parsing logic and theconfig_setlogic) but that can be done at a later point. I started looking at doing that now but that logic is a little more entangled than I thought it was.
Quoted 5 lines
To be clear, I don't mind that sort of module refactoring and like the results. But it almost certainly isn't the biggest bang-for-buck in terms of the time it takes versus the benefit it brings. So take my comment as "we could also do..." but not "we should not take your patch because it does not go far enough".
Yes, that's how I understood your comment. I realize that there's a lot of improvements that can be done across our code base and one rabbit hole that is easy to fall into is "fix all the things right now!" hence why I decided to defer doing that to a later date. And I agree that doing that extra work doesn't buy us 'all too much'.
Having said that I do think it was worthwhile to remove the config declarations from cache.h. I think in the long term it would be nice to limit cache.h's scope as it is very unapproachable in its current form.
Signature · 1 line
Brandon Williams
Quoted 5 lines · Brandon Williams
Brandon Williams (4):
config: createconfig.h
config: removegit_config_iter
config: don't includeconfig.hby default
config: don't implicitly use gitdir
Patches 1-3 are
I'm very happy to see cache.h getting shorter and less intimidating.
I have some minor concerns with patch 4 that I described in a reply to that patch. I'd expect that after another round that one will be ready.
Thanks for a pleasant read.
Sincerely,
Jonathan
v2 cover config.h
In reply to Brandon WilliamsChanges in v2:
* Fix a small nit in builtin/config.c that Jonathan pointed out.
* Added two patches which ensure that the repository wide config is properly read by providing 'commondir' as a field in the 'config_options' struct.
Brandon Williams (6):
config: create config.h
config: remove git_config_iter
config: don't include config.h by default
config: don't implicitly use gitdir
setup: teach discover_git_directory to respect the commondir
config: respect commondir
--- interdiff with 'origin/bw/config-h'
builtin/config.c +4 -2
@@ -539,8 +539,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 (have_git_dir ()) - config_options.git_dir =get_git_common_dir (); +if (!nongit) { + config_options.commondir =get_git_common_dir (); + config_options.git_dir =get_git_dir (); + }if (end_null) { term ='\0' ;
cache.h +2 -1
@@ -530,7 +530,8 @@ extern void setup_work_tree(void);* 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); +extern const char *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);
config.c +17 -9
@@ -1544,8 +1544,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 repo_config =NULL ;
@@ -1609,8 +1609,11 @@ static void git_config_raw(config_fn_t fn, void *data)struct config_options opts = {0 }; opts.respect_includes =1 ; -if (have_git_dir ()) - opts.git_dir =get_git_common_dir (); +if (have_git_dir ()) { + opts.commondir =get_git_common_dir (); + opts.git_dir =get_git_dir (); + } +if (git_config_with_options (fn, data,NULL , &opts) <0 )/* * git_config_with_options() normally returns only
@@ -1652,11 +1655,13 @@ 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 ; -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
@@ -1666,12 +1671,15 @@ 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.commondir = commondir.buf; + 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 );
config.h +1 -0
@@ -30,6 +30,7 @@ enum config_origin_type {struct config_options {unsigned int respect_includes :1 ; +const char *commondir;const char *git_dir; };
setup.c +7 -2
@@ -946,10 +946,12 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir, } } -const char *discover_git_directory (struct strbuf *gitdir) +const char *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))
@@ -974,8 +976,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);
@@ -983,6 +987,7 @@ 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);return NULL ; }
Signature · 1 line
2.13.1.518.g3df882009-goog
PATCH v2 1/6 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.
--- cache.h | 190 +------------------------------------------------------------ config.h | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+), 189 deletions(-) create mode 100644 config.h
cache.h +1 -189
@@ -11,6 +11,7 @@#include "string-list.h" #include "pack-revindex.h" #include "hash.h" +#include "config.h" #ifndef platform_SHA_CTX/*
@@ -1872,188 +1873,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.
@@ -2061,16 +1883,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 );
config.h new file +194 -0
194 lines not on this page · raw message
Signature · 1 line
2.13.1.518.g3df882009-goog
Re: [PATCH v2 1/6] config: create config.h
Hi,
Quoted 10 lines · Brandon Williams
Move all config related declarations from
cache.hto a newconfig.hheader file. This makescache.hsmaller and allows for the opportunity in a following patch to only includeconfig.hwhen needed.Signed-off-by Brandon Williams <[email protected]>--- cache.h | 190 +------------------------------------------------------------ config.h | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+), 189 deletions(-) create mode 100644 config.h
'git diff HEAD^:cache.h config.h' confirms that this is straightforward code movement and didn't introduce any unintentional changes along the way. Thanks for writing it.
PATCH v2 2/6 config: remove git_config_iter
In reply to Brandon WilliamsSince there is no implementation of the function 'git_config_iter' lets stop exporting it and remove the prototype from config.h.
--- config.h | 1 - 1 file changed, 1 deletion(-)
config.h +0 -1
@@ -165,7 +165,6 @@ extern int git_configset_get_pathname(struct config_set *cs, const char *key, coextern 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);
Signature · 1 line
2.13.1.518.g3df882009-goog
Re: [PATCH v2 2/6] config: remove git_config_iter
Quoted 7 lines · Brandon Williams
Since there is no implementation of the function '
git_config_iter' lets stop exporting it and remove the prototype fromconfig.h.Signed-off-by Brandon Williams <[email protected]>--- config.h | 1 - 1 file changed, 1 deletion(-)
Language nit:
s/' lets/', let's/
That is, there is a comma and an apostrophe missing.
With or without that tweak,
PATCH v2 3/6 config: don't include config.h by default
In reply to Brandon WilliamsStop including config.h by default in cache.h. Instead only include config.h in those files which require use of the config system.
--- 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 | 2 ++ 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 + 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 + 145 files changed, 145 insertions(+), 1 deletion(-)
advice.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" int advice_push_update_rejected =1 ;int advice_push_non_ff_current =1 ;
alias.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" char *alias_lookup (const char *alias) {
apply.c +1 -0
@@ -8,6 +8,7 @@*/ #include "cache.h" +#include "config.h" #include "blob.h" #include "delta.h" #include "diff.h"
archive-tar.c +1 -0
@@ -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"
archive-zip.c +1 -0
@@ -2,6 +2,7 @@* Copyright (c) 2006 Rene Scharfe */ #include "cache.h" +#include "config.h" #include "archive.h" #include "streaming.h" #include "utf8.h"
archive.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "refs.h" #include "commit.h" #include "tree-walk.h"
attr.c +1 -0
@@ -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"
bisect.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "diff.h" #include "revision.h"
branch.c +1 -0
@@ -1,5 +1,6 @@#include "git-compat-util.h" #include "cache.h" +#include "config.h" #include "branch.h" #include "refs.h" #include "remote.h"
builtin/add.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) 2006 Linus Torvalds */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "lockfile.h" #include "dir.h"
builtin/am.c +1 -0
@@ -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"
builtin/blame.c +2 -0
@@ -6,6 +6,8 @@*/ #include "cache.h" +#include "config.h" +#include "refs.h" #include "builtin.h" #include "commit.h" #include "diff.h"
builtin/branch.c +1 -0
@@ -6,6 +6,7 @@*/ #include "cache.h" +#include "config.h" #include "color.h" #include "refs.h" #include "commit.h"
builtin/cat-file.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "diff.h" #include "parse-options.h"
builtin/check-attr.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "attr.h" #include "quote.h" #include "parse-options.h"
builtin/check-ignore.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "dir.h" #include "quote.h" #include "pathspec.h"
builtin/check-mailmap.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "mailmap.h" #include "parse-options.h" #include "string-list.h"
builtin/checkout-index.c +1 -0
@@ -5,6 +5,7 @@* */ #include "builtin.h" +#include "config.h" #include "lockfile.h" #include "quote.h" #include "cache-tree.h"
builtin/checkout.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "lockfile.h" #include "parse-options.h" #include "refs.h"
builtin/clean.c +1 -0
@@ -8,6 +8,7 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "dir.h" #include "parse-options.h" #include "string-list.h"
builtin/clone.c +1 -0
@@ -9,6 +9,7 @@*/ #include "builtin.h" +#include "config.h" #include "lockfile.h" #include "parse-options.h" #include "fetch-pack.h"
builtin/column.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "strbuf.h" #include "parse-options.h" #include "string-list.h"
builtin/commit-tree.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "commit.h" #include "tree.h" #include "builtin.h"
builtin/commit.c +1 -0
@@ -6,6 +6,7 @@*/ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "cache-tree.h" #include "color.h"
builtin/config.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "color.h" #include "parse-options.h" #include "urlmatch.h"
builtin/count-objects.c +1 -0
@@ -5,6 +5,7 @@*/ #include "cache.h" +#include "config.h" #include "dir.h" #include "builtin.h" #include "parse-options.h"
builtin/describe.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "lockfile.h" #include "commit.h" #include "tag.h"
builtin/diff-files.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "diff.h" #include "commit.h" #include "revision.h"
builtin/diff-index.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "diff.h" #include "commit.h" #include "revision.h"
builtin/diff-tree.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "diff.h" #include "commit.h" #include "log-tree.h"
builtin/diff.c +1 -0
@@ -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"
builtin/difftool.c +1 -0
@@ -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"
builtin/fast-export.c +1 -0
@@ -5,6 +5,7 @@*/ #include "builtin.h" #include "cache.h" +#include "config.h" #include "refs.h" #include "commit.h" #include "object.h"
builtin/fetch.c +1 -0
@@ -2,6 +2,7 @@* "git fetch" */ #include "cache.h" +#include "config.h" #include "refs.h" #include "commit.h" #include "builtin.h"
builtin/fmt-merge-msg.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "refs.h" #include "commit.h" #include "diff.h"
builtin/for-each-ref.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "refs.h" #include "object.h" #include "parse-options.h"
builtin/fsck.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "tree.h" #include "blob.h"
builtin/gc.c +1 -0
@@ -11,6 +11,7 @@*/ #include "builtin.h" +#include "config.h" #include "tempfile.h" #include "lockfile.h" #include "parse-options.h"
builtin/grep.c +1 -0
@@ -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"
builtin/hash-object.c +1 -0
@@ -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"
builtin/help.c +1 -0
@@ -2,6 +2,7 @@* Builtin help command */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "exec_cmd.h" #include "parse-options.h"
builtin/index-pack.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "delta.h" #include "pack.h" #include "csum-file.h"
builtin/init-db.c +1 -0
@@ -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"
builtin/log.c +1 -0
@@ -5,6 +5,7 @@* 2006 Junio Hamano */ #include "cache.h" +#include "config.h" #include "refs.h" #include "color.h" #include "commit.h"
builtin/ls-files.c +1 -0
@@ -6,6 +6,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "quote.h" #include "dir.h" #include "builtin.h"
builtin/ls-tree.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "blob.h" #include "tree.h" #include "commit.h"
builtin/merge-base.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "diff.h"
builtin/merge-file.c +1 -0
@@ -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"
builtin/merge.c +1 -0
@@ -7,6 +7,7 @@*/ #include "cache.h" +#include "config.h" #include "parse-options.h" #include "builtin.h" #include "lockfile.h"
builtin/mv.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) 2006 Johannes Schindelin */ #include "builtin.h" +#include "config.h" #include "pathspec.h" #include "lockfile.h" #include "dir.h"
builtin/name-rev.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "tag.h" #include "refs.h"
builtin/notes.c +1 -0
@@ -8,6 +8,7 @@*/ #include "cache.h" +#include "config.h" #include "builtin.h" #include "notes.h" #include "blob.h"
builtin/pack-objects.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "attr.h" #include "object.h" #include "blob.h"
builtin/patch-id.c +1 -0
@@ -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) {
builtin/pull.c +1 -0
@@ -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"
builtin/push.c +1 -0
@@ -2,6 +2,7 @@* "git push" */ #include "cache.h" +#include "config.h" #include "refs.h" #include "run-command.h" #include "builtin.h"
builtin/read-tree.c +1 -0
@@ -5,6 +5,7 @@*/ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "object.h" #include "tree.h"
builtin/rebase--helper.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "parse-options.h" #include "sequencer.h"
builtin/receive-pack.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "lockfile.h" #include "pack.h" #include "refs.h"
builtin/reflog.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "lockfile.h" #include "commit.h" #include "refs.h"
builtin/remote.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "parse-options.h" #include "transport.h" #include "remote.h"
builtin/repack.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "dir.h" #include "parse-options.h" #include "run-command.h"
builtin/replace.c +1 -0
@@ -9,6 +9,7 @@*/ #include "cache.h" +#include "config.h" #include "builtin.h" #include "refs.h" #include "parse-options.h"
builtin/rerere.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "dir.h" #include "parse-options.h" #include "string-list.h"
builtin/reset.c +1 -0
@@ -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"
builtin/rev-list.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "diff.h" #include "revision.h"
builtin/rev-parse.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "quote.h"
builtin/revert.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "builtin.h" #include "parse-options.h" #include "diff.h"
builtin/rm.c +1 -0
@@ -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"
builtin/send-pack.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "pkt-line.h"
builtin/shortlog.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "diff.h" #include "string-list.h"
builtin/show-branch.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "builtin.h"
builtin/stripspace.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "parse-options.h" #include "strbuf.h"
builtin/submodule--helper.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "parse-options.h" #include "quote.h" #include "pathspec.h"
builtin/symbolic-ref.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "cache.h" #include "refs.h" #include "parse-options.h"
builtin/tag.c +1 -0
@@ -7,6 +7,7 @@*/ #include "cache.h" +#include "config.h" #include "builtin.h" #include "refs.h" #include "tag.h"
builtin/unpack-file.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" static char *create_temp_file (unsigned char *sha1) {
builtin/unpack-objects.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "object.h" #include "delta.h" #include "pack.h"
builtin/update-index.c +1 -0
@@ -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"
builtin/update-ref.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "refs.h" #include "builtin.h" #include "parse-options.h"
builtin/update-server-info.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "builtin.h" #include "parse-options.h"
builtin/var.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Eric Biederman, 2005 */ #include "builtin.h" +#include "config.h" static const char var_usage[] ="git var (-l | <variable>)" ;
builtin/verify-commit.c +1 -0
@@ -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"
builtin/verify-pack.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "run-command.h" #include "parse-options.h"
builtin/verify-tag.c +1 -0
@@ -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"
builtin/worktree.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "builtin.h" #include "dir.h" #include "parse-options.h"
builtin/write-tree.c +1 -0
@@ -5,6 +5,7 @@*/ #include "builtin.h" #include "cache.h" +#include "config.h" #include "tree.h" #include "cache-tree.h" #include "parse-options.h"
cache.h +0 -1
@@ -11,7 +11,6 @@#include "string-list.h" #include "pack-revindex.h" #include "hash.h" -#include "config.h" #ifndef platform_SHA_CTX/*
color.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "color.h" static int git_use_color_default =GIT_COLOR_AUTO ;
column.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "column.h" #include "string-list.h" #include "parse-options.h"
config.c +1 -0
@@ -6,6 +6,7 @@* */ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "exec_cmd.h" #include "strbuf.h"
connect.c +1 -0
@@ -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"
convert.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "attr.h" #include "run-command.h" #include "quote.h"
credential-cache--daemon.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "tempfile.h" #include "credential.h" #include "unix-socket.h"
credential.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "credential.h" #include "string-list.h" #include "run-command.h"
daemon.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "pkt-line.h" #include "run-command.h" #include "strbuf.h"
diff.c +1 -0
@@ -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"
dir.c +1 -0
@@ -9,6 +9,7 @@*/ #define NO_THE_INDEX_COMPATIBILITY_MACROS #include "cache.h" +#include "config.h" #include "dir.h" #include "attr.h" #include "refs.h"
environment.c +1 -0
@@ -8,6 +8,7 @@* are. */ #include "cache.h" +#include "config.h" #include "refs.h" #include "fmt-merge-msg.h" #include "commit.h"
fast-import.c +1 -0
@@ -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"
fetch-pack.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "lockfile.h" #include "refs.h" #include "pkt-line.h"
git.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "exec_cmd.h" #include "help.h" #include "run-command.h"
gpg-interface.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "run-command.h" #include "strbuf.h" #include "gpg-interface.h"
graph.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "color.h" #include "graph.h"
grep.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "grep.h" #include "userdiff.h" #include "xdiff-interface.h"
help.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "builtin.h" #include "exec_cmd.h" #include "run-command.h"
http-backend.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "refs.h" #include "pkt-line.h" #include "object.h"
http-fetch.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "exec_cmd.h" #include "http.h" #include "walker.h"
http.c +1 -0
@@ -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"
ident.c +1 -0
@@ -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 ;
imap-send.c +1 -0
@@ -23,6 +23,7 @@*/ #include "cache.h" +#include "config.h" #include "credential.h" #include "exec_cmd.h" #include "run-command.h"
ll-merge.c +1 -0
@@ -5,6 +5,7 @@*/ #include "cache.h" +#include "config.h" #include "attr.h" #include "xdiff-interface.h" #include "run-command.h"
log-tree.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "diff.h" #include "commit.h" #include "tag.h"
mailinfo.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "utf8.h" #include "strbuf.h" #include "mailinfo.h"
merge-recursive.c +1 -0
@@ -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"
notes-utils.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "notes-utils.h"
notes.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "notes.h" #include "blob.h" #include "tree.h"
pager.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "run-command.h" #include "sigchain.h"
parse-options.c +1 -0
@@ -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"
pathspec.c +1 -0
@@ -1,5 +1,6 @@#define NO_THE_INDEX_COMPATIBILITY_MACROS #include "cache.h" +#include "config.h" #include "dir.h" #include "pathspec.h" #include "attr.h"
pretty.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "utf8.h" #include "diff.h"
prompt.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "run-command.h" #include "strbuf.h" #include "prompt.h"
read-cache.c +1 -0
@@ -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"
refs.c +1 -0
@@ -3,6 +3,7 @@*/ #include "cache.h" +#include "config.h" #include "hashmap.h" #include "lockfile.h" #include "iterator.h"
refs/files-backend.c +1 -0
@@ -1,4 +1,5 @@#include "../cache.h" +#include "../config.h" #include "../refs.h" #include "refs-internal.h" #include "ref-cache.h"
remote-curl.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "remote.h" #include "strbuf.h" #include "walker.h"
remote.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "remote.h" #include "refs.h" #include "commit.h"
rerere.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "lockfile.h" #include "string-list.h" #include "rerere.h"
send-pack.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "pkt-line.h"
sequencer.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "lockfile.h" #include "sequencer.h" #include "dir.h"
setup.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "dir.h" #include "string-list.h"
sha1_file.c +1 -0
@@ -7,6 +7,7 @@* creation etc. */ #include "cache.h" +#include "config.h" #include "string-list.h" #include "lockfile.h" #include "delta.h"
sha1_name.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "tag.h" #include "commit.h" #include "tree.h"
submodule-config.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "submodule-config.h" #include "submodule.h" #include "strbuf.h"
submodule.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "submodule-config.h" #include "submodule.h" #include "dir.h"
t/helper/test-config.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "string-list.h" /*
t/helper/test-submodule-config.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "submodule-config.h" #include "submodule.h"
trailer.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "string-list.h" #include "run-command.h" #include "commit.h"
transport.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "transport.h" #include "run-command.h" #include "pkt-line.h"
unpack-trees.c +1 -0
@@ -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"
upload-pack.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "refs.h" #include "pkt-line.h" #include "sideband.h"
userdiff.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "userdiff.h" #include "attr.h"
versioncmp.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "string-list.h" /*
wrapper.c +1 -0
@@ -2,6 +2,7 @@* Various trivial helper wrappers around standard functions */ #include "cache.h" +#include "config.h" static void do_nothing (size_t size) {
xdiff-interface.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "xdiff-interface.h" #include "xdiff/xtypes.h" #include "xdiff/xdiffi.h"
Signature · 1 line
2.13.1.518.g3df882009-goog
Re: [PATCH v2 3/6] config: don't include config.h by default
Quoted 5 lines · Brandon Williams
Stop including
config.hby default incache.h. Instead only includeconfig.hin those files which require use of the config system.Signed-off-by Brandon Williams <[email protected]>---
[...]
Quoted 1 line
145 files changed, 145 insertions(+), 1 deletion(-)
Thanks.
PATCH v2 4/6 config: don't implicitly use gitdir
In reply to Brandon WilliamsCommit 2185fde56 (config: handle conditional include when $GIT_DIR is not set up) added a 'git_dir' field to the config_options struct. Let's use this option field explicitly all the time instead of occasionally falling back to calling 'git_pathdup("config")' to get the path to the local repository configuration. This allows 'do_git_config_sequence()' to not implicitly rely on global repository state.
--- builtin/config.c | 2 ++ config.c | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-)
builtin/config.c +2 -0
@@ -539,6 +539,8 @@ 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.git_dir =get_git_common_dir ();if (end_null) { term ='\0' ;
config.c +2 -4
@@ -219,8 +219,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;
@@ -1548,8 +1546,6 @@ static int do_git_config_sequence(const struct config_options *opts,if (opts->git_dir) repo_config =mkpathdup ("%s/config" , opts->git_dir); -else if (have_git_dir ()) - repo_config =git_pathdup ("config" );else repo_config =NULL ;
@@ -1613,6 +1609,8 @@ static void git_config_raw(config_fn_t fn, void *data)struct config_options opts = {0 }; opts.respect_includes =1 ; +if (have_git_dir ()) + opts.git_dir =get_git_common_dir ();if (git_config_with_options (fn, data,NULL , &opts) <0 )/* * git_config_with_options() normally returns only
Signature · 1 line
2.13.1.518.g3df882009-goog
Re: [PATCH v2 4/6] config: don't implicitly use gitdir
Quoted 7 lines · Brandon Williams
Commit
2185fde56(config: handle conditional include when $GIT_DIR is not set up) added a 'git_dir' field to theconfig_optionsstruct. Let's use this option field explicitly all the time instead of occasionally falling back to calling 'git_pathdup("config")' to get the path to the local repository configuration. This allows 'do_git_config_sequence()' to not implicitly rely on global repository state.
Quoted 5 lines
Signed-off-by Brandon Williams <[email protected]>--- builtin/config.c | 2 ++ config.c | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-)
The same comments as before still apply:
- this changes API to make opts->git_dir mandatory, which is error prone and easily avoidable, e.g. by making git_dir an argument to git_config_with_options
- the commit message doesn't say anything about to git dir vs common dir change. It needs to, or even better, the switch to use common dir instead of git dir can happen as a separate patch.
Thanks,
Jonathan
Re: [PATCH v2 4/6] config: don't implicitly use gitdir
Quoted 15 lines · Jonathan Nieder
Quoted 7 lines · Brandon Williams
Commit
2185fde56(config: handle conditional include when $GIT_DIR is not set up) added a 'git_dir' field to theconfig_optionsstruct. Let's use this option field explicitly all the time instead of occasionally falling back to calling 'git_pathdup("config")' to get the path to the local repository configuration. This allows 'do_git_config_sequence()' to not implicitly rely on global repository state.Quoted 5 lines
Signed-off-by Brandon Williams <[email protected]>--- builtin/config.c | 2 ++ config.c | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-)
Quoted 5 lines
The same comments as before still apply:
- this changes API to make
opts->git_dirmandatory, which is error prone and easily avoidable, e.g. by makinggit_diran argument togit_config_with_options
I still don't agree with this. I have looked at all callers and ensured that 'git_dir' will be set when appropriate in the 'config_options' struct. I find the notion ridiculous that I would need to change a function's name or arguments every time the internals of the function are adjusted or when an options struct obtains a new field. Plus, there is already an aptly named parameter of type 'config_options' with which to hold options for the config machinery. This struct is also added to in a later patch to include commondir so that the gitdir vs commondir issue can be resolved.
Quoted 3 lines
- the commit message doesn't say anything about to git dir vs common dir change. It needs to, or even better, the switch to use common dir instead of git dir can happen as a separate patch.
There really isn't any switching in this patch. One of the following patches in this series addresses this problem in more detail though.
Signature · 1 line
Brandon Williams
Re: [PATCH v2 4/6] config: don't implicitly use gitdir
Quoted 22 lines · Brandon Williams
Quoted 15 lines · Jonathan Nieder
Quoted 7 lines · Brandon Williams
Commit
2185fde56(config: handle conditional include when $GIT_DIR is not set up) added a 'git_dir' field to theconfig_optionsstruct. Let's use this option field explicitly all the time instead of occasionally falling back to calling 'git_pathdup("config")' to get the path to the local repository configuration. This allows 'do_git_config_sequence()' to not implicitly rely on global repository state.Quoted 5 lines
Signed-off-by Brandon Williams <[email protected]>--- builtin/config.c | 2 ++ config.c | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-)Quoted 5 lines
The same comments as before still apply:
- this changes API to make
opts->git_dirmandatory, which is error prone and easily avoidable, e.g. by makinggit_diran argument togit_config_with_options
Quoted 9 lines
I still don't agree with this. I have looked at all callers and ensured that '
git_dir' will be set when appropriate in the 'config_options' struct. I find the notion ridiculous that I would need to change a function's name or arguments every time the internals of the function are adjusted or when an options struct obtains a new field. Plus, there is already an aptly named parameter of type 'config_options' with which to hold options for the config machinery. This struct is also added to in a later patch to include commondir so that the gitdir vs commondir issue can be resolved.
What is the next step, then? You can find the notion ridiculous but it's how this project has worked in my experience (and how other projects with similar patch-based workflows work).
I also don't really understand why it is so bad to have to care about API compatibility when it is so simple to do --- change the function signature or change the function name. That's all it takes.
Quoted 6 lines
Quoted 3 lines
- the commit message doesn't say anything about to git dir vs common dir change. It needs to, or even better, the switch to use common dir instead of git dir can happen as a separate patch.
There really isn't any switching in this patch. One of the following patches in this series addresses this problem in more detail though.
There is, because of the gitdir: behavior change.
Jonathan
Re: [PATCH v2 4/6] config: don't implicitly use gitdir
Quoted 4 lines · Jonathan Nieder
What is the next step, then? You can find the notion ridiculous but it's how this project has worked in my experience (and how other projects with similar patch-based workflows work).
Does "patch-based" have much to do with this? I agree that distributed nature of the development would bring this issue, but I tend to think that using merge/pull based workflow would not alleviate it--am I mistaken?
Re: [PATCH v2 4/6] config: don't implicitly use gitdir
Quoted 9 lines · Junio C Hamano
Quoted 3 lines · Jonathan Nieder
What is the next step, then? You can find the notion ridiculous but it's how this project has worked in my experience (and how other projects with similar patch-based workflows work).
Does "patch-based" have much to do with this? I agree that distributed nature of the development would bring this issue, but I tend to think that using merge/pull based workflow would not alleviate it--am I mistaken?
Thanks, you're right. Distributed is the relevant feature.
The same issue can even come up when using a centralized version control system like Subversion or Perforce --- without attention to API compatibility, someone's change that was thoroughly reviewed and well tested locally in a developer's working directory can introduce subtle breakage once they run "svn commit", causing it to merge with the latest upstream changes. The problem becomes more likely the more distributed a project is since each developer becomes less aware of the other changes that their modifications need to be compatible with.
Jonathan
Re: [PATCH v2 4/6] config: don't implicitly use gitdir
Quoted 22 lines · Jonathan Nieder
Quoted 9 lines · Junio C Hamano
Quoted 3 lines · Jonathan Nieder
What is the next step, then? You can find the notion ridiculous but it's how this project has worked in my experience (and how other projects with similar patch-based workflows work).
Does "patch-based" have much to do with this? I agree that distributed nature of the development would bring this issue, but I tend to think that using merge/pull based workflow would not alleviate it--am I mistaken?
Thanks, you're right. Distributed is the relevant feature.
The same issue can even come up when using a centralized version control system like Subversion or Perforce --- without attention to API compatibility, someone's change that was thoroughly reviewed and well tested locally in a developer's working directory can introduce subtle breakage once they run "svn commit", causing it to merge with the latest upstream changes. The problem becomes more likely the more distributed a project is since each developer becomes less aware of the other changes that their modifications need to be compatible with.
Quoted 1 line
Jonathan
Which would be why early integration (pu) and a good test suite are for. However, it's much easier to catch if you change the name when the function no longer behaves the same. In this case I guess you could argue that the part that changed wasn't part of the API... However, I think I'd lean towards "we had code depending on it, so yes it was".
It's ok to add new functionality only obtained by new flags or similar, but not ok to break potentially existing callers.
Thanks,
Jake
Re: [PATCH v2 4/6] config: don't implicitly use gitdir
In reply to Brandon WilliamsQuoted 6 lines · Brandon Williams
Quoted 5 lines
The same comments as before still apply:
- this changes API to make
opts->git_dirmandatory, which is error prone and easily avoidable, e.g. by makinggit_diran argument togit_config_with_options
Quoted 9 lines
I still don't agree with this. I have looked at all callers and ensured that '
git_dir' will be set when appropriate in the 'config_options' struct. I find the notion ridiculous that I would need to change a function's name or arguments every time the internals of the function are adjusted or when an options struct obtains a new field. Plus, there is already an aptly named parameter of type 'config_options' with which to hold options for the config machinery. This struct is also added to in a later patch to include commondir so that the gitdir vs commondir issue can be resolved.
I've already said "I'm OK either way for this case", but let me clarify a bit.
It's not about changing a function's internals, or even the struct obtaining a new field. The key change here is that the _interface_ changed. Callers used to be able to pass NULL for the git_dir and have the function behave one way, and now if they do so it behaves differently. That leads to spooky action at a distance. Code which you didn't know about still compiles but does something subtly different.
We can catch that at the compile stage, or we can catch it at the test stage, or we can decide it's somebody else's problem to deal with if they wrote code that the rest of the project hasn't seen.
But it is a real thing that comes up in a big, open project. There is no "looked at all the callers", because you can't see the whole universe of code. I do think it's a much bigger deal in a project like the kernel, which has hundreds of long-lasting forks. Git has only a handful, and we don't necessarily need to bend over backwards for people whose code hasn't been shared.
Quoted 6 lines
Quoted 3 lines
- the commit message doesn't say anything about to git dir vs common dir change. It needs to, or even better, the switch to use common dir instead of git dir can happen as a separate patch.
There really isn't any switching in this patch. One of the following patches in this series addresses this problem in more detail though.
I would have expected that patch to actually come earlier. That fixes the bug there, and then this conversion patch becomes that much more straightforward.
-Peff
Re: [PATCH v2 4/6] config: don't implicitly use gitdir
Quoted 32 lines · Jeff King
Quoted 6 lines · Brandon Williams
Quoted 5 lines
The same comments as before still apply:
- this changes API to make
opts->git_dirmandatory, which is error prone and easily avoidable, e.g. by makinggit_diran argument togit_config_with_optionsQuoted 9 lines
I still don't agree with this. I have looked at all callers and ensured that '
git_dir' will be set when appropriate in the 'config_options' struct. I find the notion ridiculous that I would need to change a function's name or arguments every time the internals of the function are adjusted or when an options struct obtains a new field. Plus, there is already an aptly named parameter of type 'config_options' with which to hold options for the config machinery. This struct is also added to in a later patch to include commondir so that the gitdir vs commondir issue can be resolved.I've already said "I'm OK either way for this case", but let me clarify a bit.
It's not about changing a function's internals, or even the struct obtaining a new field. The key change here is that the _interface_ changed. Callers used to be able to pass NULL for the
git_dirand have the function behave one way, and now if they do so it behaves differently. That leads to spooky action at a distance. Code which you didn't know about still compiles but does something subtly different.We can catch that at the compile stage, or we can catch it at the test stage, or we can decide it's somebody else's problem to deal with if they wrote code that the rest of the project hasn't seen.
Quoted 6 lines
But it is a real thing that comes up in a big, open project. There is no "looked at all the callers", because you can't see the whole universe of code. I do think it's a much bigger deal in a project like the kernel, which has hundreds of long-lasting forks. Git has only a handful, and we don't necessarily need to bend over backwards for people whose code hasn't been shared.
At this point I'm done arguing, I'll rename the function and drop the 'git' prefix as that's the only sensible name I can think of.
Quoted 11 lines
Quoted 7 lines
Quoted 4 lines
- the commit message doesn't say anything about to git dir vs common dir change. It needs to, or even better, the switch to use common dir instead of git dir can happen as a separate patch.
There really isn't any switching in this patch. One of the following patches in this series addresses this problem in more detail though.
I would have expected that patch to actually come earlier. That fixes the bug there, and then this conversion patch becomes that much more straightforward.
True, I can reorder the patches in v3 so that this change flows better.
Signature · 1 line
Brandon Williams
PATCH v2 5/6 setup: teach discover_git_directory to respect the commondir
In reply to Brandon WilliamsCurrently '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.
--- cache.h | 3 ++- config.c | 10 ++++++---- setup.c | 9 +++++++-- 3 files changed, 15 insertions(+), 7 deletions(-)
cache.h +2 -1
@@ -530,7 +530,8 @@ extern void setup_work_tree(void);* 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); +extern const char *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);
config.c +6 -4
@@ -1652,7 +1652,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 ;
@@ -1666,12 +1667,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 );
setup.c +7 -2
@@ -946,10 +946,12 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir, } } -const char *discover_git_directory (struct strbuf *gitdir) +const char *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))
@@ -974,8 +976,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);
@@ -983,6 +987,7 @@ 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);return NULL ; }
Signature · 1 line
2.13.1.518.g3df882009-goog
Re: [PATCH v2 5/6] setup: teach discover_git_directory to respect the commondir
Quoted 10 lines · Brandon Williams
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.
This makes sense, and I agree is the correct path forward for handling the config code's needs.
cache.h extern void setup_work_tree(void); · line 534
Quoted 11 lines
cache.h +2
-1@@ -530,7 +530,8 @@ extern void setup_work_tree(void);* 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); +extern const char *discover_git_directory (struct strbuf *commondir, +struct strbuf *gitdir);
Does the docstring above the function need updating? What happens when you are not in a worktree? Are both strbufs filled out with the same value?
That's what I'd assume (and what it looks like looking at the code), but it's probably worth being explicit.
We also return a pointer. I think this still points into the gitdir strbuf. Which I guess is reasonable, though probably should be documented.
Given that the callers only ever look at whether it's non-NULL, it probably would be better to just return a true/false value. This might be a good time to do that, because the function signature is changing already (so if we switch to the usual "0 is success", a newly added call won't silently do the wrong thing).
cache.h const char *discover_git_directory(struct strbuf *gitdir) · line 992
Quoted 7 lines
cache.h +1
-0@@ -983,6 +987,7 @@ 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);return NULL ; }
I'd have expected these resetting setlens to be paired between gitdir and commondir. And indeed, they should be; this is the same case that Dscho fixed in the first patch of his series.
I kind of wonder if one of you should take ownership and do a combined series.
-Peff
Re: [PATCH v2 5/6] setup: teach discover_git_directory to respect the commondir
Quoted 16 lines · Jeff King
Quoted 10 lines · Brandon Williams
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.
This makes sense, and I agree is the correct path forward for handling the config code's needs.
Quoted 15 lines
cache.h extern void setup_work_tree(void); · line 534
Quoted 11 lines
cache.h +2
-1@@ -530,7 +530,8 @@ extern void setup_work_tree(void);* 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); +extern const char *discover_git_directory (struct strbuf *commondir, +struct strbuf *gitdir);Does the docstring above the function need updating? What happens when you are not in a worktree? Are both strbufs filled out with the same value?
Yes I'll update the docstring to reflect the change. And yes if you aren't in a worktree, then both strbufs would hold the same value.
Quoted 7 lines
That's what I'd assume (and what it looks like looking at the code), but it's probably worth being explicit.
We also return a pointer. I think this still points into the gitdir strbuf. Which I guess is reasonable, though probably should be documented.
Quoted 5 lines
Given that the callers only ever look at whether it's non-NULL, it probably would be better to just return a true/false value. This might be a good time to do that, because the function signature is changing already (so if we switch to the usual "0 is success", a newly added call won't silently do the wrong thing).
I agree with that. I can tweak the return value to return a success code.
Quoted 13 lines
cache.h const char *discover_git_directory(struct strbuf *gitdir) · line 992
Quoted 8 lines
cache.h +1
-0@@ -983,6 +987,7 @@ 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);return NULL ; }I'd have expected these resetting setlens to be paired between gitdir and commondir. And indeed, they should be; this is the same case that Dscho fixed in the first patch of his series.
Quoted 2 lines
I kind of wonder if one of you should take ownership and do a combined series.
Yeah I think that Dschos series has less review to still take place (as he just sent out a v3) so I'll just rebase ontop of his series.
Signature · 1 line
Brandon Williams
PATCH v2 6/6 config: respect commondir
In reply to Brandon WilliamsWorktrees 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.
--- builtin/config.c | 6 ++++-- config.c | 18 ++++++++++++------ config.h | 1 + 3 files changed, 17 insertions(+), 8 deletions(-)
builtin/config.c +4 -2
@@ -539,8 +539,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.git_dir =get_git_common_dir (); +if (!nongit) { + config_options.commondir =get_git_common_dir (); + config_options.git_dir =get_git_dir (); + }if (end_null) { term ='\0' ;
config.c +12 -6
@@ -1544,8 +1544,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 repo_config =NULL ;
@@ -1609,8 +1609,11 @@ static void git_config_raw(config_fn_t fn, void *data)struct config_options opts = {0 }; opts.respect_includes =1 ; -if (have_git_dir ()) - opts.git_dir =get_git_common_dir (); +if (have_git_dir ()) { + opts.commondir =get_git_common_dir (); + opts.git_dir =get_git_dir (); + } +if (git_config_with_options (fn, data,NULL , &opts) <0 )/* * git_config_with_options() normally returns only
@@ -1657,7 +1660,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
@@ -1667,8 +1671,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);
config.h +1 -0
@@ -30,6 +30,7 @@ enum config_origin_type {struct config_options {unsigned int respect_includes :1 ; +const char *commondir;const char *git_dir; };
Signature · 1 line
2.13.1.518.g3df882009-goog
v3 cover config.h
In reply to Brandon WilliamsChanges in v3:
* tweaked the discover_git_directory function's API based on Peff's feedback
* reordered the last three patches so that they flowed a bit better
* renamed 'git_config_with_options'
* rebased ontop of v4 of Dscho's alias series
https://public-inbox.org/git/[email protected]/
Brandon Williams (6):
config: create config.h
config: remove git_config_iter
config: don't include config.h by default
setup: teach discover_git_directory to respect the commondir
config: respect commondir
config: don't implicitly use gitdir or commondir
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 | 2 + 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 | 27 +++--- 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 | 204 ++------------------------------------- color.c | 1 + column.c | 1 + compat/precompose_utf8.c | 1 + config.c | 41 ++++---- config.h | 194 +++++++++++++++++++++++++++++++++++++ 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 | 18 ++-- 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 + 147 files changed, 398 insertions(+), 229 deletions(-) create mode 100644 config.h
Signature · 1 line
2.13.1.518.g3df882009-goog
PATCH v3 1/6 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.
--- cache.h | 190 +------------------------------------------------------------ config.h | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+), 189 deletions(-) create mode 100644 config.h
cache.h +1 -189
@@ -11,6 +11,7 @@#include "string-list.h" #include "pack-revindex.h" #include "hash.h" +#include "config.h" #ifndef platform_SHA_CTX/*
@@ -1872,188 +1873,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.
@@ -2061,16 +1883,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 );
config.h new file +194 -0
194 lines not on this page · raw message
Signature · 1 line
2.13.1.518.g3df882009-goog
PATCH v3 2/6 config: remove git_config_iter
In reply to Brandon WilliamsSince there is no implementation of the function 'git_config_iter', let's stop exporting it and remove the prototype from config.h.
--- config.h | 1 - 1 file changed, 1 deletion(-)
config.h +0 -1
@@ -165,7 +165,6 @@ extern int git_configset_get_pathname(struct config_set *cs, const char *key, coextern 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);
Signature · 1 line
2.13.1.518.g3df882009-goog
PATCH v3 3/6 config: don't include config.h by default
In reply to Brandon WilliamsStop including config.h by default in cache.h. Instead only include config.h in those files which require use of the config system.
--- 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 | 2 ++ 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, 146 insertions(+), 1 deletion(-)
advice.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" int advice_push_update_rejected =1 ;int advice_push_non_ff_current =1 ;
alias.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" struct config_alias_data {
apply.c +1 -0
@@ -8,6 +8,7 @@*/ #include "cache.h" +#include "config.h" #include "blob.h" #include "delta.h" #include "diff.h"
archive-tar.c +1 -0
@@ -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"
archive-zip.c +1 -0
@@ -2,6 +2,7 @@* Copyright (c) 2006 Rene Scharfe */ #include "cache.h" +#include "config.h" #include "archive.h" #include "streaming.h" #include "utf8.h"
archive.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "refs.h" #include "commit.h" #include "tree-walk.h"
attr.c +1 -0
@@ -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"
bisect.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "diff.h" #include "revision.h"
branch.c +1 -0
@@ -1,5 +1,6 @@#include "git-compat-util.h" #include "cache.h" +#include "config.h" #include "branch.h" #include "refs.h" #include "remote.h"
builtin/add.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) 2006 Linus Torvalds */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "lockfile.h" #include "dir.h"
builtin/am.c +1 -0
@@ -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"
builtin/blame.c +2 -0
@@ -6,6 +6,8 @@*/ #include "cache.h" +#include "config.h" +#include "refs.h" #include "builtin.h" #include "commit.h" #include "diff.h"
builtin/branch.c +1 -0
@@ -6,6 +6,7 @@*/ #include "cache.h" +#include "config.h" #include "color.h" #include "refs.h" #include "commit.h"
builtin/cat-file.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "diff.h" #include "parse-options.h"
builtin/check-attr.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "attr.h" #include "quote.h" #include "parse-options.h"
builtin/check-ignore.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "dir.h" #include "quote.h" #include "pathspec.h"
builtin/check-mailmap.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "mailmap.h" #include "parse-options.h" #include "string-list.h"
builtin/checkout-index.c +1 -0
@@ -5,6 +5,7 @@* */ #include "builtin.h" +#include "config.h" #include "lockfile.h" #include "quote.h" #include "cache-tree.h"
builtin/checkout.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "lockfile.h" #include "parse-options.h" #include "refs.h"
builtin/clean.c +1 -0
@@ -8,6 +8,7 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "dir.h" #include "parse-options.h" #include "string-list.h"
builtin/clone.c +1 -0
@@ -9,6 +9,7 @@*/ #include "builtin.h" +#include "config.h" #include "lockfile.h" #include "parse-options.h" #include "fetch-pack.h"
builtin/column.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "strbuf.h" #include "parse-options.h" #include "string-list.h"
builtin/commit-tree.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "commit.h" #include "tree.h" #include "builtin.h"
builtin/commit.c +1 -0
@@ -6,6 +6,7 @@*/ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "cache-tree.h" #include "color.h"
builtin/config.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "color.h" #include "parse-options.h" #include "urlmatch.h"
builtin/count-objects.c +1 -0
@@ -5,6 +5,7 @@*/ #include "cache.h" +#include "config.h" #include "dir.h" #include "builtin.h" #include "parse-options.h"
builtin/describe.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "lockfile.h" #include "commit.h" #include "tag.h"
builtin/diff-files.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "diff.h" #include "commit.h" #include "revision.h"
builtin/diff-index.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "diff.h" #include "commit.h" #include "revision.h"
builtin/diff-tree.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "diff.h" #include "commit.h" #include "log-tree.h"
builtin/diff.c +1 -0
@@ -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"
builtin/difftool.c +1 -0
@@ -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"
builtin/fast-export.c +1 -0
@@ -5,6 +5,7 @@*/ #include "builtin.h" #include "cache.h" +#include "config.h" #include "refs.h" #include "commit.h" #include "object.h"
builtin/fetch.c +1 -0
@@ -2,6 +2,7 @@* "git fetch" */ #include "cache.h" +#include "config.h" #include "refs.h" #include "commit.h" #include "builtin.h"
builtin/fmt-merge-msg.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "refs.h" #include "commit.h" #include "diff.h"
builtin/for-each-ref.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "refs.h" #include "object.h" #include "parse-options.h"
builtin/fsck.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "tree.h" #include "blob.h"
builtin/gc.c +1 -0
@@ -11,6 +11,7 @@*/ #include "builtin.h" +#include "config.h" #include "tempfile.h" #include "lockfile.h" #include "parse-options.h"
builtin/grep.c +1 -0
@@ -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"
builtin/hash-object.c +1 -0
@@ -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"
builtin/help.c +1 -0
@@ -2,6 +2,7 @@* Builtin help command */ #include "cache.h" +#include "config.h" #include "builtin.h" #include "exec_cmd.h" #include "parse-options.h"
builtin/index-pack.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "delta.h" #include "pack.h" #include "csum-file.h"
builtin/init-db.c +1 -0
@@ -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"
builtin/log.c +1 -0
@@ -5,6 +5,7 @@* 2006 Junio Hamano */ #include "cache.h" +#include "config.h" #include "refs.h" #include "color.h" #include "commit.h"
builtin/ls-files.c +1 -0
@@ -6,6 +6,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "quote.h" #include "dir.h" #include "builtin.h"
builtin/ls-tree.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "blob.h" #include "tree.h" #include "commit.h"
builtin/merge-base.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "diff.h"
builtin/merge-file.c +1 -0
@@ -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"
builtin/merge.c +1 -0
@@ -7,6 +7,7 @@*/ #include "cache.h" +#include "config.h" #include "parse-options.h" #include "builtin.h" #include "lockfile.h"
builtin/mv.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) 2006 Johannes Schindelin */ #include "builtin.h" +#include "config.h" #include "pathspec.h" #include "lockfile.h" #include "dir.h"
builtin/name-rev.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "tag.h" #include "refs.h"
builtin/notes.c +1 -0
@@ -8,6 +8,7 @@*/ #include "cache.h" +#include "config.h" #include "builtin.h" #include "notes.h" #include "blob.h"
builtin/pack-objects.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "attr.h" #include "object.h" #include "blob.h"
builtin/patch-id.c +1 -0
@@ -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) {
builtin/pull.c +1 -0
@@ -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"
builtin/push.c +1 -0
@@ -2,6 +2,7 @@* "git push" */ #include "cache.h" +#include "config.h" #include "refs.h" #include "run-command.h" #include "builtin.h"
builtin/read-tree.c +1 -0
@@ -5,6 +5,7 @@*/ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "object.h" #include "tree.h"
builtin/rebase--helper.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "parse-options.h" #include "sequencer.h"
builtin/receive-pack.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "lockfile.h" #include "pack.h" #include "refs.h"
builtin/reflog.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "lockfile.h" #include "commit.h" #include "refs.h"
builtin/remote.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "parse-options.h" #include "transport.h" #include "remote.h"
builtin/repack.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "dir.h" #include "parse-options.h" #include "run-command.h"
builtin/replace.c +1 -0
@@ -9,6 +9,7 @@*/ #include "cache.h" +#include "config.h" #include "builtin.h" #include "refs.h" #include "parse-options.h"
builtin/rerere.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "dir.h" #include "parse-options.h" #include "string-list.h"
builtin/reset.c +1 -0
@@ -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"
builtin/rev-list.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "diff.h" #include "revision.h"
builtin/rev-parse.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "quote.h"
builtin/revert.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "builtin.h" #include "parse-options.h" #include "diff.h"
builtin/rm.c +1 -0
@@ -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"
builtin/send-pack.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "pkt-line.h"
builtin/shortlog.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "commit.h" #include "diff.h" #include "string-list.h"
builtin/show-branch.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "builtin.h"
builtin/stripspace.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "parse-options.h" #include "strbuf.h"
builtin/submodule--helper.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "parse-options.h" #include "quote.h" #include "pathspec.h"
builtin/symbolic-ref.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "cache.h" #include "refs.h" #include "parse-options.h"
builtin/tag.c +1 -0
@@ -7,6 +7,7 @@*/ #include "cache.h" +#include "config.h" #include "builtin.h" #include "refs.h" #include "tag.h"
builtin/unpack-file.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" static char *create_temp_file (unsigned char *sha1) {
builtin/unpack-objects.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "object.h" #include "delta.h" #include "pack.h"
builtin/update-index.c +1 -0
@@ -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"
builtin/update-ref.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "refs.h" #include "builtin.h" #include "parse-options.h"
builtin/update-server-info.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "builtin.h" #include "parse-options.h"
builtin/var.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Eric Biederman, 2005 */ #include "builtin.h" +#include "config.h" static const char var_usage[] ="git var (-l | <variable>)" ;
builtin/verify-commit.c +1 -0
@@ -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"
builtin/verify-pack.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "config.h" #include "run-command.h" #include "parse-options.h"
builtin/verify-tag.c +1 -0
@@ -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"
builtin/worktree.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "builtin.h" #include "dir.h" #include "parse-options.h"
builtin/write-tree.c +1 -0
@@ -5,6 +5,7 @@*/ #include "builtin.h" #include "cache.h" +#include "config.h" #include "tree.h" #include "cache-tree.h" #include "parse-options.h"
cache.h +0 -1
@@ -11,7 +11,6 @@#include "string-list.h" #include "pack-revindex.h" #include "hash.h" -#include "config.h" #ifndef platform_SHA_CTX/*
color.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "color.h" static int git_use_color_default =GIT_COLOR_AUTO ;
column.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "column.h" #include "string-list.h" #include "parse-options.h"
compat/precompose_utf8.c +1 -0
@@ -6,6 +6,7 @@#define PRECOMPOSE_UNICODE_C #include "cache.h" +#include "config.h" #include "utf8.h" #include "precompose_utf8.h"
config.c +1 -0
@@ -6,6 +6,7 @@* */ #include "cache.h" +#include "config.h" #include "lockfile.h" #include "exec_cmd.h" #include "strbuf.h"
connect.c +1 -0
@@ -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"
convert.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "attr.h" #include "run-command.h" #include "quote.h"
credential-cache--daemon.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "tempfile.h" #include "credential.h" #include "unix-socket.h"
credential.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "credential.h" #include "string-list.h" #include "run-command.h"
daemon.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "pkt-line.h" #include "run-command.h" #include "strbuf.h"
diff.c +1 -0
@@ -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"
dir.c +1 -0
@@ -9,6 +9,7 @@*/ #define NO_THE_INDEX_COMPATIBILITY_MACROS #include "cache.h" +#include "config.h" #include "dir.h" #include "attr.h" #include "refs.h"
environment.c +1 -0
@@ -8,6 +8,7 @@* are. */ #include "cache.h" +#include "config.h" #include "refs.h" #include "fmt-merge-msg.h" #include "commit.h"
fast-import.c +1 -0
@@ -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"
fetch-pack.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "lockfile.h" #include "refs.h" #include "pkt-line.h"
git.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "exec_cmd.h" #include "help.h" #include "run-command.h"
gpg-interface.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "run-command.h" #include "strbuf.h" #include "gpg-interface.h"
graph.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "color.h" #include "graph.h"
grep.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "grep.h" #include "userdiff.h" #include "xdiff-interface.h"
help.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "builtin.h" #include "exec_cmd.h" #include "run-command.h"
http-backend.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "refs.h" #include "pkt-line.h" #include "object.h"
http-fetch.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "exec_cmd.h" #include "http.h" #include "walker.h"
http.c +1 -0
@@ -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"
ident.c +1 -0
@@ -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 ;
imap-send.c +1 -0
@@ -23,6 +23,7 @@*/ #include "cache.h" +#include "config.h" #include "credential.h" #include "exec_cmd.h" #include "run-command.h"
ll-merge.c +1 -0
@@ -5,6 +5,7 @@*/ #include "cache.h" +#include "config.h" #include "attr.h" #include "xdiff-interface.h" #include "run-command.h"
log-tree.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "diff.h" #include "commit.h" #include "tag.h"
mailinfo.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "utf8.h" #include "strbuf.h" #include "mailinfo.h"
merge-recursive.c +1 -0
@@ -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"
notes-utils.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "notes-utils.h"
notes.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "notes.h" #include "blob.h" #include "tree.h"
pager.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "run-command.h" #include "sigchain.h"
parse-options.c +1 -0
@@ -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"
pathspec.c +1 -0
@@ -1,5 +1,6 @@#define NO_THE_INDEX_COMPATIBILITY_MACROS #include "cache.h" +#include "config.h" #include "dir.h" #include "pathspec.h" #include "attr.h"
pretty.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "commit.h" #include "utf8.h" #include "diff.h"
prompt.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "run-command.h" #include "strbuf.h" #include "prompt.h"
read-cache.c +1 -0
@@ -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"
refs.c +1 -0
@@ -3,6 +3,7 @@*/ #include "cache.h" +#include "config.h" #include "hashmap.h" #include "lockfile.h" #include "iterator.h"
refs/files-backend.c +1 -0
@@ -1,4 +1,5 @@#include "../cache.h" +#include "../config.h" #include "../refs.h" #include "refs-internal.h" #include "ref-cache.h"
remote-curl.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "remote.h" #include "strbuf.h" #include "walker.h"
remote.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "remote.h" #include "refs.h" #include "commit.h"
rerere.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "lockfile.h" #include "string-list.h" #include "rerere.h"
send-pack.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "config.h" #include "commit.h" #include "refs.h" #include "pkt-line.h"
sequencer.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "lockfile.h" #include "sequencer.h" #include "dir.h"
setup.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "dir.h" #include "string-list.h"
sha1_file.c +1 -0
@@ -7,6 +7,7 @@* creation etc. */ #include "cache.h" +#include "config.h" #include "string-list.h" #include "lockfile.h" #include "delta.h"
sha1_name.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "tag.h" #include "commit.h" #include "tree.h"
submodule-config.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "submodule-config.h" #include "submodule.h" #include "strbuf.h"
submodule.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "submodule-config.h" #include "submodule.h" #include "dir.h"
t/helper/test-config.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "string-list.h" /*
t/helper/test-submodule-config.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "submodule-config.h" #include "submodule.h"
trailer.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "string-list.h" #include "run-command.h" #include "commit.h"
transport.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "transport.h" #include "run-command.h" #include "pkt-line.h"
unpack-trees.c +1 -0
@@ -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"
upload-pack.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "refs.h" #include "pkt-line.h" #include "sideband.h"
userdiff.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "userdiff.h" #include "attr.h"
versioncmp.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "string-list.h" /*
wrapper.c +1 -0
@@ -2,6 +2,7 @@* Various trivial helper wrappers around standard functions */ #include "cache.h" +#include "config.h" static void do_nothing (size_t size) {
xdiff-interface.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "config.h" #include "xdiff-interface.h" #include "xdiff/xtypes.h" #include "xdiff/xdiffi.h"
Signature · 1 line
2.13.1.518.g3df882009-goog
PATCH v3 4/6 setup: teach discover_git_directory to respect the commondir
In reply to Brandon WilliamsCurrently '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.
--- cache.h | 15 +++++++++------ config.c | 10 ++++++---- setup.c | 17 +++++++++++------ 3 files changed, 26 insertions(+), 16 deletions(-)
cache.h +9 -6
@@ -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);
config.c +6 -4
@@ -1655,7 +1655,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 ;
@@ -1669,12 +1670,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 );
setup.c +11 -6
@@ -946,19 +946,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 ; }/*
@@ -974,8 +976,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);
@@ -983,11 +987,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)
Signature · 1 line
2.13.1.518.g3df882009-goog
PATCH v3 5/6 config: respect commondir
In reply to Brandon WilliamsWorktrees 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.
--- config.c | 11 +++++++---- config.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-)
config.c +7 -4
@@ -1547,8 +1547,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
@@ -1660,7 +1660,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
@@ -1670,8 +1671,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);
config.h +1 -0
@@ -30,6 +30,7 @@ enum config_origin_type {struct config_options {unsigned int respect_includes :1 ; +const char *commondir;const char *git_dir; };
Signature · 1 line
2.13.1.518.g3df882009-goog
PATCH v3 6/6 config: don't implicitly use gitdir or commondir
In reply to Brandon Williams'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.
--- builtin/config.c | 26 +++++++++++++++----------- config.c | 21 +++++++++++---------- config.h | 6 +++--- 3 files changed, 29 insertions(+), 24 deletions(-)
builtin/config.c +15 -11
@@ -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;
@@ -539,6 +539,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' ;
@@ -583,9 +587,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);
config.c +11 -10
@@ -219,8 +219,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;
@@ -1549,8 +1547,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 ;
@@ -1581,9 +1577,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 ;
@@ -1614,9 +1610,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
@@ -1676,7 +1677,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);
config.h +3 -3
@@ -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 *);
Signature · 1 line
2.13.1.518.g3df882009-goog
Quoted 7 lines · Brandon Williams
Changes in v3:
* tweaked the
discover_git_directoryfunction's API based on Peff's feedback
* reordered the last three patches so that they flowed a bit better
* renamed 'git_config_with_options'
* rebased ontop of v4 of Dscho's alias series
https://public-inbox.org/git/[email protected]/
Applying this series was messier than necessary, I'd have to say, as this series would not apply cleanly on top of the result of applying Dscho's v4 on top of the same base as Dscho's v3 was applied (which is v2.13.0). It applied cleanly only when Dscho's v4 and then this series were applied on top of 02a2850a ("Sync with maint", 2017-06-13), which is a much newer commit than v2.13.0.
Which in turn means these two fixes cannot be merged to 'maint' as you two collaboratively prepared.
I've applied Dscho's v4 on top of v2.13.0 (just like his v3 was queued in my tree on the same base), and then tweaked this series to apply on top of that, so that they can go to 'maint' if we chose to.
But it is possible that during this unnecessary patch shuffling, I may have made some mistake, so please eyeball the resulting 12 patches carefully when they are pushed out.
Thanks.
Quoted 1 line
Quoted 20 lines · Junio C Hamano
Quoted 7 lines · Brandon Williams
Changes in v3:
* tweaked the
discover_git_directoryfunction's API based on Peff's feedback
* reordered the last three patches so that they flowed a bit better
* renamed 'git_config_with_options'
* rebased ontop of v4 of Dscho's alias series
https://public-inbox.org/git/[email protected]/Applying this series was messier than necessary, I'd have to say, as this series would not apply cleanly on top of the result of applying Dscho's v4 on top of the same base as Dscho's v3 was applied (which is v2.13.0). It applied cleanly only when Dscho's v4 and then this series were applied on top of
02a2850a("Sync with maint", 2017-06-13), which is a much newer commit than v2.13.0.Which in turn means these two fixes cannot be merged to 'maint' as you two collaboratively prepared.
Quoted 7 lines
I've applied Dscho's v4 on top of v2.13.0 (just like his v3 was queued in my tree on the same base), and then tweaked this series to apply on top of that, so that they can go to 'maint' if we chose to.
But it is possible that during this unnecessary patch shuffling, I may have made some mistake, so please eyeball the resulting 12 patches carefully when they are pushed out.
Ugh, I'm terribly sorry. Completely my bad as I didn't consider what you would need to do on your end. When I built my patches on top of his I naively just applied his v4 to what ever the current origin/master was at that point in time. I'll be sure to be more careful with this next time.
Signature · 1 line
Brandon Williams
Quoted 10 lines · Brandon Williams
Quoted 2 lines · Junio C Hamano
... so please eyeball the resulting 12 patches carefully when they are pushed out.
Ugh, I'm terribly sorry. Completely my bad as I didn't consider what you would need to do on your end. When I built my patches on top of his I naively just applied his v4 to what ever the current origin/master was at that point in time. I'll be sure to be more careful with this next time.
It's no big deal (otherwise I would have insisted you to rebase so that the end result can be merged to 'maint', instead of doing it myself).
But quite honestly, I do not understand why you rebased this on top of the alias thing. Help me make sure that I correctly undertand what these two topics want to do:
- The primary point of js/alias-early-config is to fix reading of pager config from a wrong place when alias expansion is involved, and its solution has a nice property that it simplifies the alias lookup and avoids the unpleasant save/restore-env dance by switching to use the early-config mechanism.
- Unfortunately, the early-config mechanism is broken with respect to multi-worktree configuration because it does not pay attention to the common-dir stuff.
- The primary objective of bw/config-h was to separate out the configuration related things out of the kitchen-sink cache.h, but as a nice side effect, it also fixes the early-config mechanism.
Assuming that the above reading of mine of these two topics are correct, we can conclude that even if we merge js/alias-early-config that forks from v2.13.0 to 'maint', the result by itself would regress the use of alias in multi-worktree configuration. For it to be useful, it must be merged after bw/config-h gets merged.
So it looks to me that it would make more sense to build bw/config-h on v2.13.0 and then base js/alias-early-config on top of the result. If Dscho is too busy to rebase and you are volunteering to help, perhaps the right way to help would be for you to do that rebasing, not rebase bw/config-h on top of js/alias-early-config, which is backwards and does not buy us very much. Of course, we could make the result of such rebasing into a single topic, but even in that case, the order of changes feel backwards if bw/config-h comes later.
Anyway, I think I have to tend to many more patches before I can push out today's integration result, so ...
Quoted 51 lines · Junio C Hamano
Quoted 10 lines · Brandon Williams
Quoted 2 lines · Junio C Hamano
... so please eyeball the resulting 12 patches carefully when they are pushed out.
Ugh, I'm terribly sorry. Completely my bad as I didn't consider what you would need to do on your end. When I built my patches on top of his I naively just applied his v4 to what ever the current origin/master was at that point in time. I'll be sure to be more careful with this next time.
It's no big deal (otherwise I would have insisted you to rebase so that the end result can be merged to 'maint', instead of doing it myself).
But quite honestly, I do not understand why you rebased this on top of the alias thing. Help me make sure that I correctly undertand what these two topics want to do:
- The primary point of js/alias-early-config is to fix reading of pager config from a wrong place when alias expansion is involved, and its solution has a nice property that it simplifies the alias lookup and avoids the unpleasant save/restore-env dance by switching to use the early-config mechanism.
- Unfortunately, the early-config mechanism is broken with respect to multi-worktree configuration because it does not pay attention to the common-dir stuff.
- The primary objective of bw/config-h was to separate out the configuration related things out of the kitchen-sink
cache.h, but as a nice side effect, it also fixes the early-config mechanism.Assuming that the above reading of mine of these two topics are correct, we can conclude that even if we merge js/alias-early-config that forks from v2.13.0 to 'maint', the result by itself would regress the use of alias in multi-worktree configuration. For it to be useful, it must be merged after bw/config-h gets merged.
So it looks to me that it would make more sense to build bw/config-h on v2.13.0 and then base js/alias-early-config on top of the result. If Dscho is too busy to rebase and you are volunteering to help, perhaps the right way to help would be for you to do that rebasing, not rebase bw/config-h on top of js/alias-early-config, which is backwards and does not buy us very much. Of course, we could make the result of such rebasing into a single topic, but even in that case, the order of changes feel backwards if bw/config-h comes later.
Quoted 4 lines
Anyway, I think I have to tend to many more patches before I can push out today's integration result, so ...
Yeah I see that the order is probably backwards. I think I just heard Dscho say "I'm too busy" and went along with just rebasing on top of his series. If you do end up feeling like this should be done differently (like if another reroll is needed etc) then I wouldn't mind taking ownership and making the order more sane.
Signature · 1 line
Brandon Williams
Quoted 7 lines · Brandon Williams
Quoted 6 lines · Junio C Hamano
Quoted 4 lines · Brandon Williams
Quoted 2 lines · Junio C Hamano
... so please eyeball the resulting 12 patches carefully when they are pushed out.
I just took a look at what you pushed out and they look good to me.
Signature · 1 line
Brandon Williams