summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--advice.c1
-rw-r--r--alias.c1
-rw-r--r--apply.c1
-rw-r--r--archive-tar.c1
-rw-r--r--archive-zip.c1
-rw-r--r--archive.c1
-rw-r--r--attr.c1
-rw-r--r--bisect.c1
-rw-r--r--branch.c1
-rw-r--r--builtin/add.c1
-rw-r--r--builtin/am.c1
-rw-r--r--builtin/blame.c1
-rw-r--r--builtin/branch.c1
-rw-r--r--builtin/cat-file.c1
-rw-r--r--builtin/check-attr.c1
-rw-r--r--builtin/check-ignore.c1
-rw-r--r--builtin/check-mailmap.c1
-rw-r--r--builtin/checkout-index.c1
-rw-r--r--builtin/checkout.c1
-rw-r--r--builtin/clean.c1
-rw-r--r--builtin/clone.c1
-rw-r--r--builtin/column.c1
-rw-r--r--builtin/commit-tree.c1
-rw-r--r--builtin/commit.c1
-rw-r--r--builtin/config.c27
-rw-r--r--builtin/count-objects.c1
-rw-r--r--builtin/describe.c1
-rw-r--r--builtin/diff-files.c1
-rw-r--r--builtin/diff-index.c1
-rw-r--r--builtin/diff-tree.c1
-rw-r--r--builtin/diff.c1
-rw-r--r--builtin/difftool.c1
-rw-r--r--builtin/fast-export.c1
-rw-r--r--builtin/fetch.c1
-rw-r--r--builtin/fmt-merge-msg.c1
-rw-r--r--builtin/for-each-ref.c1
-rw-r--r--builtin/fsck.c1
-rw-r--r--builtin/gc.c1
-rw-r--r--builtin/grep.c1
-rw-r--r--builtin/hash-object.c1
-rw-r--r--builtin/help.c1
-rw-r--r--builtin/index-pack.c1
-rw-r--r--builtin/init-db.c1
-rw-r--r--builtin/log.c1
-rw-r--r--builtin/ls-files.c1
-rw-r--r--builtin/ls-tree.c1
-rw-r--r--builtin/merge-base.c1
-rw-r--r--builtin/merge-file.c1
-rw-r--r--builtin/merge.c1
-rw-r--r--builtin/mv.c1
-rw-r--r--builtin/name-rev.c1
-rw-r--r--builtin/notes.c1
-rw-r--r--builtin/pack-objects.c1
-rw-r--r--builtin/patch-id.c1
-rw-r--r--builtin/pull.c1
-rw-r--r--builtin/push.c1
-rw-r--r--builtin/read-tree.c1
-rw-r--r--builtin/rebase--helper.c1
-rw-r--r--builtin/receive-pack.c1
-rw-r--r--builtin/reflog.c1
-rw-r--r--builtin/remote.c1
-rw-r--r--builtin/repack.c1
-rw-r--r--builtin/replace.c1
-rw-r--r--builtin/rerere.c1
-rw-r--r--builtin/reset.c1
-rw-r--r--builtin/rev-list.c1
-rw-r--r--builtin/rev-parse.c1
-rw-r--r--builtin/revert.c1
-rw-r--r--builtin/rm.c1
-rw-r--r--builtin/send-pack.c1
-rw-r--r--builtin/shortlog.c1
-rw-r--r--builtin/show-branch.c1
-rw-r--r--builtin/stripspace.c1
-rw-r--r--builtin/submodule--helper.c1
-rw-r--r--builtin/symbolic-ref.c1
-rw-r--r--builtin/tag.c1
-rw-r--r--builtin/unpack-file.c1
-rw-r--r--builtin/unpack-objects.c1
-rw-r--r--builtin/update-index.c1
-rw-r--r--builtin/update-ref.c1
-rw-r--r--builtin/update-server-info.c1
-rw-r--r--builtin/var.c1
-rw-r--r--builtin/verify-commit.c1
-rw-r--r--builtin/verify-pack.c1
-rw-r--r--builtin/verify-tag.c1
-rw-r--r--builtin/worktree.c1
-rw-r--r--builtin/write-tree.c1
-rw-r--r--cache.h204
-rw-r--r--color.c1
-rw-r--r--column.c1
-rw-r--r--compat/precompose_utf8.c1
-rw-r--r--config.c41
-rw-r--r--config.h194
-rw-r--r--connect.c1
-rw-r--r--convert.c1
-rw-r--r--credential-cache--daemon.c1
-rw-r--r--credential.c1
-rw-r--r--daemon.c1
-rw-r--r--diff.c1
-rw-r--r--dir.c1
-rw-r--r--environment.c1
-rw-r--r--fast-import.c1
-rw-r--r--fetch-pack.c1
-rw-r--r--git.c1
-rw-r--r--gpg-interface.c1
-rw-r--r--graph.c1
-rw-r--r--grep.c1
-rw-r--r--help.c1
-rw-r--r--http-backend.c1
-rw-r--r--http-fetch.c1
-rw-r--r--http.c1
-rw-r--r--ident.c1
-rw-r--r--imap-send.c1
-rw-r--r--ll-merge.c1
-rw-r--r--log-tree.c1
-rw-r--r--mailinfo.c1
-rw-r--r--merge-recursive.c1
-rw-r--r--notes-utils.c1
-rw-r--r--notes.c1
-rw-r--r--pager.c1
-rw-r--r--parse-options.c1
-rw-r--r--pathspec.c1
-rw-r--r--pretty.c1
-rw-r--r--prompt.c1
-rw-r--r--read-cache.c1
-rw-r--r--refs.c1
-rw-r--r--refs/files-backend.c1
-rw-r--r--remote-curl.c1
-rw-r--r--remote.c1
-rw-r--r--rerere.c1
-rw-r--r--send-pack.c1
-rw-r--r--sequencer.c1
-rw-r--r--setup.c18
-rw-r--r--sha1_file.c1
-rw-r--r--sha1_name.c1
-rw-r--r--submodule-config.c1
-rw-r--r--submodule.c1
-rw-r--r--t/helper/test-config.c1
-rw-r--r--t/helper/test-submodule-config.c1
-rw-r--r--trailer.c1
-rw-r--r--transport.c1
-rw-r--r--unpack-trees.c1
-rw-r--r--upload-pack.c1
-rw-r--r--userdiff.c1
-rw-r--r--versioncmp.c1
-rw-r--r--wrapper.c1
-rw-r--r--xdiff-interface.c1
147 files changed, 397 insertions, 229 deletions
diff --git a/advice.c b/advice.c
index b84ae49..3fa04fc 100644
--- a/advice.c
+++ b/advice.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
int advice_push_update_rejected = 1;
int advice_push_non_ff_current = 1;
diff --git a/alias.c b/alias.c
index 0526304..de8e6a3 100644
--- a/alias.c
+++ b/alias.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
struct config_alias_data {
const char *alias;
diff --git a/apply.c b/apply.c
index f24014a..f7251cc 100644
--- a/apply.c
+++ b/apply.c
@@ -8,6 +8,7 @@
*/
#include "cache.h"
+#include "config.h"
#include "blob.h"
#include "delta.h"
#include "diff.h"
diff --git a/archive-tar.c b/archive-tar.c
index 073e60e..c6ed96e 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -2,6 +2,7 @@
* Copyright (c) 2005, 2006 Rene Scharfe
*/
#include "cache.h"
+#include "config.h"
#include "tar.h"
#include "archive.h"
#include "streaming.h"
diff --git a/archive-zip.c b/archive-zip.c
index 27563e9..e8913e5 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -2,6 +2,7 @@
* Copyright (c) 2006 Rene Scharfe
*/
#include "cache.h"
+#include "config.h"
#include "archive.h"
#include "streaming.h"
#include "utf8.h"
diff --git a/archive.c b/archive.c
index b15a922..60b3035 100644
--- a/archive.c
+++ b/archive.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "refs.h"
#include "commit.h"
#include "tree-walk.h"
diff --git a/attr.c b/attr.c
index 821203e..6e4b247 100644
--- a/attr.c
+++ b/attr.c
@@ -9,6 +9,7 @@
#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
+#include "config.h"
#include "exec_cmd.h"
#include "attr.h"
#include "dir.h"
diff --git a/bisect.c b/bisect.c
index 2a2b9b7..a9fd9fb 100644
--- a/bisect.c
+++ b/bisect.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "commit.h"
#include "diff.h"
#include "revision.h"
diff --git a/branch.c b/branch.c
index 985316e..a8a548c 100644
--- a/branch.c
+++ b/branch.c
@@ -1,5 +1,6 @@
#include "git-compat-util.h"
#include "cache.h"
+#include "config.h"
#include "branch.h"
#include "refs.h"
#include "remote.h"
diff --git a/builtin/add.c b/builtin/add.c
index d9a2491..f2415e9 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -4,6 +4,7 @@
* Copyright (C) 2006 Linus Torvalds
*/
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "lockfile.h"
#include "dir.h"
diff --git a/builtin/am.c b/builtin/am.c
index 3985f9a..7c7b916 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -4,6 +4,7 @@
* Based on git-am.sh by Junio C Hamano.
*/
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "exec_cmd.h"
#include "parse-options.h"
diff --git a/builtin/blame.c b/builtin/blame.c
index 749ad7f..bda1a78 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -6,6 +6,7 @@
*/
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "commit.h"
#include "diff.h"
diff --git a/builtin/branch.c b/builtin/branch.c
index 83fcda4..c958e93 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -6,6 +6,7 @@
*/
#include "cache.h"
+#include "config.h"
#include "color.h"
#include "refs.h"
#include "commit.h"
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 4bffd7a..7efbc40 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -4,6 +4,7 @@
* Copyright (C) Linus Torvalds, 2005
*/
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "diff.h"
#include "parse-options.h"
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 4d01ca0..91444dc 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "attr.h"
#include "quote.h"
#include "parse-options.h"
diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c
index c7b8c08..3e280b9 100644
--- a/builtin/check-ignore.c
+++ b/builtin/check-ignore.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "dir.h"
#include "quote.h"
#include "pathspec.h"
diff --git a/builtin/check-mailmap.c b/builtin/check-mailmap.c
index cf0f54f..cdce144 100644
--- a/builtin/check-mailmap.c
+++ b/builtin/check-mailmap.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "config.h"
#include "mailmap.h"
#include "parse-options.h"
#include "string-list.h"
diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c
index 07631d0..39c8be0 100644
--- a/builtin/checkout-index.c
+++ b/builtin/checkout-index.c
@@ -5,6 +5,7 @@
*
*/
#include "builtin.h"
+#include "config.h"
#include "lockfile.h"
#include "quote.h"
#include "cache-tree.h"
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 1624eed..9661e1b 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "config.h"
#include "lockfile.h"
#include "parse-options.h"
#include "refs.h"
diff --git a/builtin/clean.c b/builtin/clean.c
index 142bf66..ed95413 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -8,6 +8,7 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "dir.h"
#include "parse-options.h"
#include "string-list.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index a2ea019..08b5cc4 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -9,6 +9,7 @@
*/
#include "builtin.h"
+#include "config.h"
#include "lockfile.h"
#include "parse-options.h"
#include "fetch-pack.h"
diff --git a/builtin/column.c b/builtin/column.c
index 33314b4..0c3223d 100644
--- a/builtin/column.c
+++ b/builtin/column.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "strbuf.h"
#include "parse-options.h"
#include "string-list.h"
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index f39c2b2..a4a923d 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -4,6 +4,7 @@
* Copyright (C) Linus Torvalds, 2005
*/
#include "cache.h"
+#include "config.h"
#include "commit.h"
#include "tree.h"
#include "builtin.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index 5968970..021070e 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -6,6 +6,7 @@
*/
#include "cache.h"
+#include "config.h"
#include "lockfile.h"
#include "cache-tree.h"
#include "color.h"
diff --git a/builtin/config.c b/builtin/config.c
index 7f6c25d..82db29f 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "color.h"
#include "parse-options.h"
#include "urlmatch.h"
@@ -242,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;
@@ -320,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)
@@ -352,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"))
@@ -441,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;
@@ -538,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';
@@ -582,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);
diff --git a/builtin/count-objects.c b/builtin/count-objects.c
index acb0594..1d82e61 100644
--- a/builtin/count-objects.c
+++ b/builtin/count-objects.c
@@ -5,6 +5,7 @@
*/
#include "cache.h"
+#include "config.h"
#include "dir.h"
#include "builtin.h"
#include "parse-options.h"
diff --git a/builtin/describe.c b/builtin/describe.c
index 893c878..70eb144 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "lockfile.h"
#include "commit.h"
#include "tag.h"
diff --git a/builtin/diff-files.c b/builtin/diff-files.c
index c97069a..17bf84d 100644
--- a/builtin/diff-files.c
+++ b/builtin/diff-files.c
@@ -4,6 +4,7 @@
* Copyright (C) Linus Torvalds, 2005
*/
#include "cache.h"
+#include "config.h"
#include "diff.h"
#include "commit.h"
#include "revision.h"
diff --git a/builtin/diff-index.c b/builtin/diff-index.c
index d59bf6c..185e6f9 100644
--- a/builtin/diff-index.c
+++ b/builtin/diff-index.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "diff.h"
#include "commit.h"
#include "revision.h"
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index 7e15d01..31d2cb4 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "diff.h"
#include "commit.h"
#include "log-tree.h"
diff --git a/builtin/diff.c b/builtin/diff.c
index d9152c2..7cde6ab 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -4,6 +4,7 @@
* Copyright (c) 2006 Junio C Hamano
*/
#include "cache.h"
+#include "config.h"
#include "lockfile.h"
#include "color.h"
#include "commit.h"
diff --git a/builtin/difftool.c b/builtin/difftool.c
index b9a892f..9199227 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -12,6 +12,7 @@
* Copyright (C) 2016 Johannes Schindelin
*/
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "run-command.h"
#include "exec_cmd.h"
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index a932be0..12d501b 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -5,6 +5,7 @@
*/
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "refs.h"
#include "commit.h"
#include "object.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 100248c..16cf842 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -2,6 +2,7 @@
* "git fetch"
*/
#include "cache.h"
+#include "config.h"
#include "refs.h"
#include "commit.h"
#include "builtin.h"
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 70137b0..10cbb43 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "refs.h"
#include "commit.h"
#include "diff.h"
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index eca365b..52be99c 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "refs.h"
#include "object.h"
#include "parse-options.h"
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 3a2c27f..87c6756 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "commit.h"
#include "tree.h"
#include "blob.h"
diff --git a/builtin/gc.c b/builtin/gc.c
index f484eda..bd91f13 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -11,6 +11,7 @@
*/
#include "builtin.h"
+#include "config.h"
#include "tempfile.h"
#include "lockfile.h"
#include "parse-options.h"
diff --git a/builtin/grep.c b/builtin/grep.c
index 3e4b960..f61a9d9 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -4,6 +4,7 @@
* Copyright (c) 2006 Junio C Hamano
*/
#include "cache.h"
+#include "config.h"
#include "blob.h"
#include "tree.h"
#include "commit.h"
diff --git a/builtin/hash-object.c b/builtin/hash-object.c
index bbeaf20..d04baf9 100644
--- a/builtin/hash-object.c
+++ b/builtin/hash-object.c
@@ -5,6 +5,7 @@
* Copyright (C) Junio C Hamano, 2005
*/
#include "builtin.h"
+#include "config.h"
#include "blob.h"
#include "quote.h"
#include "parse-options.h"
diff --git a/builtin/help.c b/builtin/help.c
index 49f7a07..334a849 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -2,6 +2,7 @@
* Builtin help command
*/
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "exec_cmd.h"
#include "parse-options.h"
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 04b9dca..edc1a91 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "config.h"
#include "delta.h"
#include "pack.h"
#include "csum-file.h"
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 8a6acb0..47823f9 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -4,6 +4,7 @@
* Copyright (C) Linus Torvalds, 2005
*/
#include "cache.h"
+#include "config.h"
#include "refs.h"
#include "builtin.h"
#include "exec_cmd.h"
diff --git a/builtin/log.c b/builtin/log.c
index 998437b..8ca1de9 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -5,6 +5,7 @@
* 2006 Junio Hamano
*/
#include "cache.h"
+#include "config.h"
#include "refs.h"
#include "color.h"
#include "commit.h"
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index cdc1cfd..b12d0bb 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -6,6 +6,7 @@
* Copyright (C) Linus Torvalds, 2005
*/
#include "cache.h"
+#include "config.h"
#include "quote.h"
#include "dir.h"
#include "builtin.h"
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index ee7b293..ef96540 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -4,6 +4,7 @@
* Copyright (C) Linus Torvalds, 2005
*/
#include "cache.h"
+#include "config.h"
#include "blob.h"
#include "tree.h"
#include "commit.h"
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index 0c36a70..6dbd167 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "commit.h"
#include "refs.h"
#include "diff.h"
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 47dde7c..b08803e 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "xdiff/xdiff.h"
#include "xdiff-interface.h"
#include "parse-options.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index 84970cd..900bafd 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -7,6 +7,7 @@
*/
#include "cache.h"
+#include "config.h"
#include "parse-options.h"
#include "builtin.h"
#include "lockfile.h"
diff --git a/builtin/mv.c b/builtin/mv.c
index 61d2003..dcf6736 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -4,6 +4,7 @@
* Copyright (C) 2006 Johannes Schindelin
*/
#include "builtin.h"
+#include "config.h"
#include "pathspec.h"
#include "lockfile.h"
#include "dir.h"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 7fc7e66..e21715f 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "commit.h"
#include "tag.h"
#include "refs.h"
diff --git a/builtin/notes.c b/builtin/notes.c
index c939a84..77573cf 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -8,6 +8,7 @@
*/
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "notes.h"
#include "blob.h"
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index f672225..d5e96ed 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "attr.h"
#include "object.h"
#include "blob.h"
diff --git a/builtin/patch-id.c b/builtin/patch-id.c
index 81552e0..970d0d3 100644
--- a/builtin/patch-id.c
+++ b/builtin/patch-id.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "config.h"
static void flush_current_id(int patchlen, struct object_id *id, struct object_id *result)
{
diff --git a/builtin/pull.c b/builtin/pull.c
index 69417e4..2ce311a 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -6,6 +6,7 @@
* Fetch one or more remote refs and merge it/them into the current HEAD.
*/
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "parse-options.h"
#include "exec_cmd.h"
diff --git a/builtin/push.c b/builtin/push.c
index 258648d..03846e8 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -2,6 +2,7 @@
* "git push"
*/
#include "cache.h"
+#include "config.h"
#include "refs.h"
#include "run-command.h"
#include "builtin.h"
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 5bfd4c9..d5f618d 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -5,6 +5,7 @@
*/
#include "cache.h"
+#include "config.h"
#include "lockfile.h"
#include "object.h"
#include "tree.h"
diff --git a/builtin/rebase--helper.c b/builtin/rebase--helper.c
index ca1ebb2..c82b4dc 100644
--- a/builtin/rebase--helper.c
+++ b/builtin/rebase--helper.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "parse-options.h"
#include "sequencer.h"
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index b1706a5..71c0c76 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "config.h"
#include "lockfile.h"
#include "pack.h"
#include "refs.h"
diff --git a/builtin/reflog.c b/builtin/reflog.c
index 920c16d..44cdc2d 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "config.h"
#include "lockfile.h"
#include "commit.h"
#include "refs.h"
diff --git a/builtin/remote.c b/builtin/remote.c
index f1a88fe..6273c0c 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "config.h"
#include "parse-options.h"
#include "transport.h"
#include "remote.h"
diff --git a/builtin/repack.c b/builtin/repack.c
index 38ba4ef..f17a68a 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "dir.h"
#include "parse-options.h"
#include "run-command.h"
diff --git a/builtin/replace.c b/builtin/replace.c
index c921bc9..80a15cf 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -9,6 +9,7 @@
*/
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "refs.h"
#include "parse-options.h"
diff --git a/builtin/rerere.c b/builtin/rerere.c
index 1bf7242..ffb66e2 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "dir.h"
#include "parse-options.h"
#include "string-list.h"
diff --git a/builtin/reset.c b/builtin/reset.c
index 45001e5..7aeaea2 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -8,6 +8,7 @@
* Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano
*/
#include "builtin.h"
+#include "config.h"
#include "lockfile.h"
#include "tag.h"
#include "object.h"
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index b250c51..95d84d5 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "commit.h"
#include "diff.h"
#include "revision.h"
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index efdc144..c78b7b3 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -4,6 +4,7 @@
* Copyright (C) Linus Torvalds, 2005
*/
#include "cache.h"
+#include "config.h"
#include "commit.h"
#include "refs.h"
#include "quote.h"
diff --git a/builtin/revert.c b/builtin/revert.c
index 345d958..16028b9 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "parse-options.h"
#include "diff.h"
diff --git a/builtin/rm.c b/builtin/rm.c
index b39f10f..52826d1 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -4,6 +4,7 @@
* Copyright (C) Linus Torvalds 2006
*/
#include "builtin.h"
+#include "config.h"
#include "lockfile.h"
#include "dir.h"
#include "cache-tree.h"
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index b8e2e74..633e0c3 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "config.h"
#include "commit.h"
#include "refs.h"
#include "pkt-line.h"
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 7cff183..43c4799 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "commit.h"
#include "diff.h"
#include "string-list.h"
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 3636a05..527f69e 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "commit.h"
#include "refs.h"
#include "builtin.h"
diff --git a/builtin/stripspace.c b/builtin/stripspace.c
index 1e62a00..bdf0328 100644
--- a/builtin/stripspace.c
+++ b/builtin/stripspace.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "parse-options.h"
#include "strbuf.h"
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 1b4d2b3..8517032 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "parse-options.h"
#include "quote.h"
#include "pathspec.h"
diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c
index 70addef..df75cb9 100644
--- a/builtin/symbolic-ref.c
+++ b/builtin/symbolic-ref.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "config.h"
#include "cache.h"
#include "refs.h"
#include "parse-options.h"
diff --git a/builtin/tag.c b/builtin/tag.c
index 1f74a56..01154ea 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -7,6 +7,7 @@
*/
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "refs.h"
#include "tag.h"
diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c
index 6fc6bcd..73f1334 100644
--- a/builtin/unpack-file.c
+++ b/builtin/unpack-file.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "config.h"
static char *create_temp_file(unsigned char *sha1)
{
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 8bc9997..193f8b9 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "object.h"
#include "delta.h"
#include "pack.h"
diff --git a/builtin/update-index.c b/builtin/update-index.c
index f99b1e5..56721cf 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -4,6 +4,7 @@
* Copyright (C) Linus Torvalds, 2005
*/
#include "cache.h"
+#include "config.h"
#include "lockfile.h"
#include "quote.h"
#include "cache-tree.h"
diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index 0b2ecf4..40ccfc1 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "refs.h"
#include "builtin.h"
#include "parse-options.h"
diff --git a/builtin/update-server-info.c b/builtin/update-server-info.c
index 6c8cc3e..873070e 100644
--- a/builtin/update-server-info.c
+++ b/builtin/update-server-info.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "parse-options.h"
diff --git a/builtin/var.c b/builtin/var.c
index aedbb53..6c6f46b 100644
--- a/builtin/var.c
+++ b/builtin/var.c
@@ -4,6 +4,7 @@
* Copyright (C) Eric Biederman, 2005
*/
#include "builtin.h"
+#include "config.h"
static const char var_usage[] = "git var (-l | <variable>)";
diff --git a/builtin/verify-commit.c b/builtin/verify-commit.c
index 05b734e..ba38ac9 100644
--- a/builtin/verify-commit.c
+++ b/builtin/verify-commit.c
@@ -6,6 +6,7 @@
* Based on git-verify-tag
*/
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "commit.h"
#include "run-command.h"
diff --git a/builtin/verify-pack.c b/builtin/verify-pack.c
index c94e156..c2a1a5c 100644
--- a/builtin/verify-pack.c
+++ b/builtin/verify-pack.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "run-command.h"
#include "parse-options.h"
diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index 5199553..f9a5f75 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -6,6 +6,7 @@
* Based on git-verify-tag.sh
*/
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "tag.h"
#include "run-command.h"
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 793306e..0c5476e 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "dir.h"
#include "parse-options.h"
diff --git a/builtin/write-tree.c b/builtin/write-tree.c
index 084c0df..bd0a78a 100644
--- a/builtin/write-tree.c
+++ b/builtin/write-tree.c
@@ -5,6 +5,7 @@
*/
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "tree.h"
#include "cache-tree.h"
#include "parse-options.h"
diff --git a/cache.h b/cache.h
index a666aaf..96055c2 100644
--- a/cache.h
+++ b/cache.h
@@ -525,12 +525,15 @@ extern void set_git_work_tree(const char *tree);
extern void setup_work_tree(void);
/*
- * Find GIT_DIR of the repository that contains the current working directory,
- * without changing the working directory or other global state. The result is
- * appended to gitdir. The return value is either NULL if no repository was
- * found, or pointing to the path inside gitdir's buffer.
- */
-extern const char *discover_git_directory(struct strbuf *gitdir);
+ * Find the commondir and gitdir of the repository that contains the current
+ * working directory, without changing the working directory or other global
+ * state. The result is appended to commondir and gitdir. If the discovered
+ * gitdir does not correspond to a worktree, then 'commondir' and 'gitdir' will
+ * both have the same result appended to the buffer. The return value is
+ * either 0 upon success and non-zero if no repository was found.
+ */
+extern int discover_git_directory(struct strbuf *commondir,
+ struct strbuf *gitdir);
extern const char *setup_git_directory_gently(int *);
extern const char *setup_git_directory(void);
extern char *prefix_path(const char *prefix, int len, const char *path);
@@ -1879,188 +1882,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.
@@ -2068,16 +1892,6 @@ extern int git_config_get_expiry(const char *key, const char **output);
*/
extern int ignore_untracked_cache_config;
-struct key_value_info {
- const char *filename;
- int linenr;
- enum config_origin_type origin_type;
- enum config_scope scope;
-};
-
-extern NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3)));
-extern NORETURN void git_die_config_linenr(const char *key, const char *filename, int linenr);
-
extern int committer_ident_sufficiently_given(void);
extern int author_ident_sufficiently_given(void);
diff --git a/color.c b/color.c
index dee6155..31b6207 100644
--- a/color.c
+++ b/color.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "color.h"
static int git_use_color_default = GIT_COLOR_AUTO;
diff --git a/column.c b/column.c
index d55ead1..ff7bdab 100644
--- a/column.c
+++ b/column.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "column.h"
#include "string-list.h"
#include "parse-options.h"
diff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c
index 4293b53..de61c15 100644
--- a/compat/precompose_utf8.c
+++ b/compat/precompose_utf8.c
@@ -6,6 +6,7 @@
#define PRECOMPOSE_UNICODE_C
#include "cache.h"
+#include "config.h"
#include "utf8.h"
#include "precompose_utf8.h"
diff --git a/config.c b/config.c
index 547daf8..6f0f8b3 100644
--- a/config.c
+++ b/config.c
@@ -6,6 +6,7 @@
*
*/
#include "cache.h"
+#include "config.h"
#include "lockfile.h"
#include "exec_cmd.h"
#include "strbuf.h"
@@ -218,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;
@@ -1546,10 +1545,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);
- else if (have_git_dir())
- repo_config = git_pathdup("config");
+ if (opts->commondir)
+ repo_config = mkpathdup("%s/config", opts->commondir);
else
repo_config = NULL;
@@ -1580,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;
@@ -1613,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
@@ -1654,11 +1656,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
@@ -1668,12 +1672,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);
+ config_with_options(cb, data, NULL, &opts);
- strbuf_release(&buf);
+ strbuf_release(&commondir);
+ strbuf_release(&gitdir);
}
static void git_config_check_init(void);
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..9e038cc
--- /dev/null
+++ b/config.h
@@ -0,0 +1,194 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+/* git_config_parse_key() returns these negated: */
+#define CONFIG_INVALID_KEY 1
+#define CONFIG_NO_SECTION_OR_NAME 2
+/* git_config_set_gently(), git_config_set_multivar_gently() return the above or these: */
+#define CONFIG_NO_LOCK -1
+#define CONFIG_INVALID_FILE 3
+#define CONFIG_NO_WRITE 4
+#define CONFIG_NOTHING_SET 5
+#define CONFIG_INVALID_PATTERN 6
+#define CONFIG_GENERIC_ERROR 7
+
+#define CONFIG_REGEX_NONE ((void *)1)
+
+struct git_config_source {
+ unsigned int use_stdin:1;
+ const char *file;
+ const char *blob;
+};
+
+enum config_origin_type {
+ CONFIG_ORIGIN_BLOB,
+ CONFIG_ORIGIN_FILE,
+ CONFIG_ORIGIN_STDIN,
+ CONFIG_ORIGIN_SUBMODULE_BLOB,
+ CONFIG_ORIGIN_CMDLINE
+};
+
+struct config_options {
+ unsigned int respect_includes : 1;
+ const char *commondir;
+ 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 config_with_options(config_fn_t fn, void *,
+ struct git_config_source *config_source,
+ const struct config_options *opts);
+extern int git_parse_ulong(const char *, unsigned long *);
+extern int git_parse_maybe_bool(const char *);
+extern int git_config_int(const char *, const char *);
+extern int64_t git_config_int64(const char *, const char *);
+extern unsigned long git_config_ulong(const char *, const char *);
+extern ssize_t git_config_ssize_t(const char *, const char *);
+extern int git_config_bool_or_int(const char *, const char *, int *);
+extern int git_config_bool(const char *, const char *);
+extern int git_config_maybe_bool(const char *, const char *);
+extern int git_config_string(const char **, const char *, const char *);
+extern int git_config_pathname(const char **, const char *, const char *);
+extern int git_config_set_in_file_gently(const char *, const char *, const char *);
+extern void git_config_set_in_file(const char *, const char *, const char *);
+extern int git_config_set_gently(const char *, const char *);
+extern void git_config_set(const char *, const char *);
+extern int git_config_parse_key(const char *, char **, int *);
+extern int git_config_key_is_valid(const char *key);
+extern int git_config_set_multivar_gently(const char *, const char *, const char *, int);
+extern void git_config_set_multivar(const char *, const char *, const char *, int);
+extern int git_config_set_multivar_in_file_gently(const char *, const char *, const char *, const char *, int);
+extern void git_config_set_multivar_in_file(const char *, const char *, const char *, const char *, int);
+extern int git_config_rename_section(const char *, const char *);
+extern int git_config_rename_section_in_file(const char *, const char *, const char *);
+extern const char *git_etc_gitconfig(void);
+extern int git_env_bool(const char *, int);
+extern unsigned long git_env_ulong(const char *, unsigned long);
+extern int git_config_system(void);
+extern int config_error_nonbool(const char *);
+#if defined(__GNUC__)
+#define config_error_nonbool(s) (config_error_nonbool(s), const_error())
+#endif
+
+extern int git_config_parse_parameter(const char *, config_fn_t fn, void *data);
+
+enum config_scope {
+ CONFIG_SCOPE_UNKNOWN = 0,
+ CONFIG_SCOPE_SYSTEM,
+ CONFIG_SCOPE_GLOBAL,
+ CONFIG_SCOPE_REPO,
+ CONFIG_SCOPE_CMDLINE,
+};
+
+extern enum config_scope current_config_scope(void);
+extern const char *current_config_origin_type(void);
+extern const char *current_config_name(void);
+
+struct config_include_data {
+ int depth;
+ config_fn_t fn;
+ void *data;
+ const struct config_options *opts;
+};
+#define CONFIG_INCLUDE_INIT { 0 }
+extern int git_config_include(const char *name, const char *value, void *data);
+
+/*
+ * Match and parse a config key of the form:
+ *
+ * section.(subsection.)?key
+ *
+ * (i.e., what gets handed to a config_fn_t). The caller provides the section;
+ * we return -1 if it does not match, 0 otherwise. The subsection and key
+ * out-parameters are filled by the function (and *subsection is NULL if it is
+ * missing).
+ *
+ * If the subsection pointer-to-pointer passed in is NULL, returns 0 only if
+ * there is no subsection at all.
+ */
+extern int parse_config_key(const char *var,
+ const char *section,
+ const char **subsection, int *subsection_len,
+ const char **key);
+
+struct config_set_element {
+ struct hashmap_entry ent;
+ char *key;
+ struct string_list value_list;
+};
+
+struct configset_list_item {
+ struct config_set_element *e;
+ int value_index;
+};
+
+/*
+ * the contents of the list are ordered according to their
+ * position in the config files and order of parsing the files.
+ * (i.e. key-value pair at the last position of .git/config will
+ * be at the last item of the list)
+ */
+struct configset_list {
+ struct configset_list_item *items;
+ unsigned int nr, alloc;
+};
+
+struct config_set {
+ struct hashmap config_hash;
+ int hash_initialized;
+ struct configset_list list;
+};
+
+extern void git_configset_init(struct config_set *cs);
+extern int git_configset_add_file(struct config_set *cs, const char *filename);
+extern int git_configset_get_value(struct config_set *cs, const char *key, const char **value);
+extern const struct string_list *git_configset_get_value_multi(struct config_set *cs, const char *key);
+extern void git_configset_clear(struct config_set *cs);
+extern int git_configset_get_string_const(struct config_set *cs, const char *key, const char **dest);
+extern int git_configset_get_string(struct config_set *cs, const char *key, char **dest);
+extern int git_configset_get_int(struct config_set *cs, const char *key, int *dest);
+extern int git_configset_get_ulong(struct config_set *cs, const char *key, unsigned long *dest);
+extern int git_configset_get_bool(struct config_set *cs, const char *key, int *dest);
+extern int git_configset_get_bool_or_int(struct config_set *cs, const char *key, int *is_bool, int *dest);
+extern int git_configset_get_maybe_bool(struct config_set *cs, const char *key, int *dest);
+extern int git_configset_get_pathname(struct config_set *cs, const char *key, const char **dest);
+
+extern int git_config_get_value(const char *key, const char **value);
+extern const struct string_list *git_config_get_value_multi(const char *key);
+extern void git_config_clear(void);
+extern int git_config_get_string_const(const char *key, const char **dest);
+extern int git_config_get_string(const char *key, char **dest);
+extern int git_config_get_int(const char *key, int *dest);
+extern int git_config_get_ulong(const char *key, unsigned long *dest);
+extern int git_config_get_bool(const char *key, int *dest);
+extern int git_config_get_bool_or_int(const char *key, int *is_bool, int *dest);
+extern int git_config_get_maybe_bool(const char *key, int *dest);
+extern int git_config_get_pathname(const char *key, const char **dest);
+extern int git_config_get_untracked_cache(void);
+extern int git_config_get_split_index(void);
+extern int git_config_get_max_percent_split_change(void);
+
+/* This dies if the configured or default date is in the future */
+extern int git_config_get_expiry(const char *key, const char **output);
+
+struct key_value_info {
+ const char *filename;
+ int linenr;
+ enum config_origin_type origin_type;
+ enum config_scope scope;
+};
+
+extern NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3)));
+extern NORETURN void git_die_config_linenr(const char *key, const char *filename, int linenr);
+
+#endif /* CONFIG_H */
diff --git a/connect.c b/connect.c
index c72b1d1..e78d3f4 100644
--- a/connect.c
+++ b/connect.c
@@ -1,5 +1,6 @@
#include "git-compat-util.h"
#include "cache.h"
+#include "config.h"
#include "pkt-line.h"
#include "quote.h"
#include "refs.h"
diff --git a/convert.c b/convert.c
index 4097f52..7d2a519 100644
--- a/convert.c
+++ b/convert.c
@@ -1,5 +1,6 @@
#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
+#include "config.h"
#include "attr.h"
#include "run-command.h"
#include "quote.h"
diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c
index f3814cc..0d5c625 100644
--- a/credential-cache--daemon.c
+++ b/credential-cache--daemon.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "tempfile.h"
#include "credential.h"
#include "unix-socket.h"
diff --git a/credential.c b/credential.c
index aa99666..67a5233 100644
--- a/credential.c
+++ b/credential.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "credential.h"
#include "string-list.h"
#include "run-command.h"
diff --git a/daemon.c b/daemon.c
index ac7181a..3074707 100644
--- a/daemon.c
+++ b/daemon.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "pkt-line.h"
#include "run-command.h"
#include "strbuf.h"
diff --git a/diff.c b/diff.c
index e3d7e91..41295d4 100644
--- a/diff.c
+++ b/diff.c
@@ -2,6 +2,7 @@
* Copyright (C) 2005 Junio C Hamano
*/
#include "cache.h"
+#include "config.h"
#include "tempfile.h"
#include "quote.h"
#include "diff.h"
diff --git a/dir.c b/dir.c
index 6687d84..f679547 100644
--- a/dir.c
+++ b/dir.c
@@ -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"
diff --git a/environment.c b/environment.c
index aa478e7..d40b21f 100644
--- a/environment.c
+++ b/environment.c
@@ -8,6 +8,7 @@
* are.
*/
#include "cache.h"
+#include "config.h"
#include "refs.h"
#include "fmt-merge-msg.h"
#include "commit.h"
diff --git a/fast-import.c b/fast-import.c
index fc2b220..12b90fe 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -154,6 +154,7 @@ Format of STDIN stream:
#include "builtin.h"
#include "cache.h"
+#include "config.h"
#include "lockfile.h"
#include "object.h"
#include "blob.h"
diff --git a/fetch-pack.c b/fetch-pack.c
index cd86865..fbbc99c 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "lockfile.h"
#include "refs.h"
#include "pkt-line.h"
diff --git a/git.c b/git.c
index 6150d6d..5be27b0 100644
--- a/git.c
+++ b/git.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "config.h"
#include "exec_cmd.h"
#include "help.h"
#include "run-command.h"
diff --git a/gpg-interface.c b/gpg-interface.c
index e44cc27..8ab32df 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "run-command.h"
#include "strbuf.h"
#include "gpg-interface.h"
diff --git a/graph.c b/graph.c
index 8b9049d..e7e2065 100644
--- a/graph.c
+++ b/graph.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "commit.h"
#include "color.h"
#include "graph.h"
diff --git a/grep.c b/grep.c
index 06c4c24..1fca83b 100644
--- a/grep.c
+++ b/grep.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "grep.h"
#include "userdiff.h"
#include "xdiff-interface.h"
diff --git a/help.c b/help.c
index 5cdfac7..8ba0777 100644
--- a/help.c
+++ b/help.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "exec_cmd.h"
#include "run-command.h"
diff --git a/http-backend.c b/http-backend.c
index ba5ff1a..519025d 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "refs.h"
#include "pkt-line.h"
#include "object.h"
diff --git a/http-fetch.c b/http-fetch.c
index 3b556d6..8af3800 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "exec_cmd.h"
#include "http.h"
#include "walker.h"
diff --git a/http.c b/http.c
index d2e11ec..013bb0c 100644
--- a/http.c
+++ b/http.c
@@ -1,5 +1,6 @@
#include "git-compat-util.h"
#include "http.h"
+#include "config.h"
#include "pack.h"
#include "sideband.h"
#include "run-command.h"
diff --git a/ident.c b/ident.c
index 91c7609..327abe5 100644
--- a/ident.c
+++ b/ident.c
@@ -6,6 +6,7 @@
* Copyright (C) 2005 Linus Torvalds
*/
#include "cache.h"
+#include "config.h"
static struct strbuf git_default_name = STRBUF_INIT;
static struct strbuf git_default_email = STRBUF_INIT;
diff --git a/imap-send.c b/imap-send.c
index 8575916..59e9b12 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -23,6 +23,7 @@
*/
#include "cache.h"
+#include "config.h"
#include "credential.h"
#include "exec_cmd.h"
#include "run-command.h"
diff --git a/ll-merge.c b/ll-merge.c
index d7eafb6..b9576ef 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -5,6 +5,7 @@
*/
#include "cache.h"
+#include "config.h"
#include "attr.h"
#include "xdiff-interface.h"
#include "run-command.h"
diff --git a/log-tree.c b/log-tree.c
index 2903874..410ab4f 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "diff.h"
#include "commit.h"
#include "tag.h"
diff --git a/mailinfo.c b/mailinfo.c
index f92cb9f..f591624 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "utf8.h"
#include "strbuf.h"
#include "mailinfo.h"
diff --git a/merge-recursive.c b/merge-recursive.c
index ce48ed7..59e5ee4 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -4,6 +4,7 @@
* The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006
*/
#include "cache.h"
+#include "config.h"
#include "advice.h"
#include "lockfile.h"
#include "cache-tree.h"
diff --git a/notes-utils.c b/notes-utils.c
index 9ebf841..9765deb 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "commit.h"
#include "refs.h"
#include "notes-utils.h"
diff --git a/notes.c b/notes.c
index 4b3a1ad..8f47c20 100644
--- a/notes.c
+++ b/notes.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "notes.h"
#include "blob.h"
#include "tree.h"
diff --git a/pager.c b/pager.c
index c113d89..4dd9e1b 100644
--- a/pager.c
+++ b/pager.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "run-command.h"
#include "sigchain.h"
diff --git a/parse-options.c b/parse-options.c
index e5ad34a..0dd9fc6 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -1,6 +1,7 @@
#include "git-compat-util.h"
#include "parse-options.h"
#include "cache.h"
+#include "config.h"
#include "commit.h"
#include "color.h"
#include "utf8.h"
diff --git a/pathspec.c b/pathspec.c
index 8284050..ecc5331 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -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"
diff --git a/pretty.c b/pretty.c
index cc099df..e4b561c 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "commit.h"
#include "utf8.h"
#include "diff.h"
diff --git a/prompt.c b/prompt.c
index 7540639..6d5885d 100644
--- a/prompt.c
+++ b/prompt.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "run-command.h"
#include "strbuf.h"
#include "prompt.h"
diff --git a/read-cache.c b/read-cache.c
index f026920..ad692e1 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -5,6 +5,7 @@
*/
#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
+#include "config.h"
#include "tempfile.h"
#include "lockfile.h"
#include "cache-tree.h"
diff --git a/refs.c b/refs.c
index f0685c9..84112c8 100644
--- a/refs.c
+++ b/refs.c
@@ -3,6 +3,7 @@
*/
#include "cache.h"
+#include "config.h"
#include "hashmap.h"
#include "lockfile.h"
#include "iterator.h"
diff --git a/refs/files-backend.c b/refs/files-backend.c
index d8b3f73..621a408 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1,4 +1,5 @@
#include "../cache.h"
+#include "../config.h"
#include "../refs.h"
#include "refs-internal.h"
#include "ref-cache.h"
diff --git a/remote-curl.c b/remote-curl.c
index ece4599..0053b09 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "remote.h"
#include "strbuf.h"
#include "walker.h"
diff --git a/remote.c b/remote.c
index f998f98..d874825 100644
--- a/remote.c
+++ b/remote.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "remote.h"
#include "refs.h"
#include "commit.h"
diff --git a/rerere.c b/rerere.c
index c26c29f..829b3b0 100644
--- a/rerere.c
+++ b/rerere.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "lockfile.h"
#include "string-list.h"
#include "rerere.h"
diff --git a/send-pack.c b/send-pack.c
index 78bb34e..ed3cee3 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "config.h"
#include "commit.h"
#include "refs.h"
#include "pkt-line.h"
diff --git a/sequencer.c b/sequencer.c
index d63099d..224afe7 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "lockfile.h"
#include "sequencer.h"
#include "dir.h"
diff --git a/setup.c b/setup.c
index ae3e0dd..358fbc2 100644
--- a/setup.c
+++ b/setup.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "dir.h"
#include "string-list.h"
@@ -967,19 +968,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;
}
/*
@@ -995,8 +998,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);
@@ -1004,11 +1009,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)
diff --git a/sha1_file.c b/sha1_file.c
index feb227a..a900b28 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -7,6 +7,7 @@
* creation etc.
*/
#include "cache.h"
+#include "config.h"
#include "string-list.h"
#include "lockfile.h"
#include "delta.h"
diff --git a/sha1_name.c b/sha1_name.c
index 5126853..d2d732c 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "tag.h"
#include "commit.h"
#include "tree.h"
diff --git a/submodule-config.c b/submodule-config.c
index 4f58491..d8f8d5e 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "submodule-config.h"
#include "submodule.h"
#include "strbuf.h"
diff --git a/submodule.c b/submodule.c
index 1b8a3b5..da0b805 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "submodule-config.h"
#include "submodule.h"
#include "dir.h"
diff --git a/t/helper/test-config.c b/t/helper/test-config.c
index 8e3ed6a..1a7b8bd 100644
--- a/t/helper/test-config.c
+++ b/t/helper/test-config.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "string-list.h"
/*
diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c
index 2f144d5..c6c57bb 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "submodule-config.h"
#include "submodule.h"
diff --git a/trailer.c b/trailer.c
index 11f0b9f..751b56c 100644
--- a/trailer.c
+++ b/trailer.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "string-list.h"
#include "run-command.h"
#include "commit.h"
diff --git a/transport.c b/transport.c
index 9bfcf87..b999530 100644
--- a/transport.c
+++ b/transport.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "transport.h"
#include "run-command.h"
#include "pkt-line.h"
diff --git a/unpack-trees.c b/unpack-trees.c
index d38c37e..dd535bc 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1,5 +1,6 @@
#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
+#include "config.h"
#include "dir.h"
#include "tree.h"
#include "tree-walk.h"
diff --git a/upload-pack.c b/upload-pack.c
index 5330c02..7efff2f 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "refs.h"
#include "pkt-line.h"
#include "sideband.h"
diff --git a/userdiff.c b/userdiff.c
index 8b732e4..2c1502f 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "userdiff.h"
#include "attr.h"
diff --git a/versioncmp.c b/versioncmp.c
index 9f81dc1..069ee94 100644
--- a/versioncmp.c
+++ b/versioncmp.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "string-list.h"
/*
diff --git a/wrapper.c b/wrapper.c
index 4632c7d..36630e5 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -2,6 +2,7 @@
* Various trivial helper wrappers around standard functions
*/
#include "cache.h"
+#include "config.h"
static void do_nothing(size_t size)
{
diff --git a/xdiff-interface.c b/xdiff-interface.c
index d3f78ca..018e033 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "xdiff-interface.h"
#include "xdiff/xtypes.h"
#include "xdiff/xdiffi.h"