All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: tboegi@web.de
Cc: git@vger.kernel.org, d.torilov@gmail.com
Subject: Re: [PATCH v2 2/2] MacOs: Precompose startup_info->prefix
Date: Sun, 04 Apr 2021 00:58:17 -0700	[thread overview]
Message-ID: <xmqqlf9y7a7a.fsf@gitster.g> (raw)
In-Reply-To: <20210404061754.19428-1-tboegi@web.de> (tboegi@web.de's message of "Sun, 4 Apr 2021 08:17:54 +0200")

tboegi@web.de writes:

> diff --git a/setup.c b/setup.c
> index c04cd25a30..dcc9c41a85 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -1281,10 +1281,6 @@ const char *setup_git_directory_gently(int *nongit_ok)
>  	} else {
>  		startup_info->have_repository = 1;
>  		startup_info->prefix = prefix;

Is this assignment sensible?  As we'd defer precomposition (or not)
after we run the repository discovery, would it break if we do not
have this line here (i.e. leaving startup_info->prefix NULL), and ...

> -		if (prefix)
> -			setenv(GIT_PREFIX_ENVIRONMENT, prefix, 1);
> -		else
> -			setenv(GIT_PREFIX_ENVIRONMENT, "", 1);
>  	}
>
>  	/*
> @@ -1311,6 +1307,16 @@ const char *setup_git_directory_gently(int *nongit_ok)
>  		if (startup_info->have_repository)
>  			repo_set_hash_algo(the_repository, repo_fmt.hash_algo);
>  	}
> +	/* Keep prefix, startup_info->prefix and GIT_PREFIX_ENVIRONMENT in sync */
> +	prefix = startup_info->prefix;

... not wipe prefix with this assignment, i.e. we learned prefix
before the previous hunk, and we would tweak it here?

> +	if (prefix) {
> +		/* This calls git_config_get_bool() under the hood (MacOs only) */

It may be more friendly to ourselves in the future if we are a bit
more explicit in what we want to convey with the comment, though.
Here is my attempt.

		/*
		 * Since precompose_string_if_needed() needs to look at
		 * the core.precomposeunicode configuration, this
		 * has to happen after the above block that finds
		 * out where the repository is, i.e. a preparation
                 * for calling git_config_get_bool().
		 */

> +		prefix = precompose_string_if_needed(prefix);
> +		startup_info->prefix = prefix;
> +		setenv(GIT_PREFIX_ENVIRONMENT, prefix, 1);
> +	} else {
> +		setenv(GIT_PREFIX_ENVIRONMENT, "", 1);
> +	}
>
>  	strbuf_release(&dir);
>  	strbuf_release(&gitdir);
> --
> 2.30.0.155.g66e871b664

Other than that, both patches look sensible.

By the way, isn't the canonical way to spell the name of the
particular operating system that needs this patch "macOS"?

cf. https://support.apple.com/macos

Thanks.

  reply	other threads:[~2021-04-04  7:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29 22:33 [PATCH] chore: use prefix from startup_info Dmitry Torilov via GitGitGadget
2021-03-29 23:53 ` Junio C Hamano
2021-03-31  5:04   ` Torsten Bögershausen
2021-04-04  6:17   ` [PATCH v2 1/2] precompose_utf8: Make precompose_string_if_needed() public tboegi
2021-04-04  6:17   ` [PATCH v2 2/2] MacOs: Precompose startup_info->prefix tboegi
2021-04-04  7:58     ` Junio C Hamano [this message]
2021-04-04 17:14   ` [PATCH v3 1/2] precompose_utf8: Make precompose_string_if_needed() public tboegi
2021-04-04 17:14   ` [PATCH v3 2/2] MacOs: Precompose startup_info->prefix tboegi

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=xmqqlf9y7a7a.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=d.torilov@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=tboegi@web.de \
    /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.