Re: [PATCH] config: fix several access(NULL) calls
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Jul 16, 2012, 16:39 UTC
- Message-ID
- <vpq7gu3wtgo.fsf@bauges.imag.fr>
- In-Reply-To
- <7vipdn4qbk.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> I would think that it is plausible that the user wanted to write > into XDG one and used "unset HOME" as a way to signal that wish.
I didn't think of this case, but it makes sense.
Anyway, I don't really care either way, so I leave it up to you (either your patch below, or the fixup in pu).
Show 24 quoted lines
> - if (user_config && access(user_config, R_OK) &&
> + if (!user_config)
> + /*
> + * We do not know HOME/.gitconfig exists or
> + * not, hence we do not know if we should
> + * write to XDG location, so we error out even
> + * if XDG_CONFIG_HOME is set and points at a
> + * sane location.
> + *
> + * In other words, we forbid the user from
> + * telling us to write to XDG location,
> + * pretending that $HOME/.gitconfig does not
> + * exist, by temporarily unsetting HOME.
> + */
> + die("$HOME not set");
> +
> + if (access(user_config, R_OK) &&
> xdg_config && !access(xdg_config, R_OK))
> given_config_file = xdg_config;
> - else if (user_config)
> - given_config_file = user_config;
> else
> - die("$HOME not set");
> + given_config_file = user_config;-- Matthieu Moy http://www-verimag.imag.fr/~moy/