diff mbox series

[v3,4/5] config.c: accept config_parse_options in git_config_from_stdin

Message ID 49d4b649919e5661daa2113c2f5d674c5cd8dd0e.1695330852.git.steadmon@google.com (mailing list archive)
State New, archived
Headers show
Series config-parse: create config parsing library | expand

Commit Message

Josh Steadmon Sept. 21, 2023, 9:17 p.m. UTC
From: Glen Choo <chooglen@google.com>

A later commit will move git_config_from_stdin() to a library, so it
will need to accept event listeners.

Signed-off-by: Glen Choo <chooglen@google.com>
Signed-off-by: Josh Steadmon <steadmon@google.com>
---
 config.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Jonathan Tan Oct. 23, 2023, 6:52 p.m. UTC | #1
Josh Steadmon <steadmon@google.com> writes:
> diff --git a/config.c b/config.c
> index 0c4f1a2874..50188f469a 100644
> --- a/config.c
> +++ b/config.c
> @@ -2063,12 +2063,11 @@ static int do_config_from_file(config_fn_t fn,
>  }
>  
>  static int git_config_from_stdin(config_fn_t fn, void *data,
> -				 enum config_scope scope)
> +				 enum config_scope scope,
> +				 const struct config_parse_options *config_opts)
>  {
> -	struct config_parse_options config_opts = CP_OPTS_INIT(CONFIG_ERROR_DIE);
> -
>  	return do_config_from_file(fn, CONFIG_ORIGIN_STDIN, "", NULL, stdin,
> -				   data, scope, &config_opts);
> +				   data, scope, config_opts);
>  }
>  
>  int git_config_from_file_with_options(config_fn_t fn, const char *filename,
> @@ -2303,7 +2302,8 @@ int config_with_options(config_fn_t fn, void *data,
>  	 * regular lookup sequence.
>  	 */
>  	if (config_source && config_source->use_stdin) {
> -		ret = git_config_from_stdin(fn, data, config_source->scope);
> +		ret = git_config_from_stdin(fn, data, config_source->scope,
> +					    &opts->parse_options);
>  	} else if (config_source && config_source->file) {
>  		ret = git_config_from_file_with_options(fn, config_source->file,
>  							data, config_source->scope,

Does this change the behavior of stdin config parsing from "die" to
"silent" (since there is no event emitting callback)? The only user of
stdin parsing seems to be builtin/config.c, so maybe a corresponding
change needs to be made there.
diff mbox series

Patch

diff --git a/config.c b/config.c
index 0c4f1a2874..50188f469a 100644
--- a/config.c
+++ b/config.c
@@ -2063,12 +2063,11 @@  static int do_config_from_file(config_fn_t fn,
 }
 
 static int git_config_from_stdin(config_fn_t fn, void *data,
-				 enum config_scope scope)
+				 enum config_scope scope,
+				 const struct config_parse_options *config_opts)
 {
-	struct config_parse_options config_opts = CP_OPTS_INIT(CONFIG_ERROR_DIE);
-
 	return do_config_from_file(fn, CONFIG_ORIGIN_STDIN, "", NULL, stdin,
-				   data, scope, &config_opts);
+				   data, scope, config_opts);
 }
 
 int git_config_from_file_with_options(config_fn_t fn, const char *filename,
@@ -2303,7 +2302,8 @@  int config_with_options(config_fn_t fn, void *data,
 	 * regular lookup sequence.
 	 */
 	if (config_source && config_source->use_stdin) {
-		ret = git_config_from_stdin(fn, data, config_source->scope);
+		ret = git_config_from_stdin(fn, data, config_source->scope,
+					    &opts->parse_options);
 	} else if (config_source && config_source->file) {
 		ret = git_config_from_file_with_options(fn, config_source->file,
 							data, config_source->scope,