git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] config: add core.sharedconfig

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Dec 9, 2010, 15:09 UTC
Message-ID
<1291907388-9068-4-git-send-email-pclouds@gmail.com>
In-Reply-To
<1291907388-9068-1-git-send-email-pclouds@gmail.com>

core.sharedconfig can take anything that resolves to a blob. $GIT_DIR/config will override the shared config. Nested shared config is not allowed.

No protection is provided. It's up to the project to maintain good config. The config could be in a separate branch that only a few people are allowed to push, for example. To be safest, just put SHA-1 there.

git-fsck and git-prune should learn about this key and protect it from being pruned.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Hopefully nobody sets core.sharedconfig = :path/to/config or similar
 And I should not open $GIT_DIR/config twice. Well, it does not hurt
 much.
 cache.h       |    1 +
 config.c      |   14 ++++++++++++++
 environment.c |    1 +
 3 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/cache.h b/cache.h
index e83bc2d..e91ce35 100644
--- a/cache.h
+++ b/cache.h
@@ -559,6 +559,7 @@ extern int read_replace_refs;
 extern int fsync_object_files;
 extern int core_preload_index;
 extern int core_apply_sparse_checkout;
+extern const char *core_shared_config;
 
 enum safe_crlf {
 	SAFE_CRLF_FALSE = 0,
diff --git a/config.c b/config.c
index e7a9ff4..735b3f4 100644
--- a/config.c
+++ b/config.c
@@ -883,6 +883,14 @@ int git_config_from_parameters(config_fn_t fn, void *data)
 	return 0;
 }
 
+static int get_shared_config(const char *var, const char *value, void *dummy)
+{
+	if (!strcmp(var, "core.sharedconfig"))
+		return git_config_string(&core_shared_config, var, value);
+
+	return 0;
+}
+
 int git_config(config_fn_t fn, void *data)
 {
 	int ret = 0, found = 0;
@@ -910,6 +918,12 @@ int git_config(config_fn_t fn, void *data)
 
 	repo_config = git_pathdup("config");
 	if (!access(repo_config, R_OK)) {
+		git_config_from_file(get_shared_config, repo_config, NULL);
+		if (core_shared_config) {
+			ret += git_config_from_sha1(fn, core_shared_config, data);
+			found += 1;
+		}
+
 		ret += git_config_from_file(fn, repo_config, data);
 		found += 1;
 	}
diff --git a/environment.c b/environment.c
index 913b058..8bfb548 100644
--- a/environment.c
+++ b/environment.c
@@ -55,6 +55,7 @@ enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
 char *notes_ref_name;
 int grafts_replace_parents = 1;
 int core_apply_sparse_checkout;
+const char *core_shared_config;
 struct startup_info *startup_info;
 
 /* Parallel index stat data preload? */
-- 
1.7.3.3.476.g893a9
Previous: Jonathan NiederNext: Thiago Farina
Message 6 of 11 in “[RFC/WIP 0/3] Shared config”
  1. Nguyễn Thái Ngọc DuyDec 9, 2010
  2. 1/3 config: read full file content before parsingNguyễn Thái Ngọc Duy, Dec 9, 2010
  3. 2/3 config: add git_config_from_sha1() to read from a blobNguyễn Thái Ngọc Duy, Dec 9, 2010
  4. Thiago FarinaDec 9, 2010
  5. Jonathan NiederDec 9, 2010
  6. 3/3 config: add core.sharedconfigNguyễn Thái Ngọc Duy, Dec 9, 2010
  7. Thiago FarinaDec 9, 2010
  8. Nguyen Thai Ngoc DuyDec 10, 2010
  9. Junio C HamanoDec 9, 2010
  10. Jonathan NiederDec 9, 2010
  11. Nguyen Thai Ngoc DuyDec 10, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.