git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: René ScharfeNext: Junio C Hamano
Message 6 of 9 in “getcwd without PATH_MAX”
  1. 0/4 getcwd without PATH_MAXRené Scharfe, Jul 20, 2014
  2. 1/4 strbuf: add strbuf_getcwd()René Scharfe, Jul 20, 2014
  3. 2/4 use strbuf_getcwd() to get the current working directory without fixed-sized buffersRené Scharfe, Jul 20, 2014
  4. Jeff KingJul 21, 2014
  5. René ScharfeJul 21, 2014
  6. Jeff KingJul 22, 2014
  7. Junio C HamanoJul 21, 2014
  8. 3/4 wrapper: add xgetcwd()René Scharfe, Jul 20, 2014
  9. 4/4 use xgetcwd() get the current directory or dieRené Scharfe, Jul 20, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.