All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Josh Steadmon <steadmon@google.com>
Cc: git@vger.kernel.org, jonathantanmy@google.com,
	calvinwan@google.com, glencbz@gmail.com
Subject: Re: [PATCH v2 2/4] config: report config parse errors using cb
Date: Wed, 23 Aug 2023 18:19:33 -0700	[thread overview]
Message-ID: <xmqqttspck4a.fsf@gitster.g> (raw)
In-Reply-To: <cb92a1f2e3098bede386d04da32fcc4f27fca51f.1692827403.git.steadmon@google.com> (Josh Steadmon's message of "Wed, 23 Aug 2023 14:53:49 -0700")

Josh Steadmon <steadmon@google.com> writes:

> From: Glen Choo <chooglen@google.com>
>
> In a subsequent commit, config parsing will become its own library, and
> it's likely that the caller will want flexibility in handling errors
> (instead of being limited to the error handling we have in-tree).

And the in-tree error handling is abstracted out as the
git_config_err_fn() function; in other words, we become the first
client of the library interface, which makes sense.

> @@ -1035,8 +1088,6 @@ static int git_parse_source(struct config_source *cs, config_fn_t fn,
>  	int comment = 0;
>  	size_t baselen = 0;
>  	struct strbuf *var = &cs->var;
> ...
> +	/*
> +	 * FIXME for whatever reason, do_event passes the _previous_ event, so
> +	 * in order for our callback to receive the error event, we have to call
> +	 * do_event twice
> +	 */
> +	do_event(cs, CONFIG_EVENT_ERROR, &event_data);
> +	do_event(cs, CONFIG_EVENT_ERROR, &event_data);
> +	return -1;
>  }

This indeed is very curious and needs to be looked into before we
proceed further.  How does the current control flow cope with the
behaviour?

> @@ -2322,7 +2342,9 @@ void read_early_config(config_fn_t cb, void *data)
>   */
>  void read_very_early_config(config_fn_t cb, void *data)
>  {
> -	struct config_options opts = { 0 };
> +	struct config_options opts = {
> +		.parse_options = CP_OPTS_INIT(CONFIG_ERROR_DIE),
> +	};
>  
>  	opts.respect_includes = 1;
>  	opts.ignore_repo = 1;

This uses a bit more assignments to various members of opts. to
initialize it, which could have been done with designated
initializer, like the one in read_protected_config() used to do.

> @@ -2760,12 +2784,14 @@ int repo_config_get_pathname(struct repository *repo,
>  static void read_protected_config(void)
>  {
>  	struct config_options opts = {
> -		.respect_includes = 1,
> -		.ignore_repo = 1,
> -		.ignore_worktree = 1,
> -		.system_gently = 1,
> +		.parse_options = CP_OPTS_INIT(CONFIG_ERROR_DIE),
>  	};
>  
> +	opts.respect_includes = 1;
> +	opts.ignore_repo = 1;
> +	opts.ignore_worktree = 1;
> +	opts.system_gently = 1;
> +

It is curious why you want to switch to manual assignment, instead
of keeping the designated initializer for this one.  I would have
expected the initialization in read_very_early_config() to start
using designated initializer to be consistent, instead.

Thanks.

  reply	other threads:[~2023-08-24  1:20 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-20 22:17 [PATCH 0/2] config-parse: create config parsing library Glen Choo via GitGitGadget
2023-07-20 22:17 ` [PATCH 1/2] config: return positive from git_config_parse_key() Glen Choo via GitGitGadget
2023-07-20 23:44   ` Jonathan Tan
2023-07-21  4:32   ` Junio C Hamano
2023-07-21 16:12     ` Glen Choo
2023-07-21 16:36       ` Junio C Hamano
2023-07-20 22:17 ` [PATCH 2/2] config-parse: split library out of config.[c|h] Glen Choo via GitGitGadget
2023-07-21  0:31   ` Jonathan Tan
2023-07-21 15:55     ` Glen Choo
2023-07-31 23:46 ` [RFC PATCH v1.5 0/5] config-parse: create config parsing library Glen Choo
2023-07-31 23:46   ` [RFC PATCH v1.5 1/5] config: return positive from git_config_parse_key() Glen Choo
2023-07-31 23:46   ` [RFC PATCH v1.5 2/5] config: split out config_parse_options Glen Choo
2023-07-31 23:46   ` [RFC PATCH v1.5 3/5] config: report config parse errors using cb Glen Choo
2023-08-04 21:34     ` Jonathan Tan
2023-07-31 23:46   ` [RFC PATCH v1.5 4/5] config.c: accept config_parse_options in git_config_from_stdin Glen Choo
2023-07-31 23:46   ` [RFC PATCH v1.5 5/5] config-parse: split library out of config.[c|h] Glen Choo
2023-08-23 21:53 ` [PATCH v2 0/4] config-parse: create config parsing library Josh Steadmon
2023-08-23 21:53   ` [PATCH v2 1/4] config: split out config_parse_options Josh Steadmon
2023-08-23 23:26     ` Junio C Hamano
2023-09-21 21:08       ` Josh Steadmon
2023-08-23 21:53   ` [PATCH v2 2/4] config: report config parse errors using cb Josh Steadmon
2023-08-24  1:19     ` Junio C Hamano [this message]
2023-08-24 17:31       ` Jonathan Tan
2023-08-24 18:48         ` Junio C Hamano
2023-09-21 21:11       ` Josh Steadmon
2023-09-21 23:36         ` Junio C Hamano
2023-08-23 21:53   ` [PATCH v2 3/4] config.c: accept config_parse_options in git_config_from_stdin Josh Steadmon
2023-08-23 21:53   ` [PATCH v2 4/4] config-parse: split library out of config.[c|h] Josh Steadmon
2023-08-24 20:10   ` [PATCH v2 0/4] config-parse: create config parsing library Josh Steadmon
2023-09-21 21:17 ` [PATCH v3 0/5] " Josh Steadmon
2023-09-21 21:17   ` [PATCH v3 1/5] config: split out config_parse_options Josh Steadmon
2023-10-23 17:52     ` Jonathan Tan
2023-10-23 18:46       ` Taylor Blau
2023-09-21 21:17   ` [PATCH v3 2/5] config: split do_event() into start and flush operations Josh Steadmon
2023-10-23 18:05     ` Jonathan Tan
2023-09-21 21:17   ` [PATCH v3 3/5] config: report config parse errors using cb Josh Steadmon
2023-10-23 18:41     ` Jonathan Tan
2023-10-23 19:29     ` Taylor Blau
2023-10-23 20:11       ` Junio C Hamano
2023-09-21 21:17   ` [PATCH v3 4/5] config.c: accept config_parse_options in git_config_from_stdin Josh Steadmon
2023-10-23 18:52     ` Jonathan Tan
2023-09-21 21:17   ` [PATCH v3 5/5] config-parse: split library out of config.[c|h] Josh Steadmon
2023-10-23 18:53     ` Jonathan Tan
2023-10-17 17:13   ` [PATCH v3 0/5] config-parse: create config parsing library Junio C Hamano
2023-10-23 19:34     ` Taylor Blau
2023-10-23 20:13       ` Junio C Hamano
2023-10-24 22:50       ` Jonathan Tan
2023-10-25 19:37         ` Josh Steadmon
2023-10-27 13:04           ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqttspck4a.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=calvinwan@google.com \
    --cc=git@vger.kernel.org \
    --cc=glencbz@gmail.com \
    --cc=jonathantanmy@google.com \
    --cc=steadmon@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.