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 p...@peff.net 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

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

2014-06-25 Thread Junio C Hamano
Jeff King p...@peff.net 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

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 p...@peff.net 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 p...@peff.net writes: On Wed, Jun 25, 2014 at 10:20:13AM -0700, Junio C Hamano wrote: Jeff King p...@peff.net 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

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 sunsh...@sunshineco.com wrote: On Thu, Jun 19, 2014 at 5:28 PM, Jeff King p...@peff.net wrote: This is shorter, harder to get wrong, and more clearly captures the intent. Signed-off-by: Jeff King p...@peff.net --- I wondered if there was a

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 p...@peff.net 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 =

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 p...@peff.net 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

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 p...@peff.net wrote: This is shorter, harder to get wrong, and more clearly captures the intent. Signed-off-by: Jeff King p...@peff.net --- I wondered if there was a reason to avoid this (because we are in setup_git_env, which can potentially be

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

2014-06-23 Thread Junio C Hamano
Eric Sunshine sunsh...@sunshineco.com writes: On Thu, Jun 19, 2014 at 5:28 PM, Jeff King p...@peff.net wrote: This is shorter, harder to get wrong, and more clearly captures the intent. Signed-off-by: Jeff King p...@peff.net --- I wondered if there was a reason to avoid this (because we

[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 p...@peff.net --- 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