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

Re: [PATCH] setup.c: set workdir when gitdir is not default

From
Max Kirillov <max@max630.net>
Date
Sep 4, 2014, 14:20 UTC
Message-ID
<20140904142015.GA8894@wheezy.local>
In-Reply-To
<CACsJy8CS3jC54bTh8ySmpAmbQOycMvvnH=yMES0LJQ4zWkqLrA@mail.gmail.com>
On Thu, Sep 04, 2014 at 05:53:34PM +0700, Duy Nguyen wrote:
Show 8 quoted lines
> On Thu, Sep 4, 2014 at 5:42 AM, Max Kirillov <max@max630.net> wrote:
>>         /* #0, #1, #5, #8, #9, #12, #13 */
>>         set_git_work_tree(".");
> 
> I wonder if we should setenv(GIT_WORK_TREE_) from inside this function
> instead. A quick glance over 'git grep set_git_work_tree' gives me the
> impression that it's safe to do so, and could cover future bugs
> similar to this.

Actually, I've been thinking about just the oppozite: remove the setenv(GIT_DIR) from the discovery code at all. Because backend performs the same discovery, and it would find the same git directory itself. And leave environment variables to be only set by user.

Currently environment variables are used for both purposes: user can use them for hacky stuff, and git itself use them for passing internal information. But, as we can see, setting the variables can have bigger effect than expected. When they are set by user, it's ok, let him try, fail and set some else variable to adapt for his needs. But for git code there is the discovery routines, lets just use them always, it will cause a couple of extra (very few) IO calls but should always give same (correct) result

-- 
Max
Previous: Duy Nguyen
Message 5 of 5 in “setup.c: set workdir when gitdir is not default”
  1. setup.c: set workdir when gitdir is not defaultMax Kirillov, Sep 3, 2014
  2. Eric SunshineSep 4, 2014
  3. Max KirillovSep 4, 2014
  4. Duy NguyenSep 4, 2014
  5. Max KirillovSep 4, 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.