Re: [PATCH v2 2/4] use strbuf_getcwd() to get the current working directory without fixed-sized buffers
- From
Jeff King <peff@peff.net>
- Date
- Jul 22, 2014, 10:43 UTC
- Message-ID
- <20140722104352.GB29607@peff.net>
- In-Reply-To
- <53CD4975.8050002@web.de>
On Mon, Jul 21, 2014 at 07:10:13PM +0200, René Scharfe wrote:
> Probably. And I was so glad to have found an example case for getcwd > without dying and without touching the get-there-and-back cases. :) Guess > I'll have to look closer at setup.c and perhaps unix-socket.c for a > replacement.
I think just:
const char *x = xgetcwd(); setenv(GIT_DIR_ENVIRONMENT, x, 0); free(x);
would be enough?
> By the way: Simply setting $GIT_DIR to "." probably won't work in the two > cases, I guess?
It might, but I'd be a little wary. For example, for the call in init_db, would we later then chdir to the working tree in order to do a checkout (since init_db is part of a clone)? Even if it works now, it seems like a bit of an accident waiting to happen.
-Peff