Re: [PATCH v2 06/10] setup_git_env: use git_pathdup instead of xmalloc + sprintf

2014-06-25 Thread Junio C Hamano
Jeff King writes: > On Wed, Jun 25, 2014 at 10:20:13AM -0700, Junio C Hamano wrote: > >> Jeff King writes: >> >> > Here's a replacement patch that handles this (and just drops the ugly >> > mallocs as a side effect). >> > >> > -- >8 -- >> > Subject: [PATCH] setup_git_env: copy getenv return val

Re: [PATCH v2 06/10] setup_git_env: use git_pathdup instead of xmalloc + sprintf

2014-06-25 Thread Jeff King
On Wed, Jun 25, 2014 at 10:20:13AM -0700, Junio C Hamano wrote: > Jeff King writes: > > > Here's a replacement patch that handles this (and just drops the ugly > > mallocs as a side effect). > > > > -- >8 -- > > Subject: [PATCH] setup_git_env: copy getenv return value > > > > The return value of

Re: [PATCH v2 06/10] setup_git_env: use git_pathdup instead of xmalloc + sprintf

2014-06-25 Thread Junio C Hamano
Jeff King writes: > Here's a replacement patch that handles this (and just drops the ugly > mallocs as a side effect). > > -- >8 -- > Subject: [PATCH] setup_git_env: copy getenv return value > > The return value of getenv is not guaranteed to survive > across further invocations of setenv or even

Re: [PATCH v2 06/10] setup_git_env: use git_pathdup instead of xmalloc + sprintf

2014-06-25 Thread Duy Nguyen
On Wed, Jun 25, 2014 at 3:58 AM, Jeff King wrote: > Here's a replacement patch that handles this (and just drops the ugly > mallocs as a side effect). Shortly after I wrote my email, I thought about getenvdup() and look for similar getenv/xstrdup patterns. But I saw only one in config.c. So let's

Re: [PATCH v2 06/10] setup_git_env: use git_pathdup instead of xmalloc + sprintf

2014-06-24 Thread Jeff King
On Tue, Jun 24, 2014 at 08:30:26PM +0700, Duy Nguyen wrote: > On Fri, Jun 20, 2014 at 4:28 AM, Jeff King wrote: > > diff --git a/environment.c b/environment.c > > index 4dac5e9..4de7b81 100644 > > --- a/environment.c > > +++ b/environment.c > > @@ -135,15 +135,11 @@ static void setup_git_env(void

Re: [PATCH v2 06/10] setup_git_env: use git_pathdup instead of xmalloc + sprintf

2014-06-24 Thread Duy Nguyen
While it's about malloc.. On Fri, Jun 20, 2014 at 4:28 AM, Jeff King wrote: > diff --git a/environment.c b/environment.c > index 4dac5e9..4de7b81 100644 > --- a/environment.c > +++ b/environment.c > @@ -135,15 +135,11 @@ static void setup_git_env(void) > gitfile = read_gitfile(git_dir); >

Re: [PATCH v2 06/10] setup_git_env: use git_pathdup instead of xmalloc + sprintf

2014-06-24 Thread Duy Nguyen
On Mon, Jun 23, 2014 at 5:21 PM, Eric Sunshine wrote: > On Thu, Jun 19, 2014 at 5:28 PM, Jeff King wrote: >> This is shorter, harder to get wrong, and more clearly >> captures the intent. >> >> Signed-off-by: Jeff King >> --- >> I wondered if there was a reason to avoid this (because we are in >

Re: [PATCH v2 06/10] setup_git_env: use git_pathdup instead of xmalloc + sprintf

2014-06-23 Thread Junio C Hamano
Eric Sunshine writes: > On Thu, Jun 19, 2014 at 5:28 PM, Jeff King wrote: >> This is shorter, harder to get wrong, and more clearly >> captures the intent. >> >> Signed-off-by: Jeff King >> --- >> I wondered if there was a reason to avoid this (because we are in >> setup_git_env, which can pote

Re: [PATCH v2 06/10] setup_git_env: use git_pathdup instead of xmalloc + sprintf

2014-06-23 Thread Eric Sunshine
On Thu, Jun 19, 2014 at 5:28 PM, Jeff King wrote: > This is shorter, harder to get wrong, and more clearly > captures the intent. > > Signed-off-by: Jeff King > --- > I wondered if there was a reason to avoid this (because we are in > setup_git_env, which can potentially be called by git_pathdup)

[PATCH v2 06/10] setup_git_env: use git_pathdup instead of xmalloc + sprintf

2014-06-19 Thread Jeff King
This is shorter, harder to get wrong, and more clearly captures the intent. Signed-off-by: Jeff King --- I wondered if there was a reason to avoid this (because we are in setup_git_env, which can potentially be called by git_pathdup). But the git_graft_file initialization below already uses it, a