Re: [PATCH] config: fix several access(NULL) calls

2012-07-16 Thread Junio C Hamano
Matthieu Moy writes: > Junio C Hamano 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

Re: [PATCH] config: fix several access(NULL) calls

2012-07-16 Thread Matthieu Moy
Junio C Hamano 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

Re: [PATCH] config: fix several access(NULL) calls

2012-07-16 Thread Junio C Hamano
Matthieu Moy writes: > Junio C Hamano writes: > >> if (use_global_config) { >> if (is $HOME/.gitconfig usable?) { >> use it; > > Yes, but when $HOME is unset, the question doesn't really make sense. > Maybe the file exists, but we can't know since the us

Re: [PATCH] config: fix several access(NULL) calls

2012-07-16 Thread Matthieu Moy
Junio C Hamano writes: > if (use_global_config) { > if (is $HOME/.gitconfig usable?) { > use it; Yes, but when $HOME is unset, the question doesn't really make sense. Maybe the file exists, but we can't know since the user broke his configuration by un

Re: [PATCH] config: fix several access(NULL) calls

2012-07-13 Thread Junio C Hamano
Matthieu Moy writes: > The old code was: > > if (use_global_config) { > char *home = getenv("HOME"); > if (home) { > char *user_config = xstrdup(mkpath("%s/.gitconfig", > home)); > given_config_file = user_co

Re: [PATCH] config: fix several access(NULL) calls

2012-07-13 Thread Matthieu Moy
Thomas Rast writes: > Umm, are you sure? I may be somewhat confused about this, but the tests > I used to trigger the access(NULL) were IIRC > > unset HOME > git config --get foo.bar > git config --global --get foo.bar > > none of which is writing I was inaccurate, but that doesn't ch

Re: [PATCH] config: fix several access(NULL) calls

2012-07-13 Thread Thomas Rast
Matthieu Moy writes: > Jeff King writes: > >> On Fri, Jul 13, 2012 at 10:48:18AM +0200, Matthieu Moy wrote: >> >>> Junio C Hamano writes: >>> >>> > But is it really true that we want to error out on missing HOME if >>> > we have usable XDG stuff? >>> >>> Anyone else have an opinion on this? >

Re: [PATCH] config: fix several access(NULL) calls

2012-07-13 Thread Matthieu Moy
Jeff King writes: > On Fri, Jul 13, 2012 at 10:48:18AM +0200, Matthieu Moy wrote: > >> Junio C Hamano writes: >> >> > But is it really true that we want to error out on missing HOME if >> > we have usable XDG stuff? >> >> Anyone else have an opinion on this? >> >> In short, the question is wh

Re: [PATCH] config: fix several access(NULL) calls

2012-07-13 Thread Jeff King
On Fri, Jul 13, 2012 at 10:48:18AM +0200, Matthieu Moy wrote: > Junio C Hamano writes: > > > But is it really true that we want to error out on missing HOME if > > we have usable XDG stuff? > > Anyone else have an opinion on this? > > In short, the question is whether > > export XDG_CONFIG_

Re: [PATCH] config: fix several access(NULL) calls

2012-07-13 Thread Matthieu Moy
Junio C Hamano writes: > But is it really true that we want to error out on missing HOME if > we have usable XDG stuff? Anyone else have an opinion on this? In short, the question is whether export XDG_CONFIG_HOME=some-existing-dir unset HOME git config foo.baz boz should die("$HOME is

Re: [PATCH] config: fix several access(NULL) calls

2012-07-12 Thread Junio C Hamano
Matthieu Moy writes: >>> + if (user_config && access(user_config, R_OK) && >>> + xdg_config && !access(xdg_config, R_OK)) >>> given_config_file = xdg_config; >> >> Shouldn't we be using xdg_config, if user_config is NULL and >> xdg_config is defined and

Re: [PATCH] config: fix several access(NULL) calls

2012-07-12 Thread Matthieu Moy
Junio C Hamano writes: > Matthieu Moy writes: > >> When $HOME is unset, home_config_paths fails and returns NULL pointers >> for user_config and xdg_config. Valgrind complains with Syscall param >> access(pathname) points to unaddressable byte(s). >> >> Don't call blindly access() on these varia

Re: [PATCH] config: fix several access(NULL) calls

2012-07-12 Thread Junio C Hamano
Matthieu Moy writes: > When $HOME is unset, home_config_paths fails and returns NULL pointers > for user_config and xdg_config. Valgrind complains with Syscall param > access(pathname) points to unaddressable byte(s). > > Don't call blindly access() on these variables, but test them for > NULL-ne

Re: [PATCH] config: fix several access(NULL) calls

2012-07-12 Thread Thomas Rast
Matthieu Moy writes: > When $HOME is unset, home_config_paths fails and returns NULL pointers > for user_config and xdg_config. Valgrind complains with Syscall param > access(pathname) points to unaddressable byte(s). > > Don't call blindly access() on these variables, but test them for > NULL-ne

[PATCH] config: fix several access(NULL) calls

2012-07-12 Thread Matthieu Moy
When $HOME is unset, home_config_paths fails and returns NULL pointers for user_config and xdg_config. Valgrind complains with Syscall param access(pathname) points to unaddressable byte(s). Don't call blindly access() on these variables, but test them for NULL-ness before. Signed-off-by: Matthie