Re: [PATCH] config: fix several access(NULL) calls
From: Matthieu Moy <hidden>
Date: 2016-06-15 22:54:15
Junio C Hamano [off-list ref] 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).
- 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/