diff mbox series

[1/1] config: add back code comment

Message ID 48d66e94ece3b763acbe933561d82157c02a5f58.1706466321.git.code@khaugsbakk.name (mailing list archive)
State Superseded
Headers show
Series config: add back code comment | expand

Commit Message

Kristoffer Haugsbakk Jan. 28, 2024, 6:31 p.m. UTC
c15129b699 (config: factor out global config file retrieval, 2024-01-18)
was a refactor that moved some of the code in this function to
`config.c`. However, in the process I managed to drop this code comment
which explains `$HOME not set`.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
---
 builtin/config.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Patrick Steinhardt Jan. 29, 2024, 11:32 a.m. UTC | #1
On Sun, Jan 28, 2024 at 07:31:40PM +0100, Kristoffer Haugsbakk wrote:
> c15129b699 (config: factor out global config file retrieval, 2024-01-18)
> was a refactor that moved some of the code in this function to
> `config.c`. However, in the process I managed to drop this code comment
> which explains `$HOME not set`.
> 
> Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
> ---
>  builtin/config.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/builtin/config.c b/builtin/config.c
> index 08fe36d499..b55bfae7d6 100644
> --- a/builtin/config.c
> +++ b/builtin/config.c
> @@ -710,6 +710,12 @@ int cmd_config(int argc, const char **argv, const char *prefix)
>  	if (use_global_config) {
>  		given_config_source.file = git_global_config();
>  		if (!given_config_source.file)
> +			/*
> +			 * It is unknown if HOME/.gitconfig exists, so
> +			 * we do not know if we should write to XDG
> +			 * location; error out even if XDG_CONFIG_HOME
> +			 * is set and points at a sane location.
> +			 */
>  			die(_("$HOME not set"));
>  		given_config_source.scope = CONFIG_SCOPE_GLOBAL;
>  	} else if (use_system_config) {

Thanks for adding the comment back in! The patch looks good to me.

Patrick
Junio C Hamano Jan. 29, 2024, 6:28 p.m. UTC | #2
Patrick Steinhardt <ps@pks.im> writes:

>>  		if (!given_config_source.file)
>> +			/*
>> +			 * It is unknown if HOME/.gitconfig exists, so
>> +			 * we do not know if we should write to XDG
>> +			 * location; error out even if XDG_CONFIG_HOME
>> +			 * is set and points at a sane location.
>> +			 */
>>  			die(_("$HOME not set"));
>>  		given_config_source.scope = CONFIG_SCOPE_GLOBAL;
>>  	} else if (use_system_config) {
>
> Thanks for adding the comment back in! The patch looks good to me.

Yeah, thanks, both.
diff mbox series

Patch

diff --git a/builtin/config.c b/builtin/config.c
index 08fe36d499..b55bfae7d6 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -710,6 +710,12 @@  int cmd_config(int argc, const char **argv, const char *prefix)
 	if (use_global_config) {
 		given_config_source.file = git_global_config();
 		if (!given_config_source.file)
+			/*
+			 * It is unknown if HOME/.gitconfig exists, so
+			 * we do not know if we should write to XDG
+			 * location; error out even if XDG_CONFIG_HOME
+			 * is set and points at a sane location.
+			 */
 			die(_("$HOME not set"));
 		given_config_source.scope = CONFIG_SCOPE_GLOBAL;
 	} else if (use_system_config) {