Re: [PATCH v3 04/12] config.c: pass ctx in configsets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Glen Choo via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes:

>  static int config_read_push_default(const char *key, const char *value,
> -	const struct config_context *ctx UNUSED, void *cb)
> +	const struct config_context *ctx, void *cb)
>  {
> +	const struct key_value_info *kvi = ctx->kvi;
> +
>  	struct push_default_info* info = cb;
>  	if (strcmp(key, "remote.pushdefault") ||
>  	    !value || strcmp(value, info->old_name))
>  		return 0;
>  
> -	info->scope = current_config_scope();
> +	info->scope = kvi->scope;
>  	strbuf_reset(&info->origin);
> -	strbuf_addstr(&info->origin, current_config_name());
> -	info->linenr = current_config_line();
> +	strbuf_addstr(&info->origin, config_origin_type_name(kvi->origin_type));
> +	info->linenr = kvi->linenr;

Yay!

It is very pleasing to see these current_*() functions made
unnecessary.  This step only allows us to remove the _line() but not
yet _scope(), but as long as we lose them at the end, going one step
at a time is perfectly fine and readable.

> +const char *current_config_origin_type(void)
> +{
> +	enum config_origin_type type = CONFIG_ORIGIN_UNKNOWN;
> +
> +	if (reader_origin_type(&the_reader, &type))
> +		BUG("current_config_origin_type called outside config callback");
> +
> +	return config_origin_type_name(type);
> +}

We still rely on the fact that the_reader is a global singleton, but
that is of course OK in this early part of the series.

Looking nice.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux