From 3caec73b5568341c5d8f303692423a8e9fb0cb39 Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Wed, 19 Feb 2014 00:58:55 +0200 Subject: config: teach "git config --file -" to read from the standard input The patch extends git config --file interface to allow read config from stdin. Editing stdin or setting value in stdin is an error. Include by absolute path is allowed in stdin config, but not by relative path. Signed-off-by: Kirill A. Shutemov Signed-off-by: Junio C Hamano --- builtin/config.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'builtin/config.c') diff --git a/builtin/config.c b/builtin/config.c index de41ba50e..5677c942b 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -360,6 +360,9 @@ static int get_colorbool(int print) static void check_write(void) { + if (given_config_source.use_stdin) + die("writing to stdin is not supported"); + if (given_config_source.blob) die("writing config blobs is not supported"); } @@ -472,6 +475,12 @@ int cmd_config(int argc, const char **argv, const char *prefix) usage_with_options(builtin_config_usage, builtin_config_options); } + if (given_config_source.file && + !strcmp(given_config_source.file, "-")) { + given_config_source.file = NULL; + given_config_source.use_stdin = 1; + } + if (use_global_config) { char *user_config = NULL; char *xdg_config = NULL; @@ -558,6 +567,8 @@ int cmd_config(int argc, const char **argv, const char *prefix) check_argc(argc, 0, 0); if (!given_config_source.file && nongit) die("not in a git directory"); + if (given_config_source.use_stdin) + die("editing stdin is not supported"); if (given_config_source.blob) die("editing blobs is not supported"); git_config(git_default_config, NULL); -- cgit v1.2.1