git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Ayush Chandekar <ayu.chandekar@gmail.com>, git@vger.kernel.org
Cc: christian.couder@gmail.com, shyamthakkar001@gmail.com,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [GSOC PATCH 1/2] environment: remove the global variable 'merge_log_config'
Date: Tue, 29 Jul 2025 20:07:15 +0100	[thread overview]
Message-ID: <23428022-ab13-4a3e-90ed-ff91ef93f051@gmail.com> (raw)
In-Reply-To: <c82620a1f54ea6760bff204fd2b5fe5c2df1896c.1753804956.git.ayu.chandekar@gmail.com>

Hi Ayush

On 29/07/2025 17:19, Ayush Chandekar wrote:
> 
> @@ -26,14 +26,7 @@ static struct string_list suppress_dest_patterns = STRING_LIST_INIT_DUP;
>   int fmt_merge_msg_config(const char *key, const char *value,
>   			 const struct config_context *ctx, void *cb)
>   {
> -	if (!strcmp(key, "merge.log") || !strcmp(key, "merge.summary")) {
> -		int is_bool;
> -		merge_log_config = git_config_bool_or_int(key, value, ctx->kvi, &is_bool);
> -		if (!is_bool && merge_log_config < 0)
> -			return error("%s: negative length %s", key, value);
> -		if (is_bool && merge_log_config)
> -			merge_log_config = DEFAULT_MERGE_LOG_LEN;
> -	} else if (!strcmp(key, "merge.branchdesc")) {

In the old code if both "merge.log" and "merge.summary" are set in the 
config file the last one wins

> +void adjust_shortlog_len(struct repository *r, int *shortlog_len)
> +{
> +	const char *keys[] = { "merge.log", "merge.summary", NULL};
> +	
> +	if (*shortlog_len >= 0)
> +		return;
> +
> +	for (const char **key = keys; *key; ++key) {
> +		int is_bool, value;
> +		if (!repo_config_get_bool_or_int(r, *key, &is_bool, &value)) {
> +			if (!is_bool && value < 0) {
> +				error("%s: negative length %d", *key, value);
> +				return;
> +			}
> +			*shortlog_len = (is_bool && value) ? DEFAULT_MERGE_LOG_LEN : value;
> +			return;

In the new code "merge.log" is always used in preference to 
"merge.summary" even if "merge.summary" appears later in the config 
file. When you have two keys setting the same variable I think the only 
way to preserve the last one wins behavior is to keep using a callback 
that updates the value as the config files are parsed.

Thanks

Phillip


  parent reply	other threads:[~2025-07-29 19:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-29 16:19 [GSOC PATCH 0/2] builtin/fmt-merge-msg: remove dependency on global variables and 'the_repository' Ayush Chandekar
2025-07-29 16:19 ` [GSOC PATCH 1/2] environment: remove the global variable 'merge_log_config' Ayush Chandekar
2025-07-29 16:48   ` Junio C Hamano
2025-07-29 17:30     ` Ayush Chandekar
2025-07-29 17:53       ` Junio C Hamano
2025-07-29 19:07   ` Phillip Wood [this message]
2025-07-29 21:16     ` Ayush Chandekar
2025-07-30  8:53       ` Phillip Wood
2025-07-29 16:19 ` [GSOC PATCH 2/2] builtin/fmt-merge-msg: stop depending on 'the_repository' Ayush Chandekar
2025-07-29 16:41   ` Junio C Hamano
2025-07-29 21:49     ` Ayush Chandekar
2025-07-29 22:41       ` Junio C Hamano
2025-08-10 15:33 ` [GSOC PATCH 0/2] builtin/fmt-merge-msg: remove dependency on global variables and 'the_repository' Ayush Chandekar
2025-08-10 23:45 ` [GSOC PATCH v2 " Ayush Chandekar
2025-08-10 23:45   ` [GSOC PATCH v2 1/2] environment: remove the global variable 'merge_log_config' Ayush Chandekar
2025-08-11 14:42     ` Phillip Wood
2025-08-11 16:13       ` Junio C Hamano
2025-08-11 18:25         ` Ayush Chandekar
2025-08-10 23:45   ` [GSOC PATCH v2 2/2] builtin/fmt-merge-msg: stop depending on 'the_repository' Ayush Chandekar

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=23428022-ab13-4a3e-90ed-ff91ef93f051@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=ayu.chandekar@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=shyamthakkar001@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).