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

Re: Running commands in wrong environment

From
Jeff King <peff@peff.net>
Date
Dec 4, 2009, 10:44 UTC
Message-ID
<20091204104441.GD27495@coredump.intra.peff.net>
In-Reply-To
<D6F784B72498304C93A8A4691967698E8EE2C44FE5@REX2.intranet.epfl.ch>
On Thu, Dec 03, 2009 at 08:19:05PM +0100, Marinescu Paul dan wrote:
Show 7 quoted lines
> git's start_command (run_command.c) executes a command (e.g. hook) but
> does not verify that it has properly set up the environment. It seems
> that in the unlikely case where putenv (run_command.c:117) fails, the
> command may have undesirable effects e.g. GIT_INDEX_FILE should have
> been set (interactive pre-commit hooks) but the default index will be
> used instead. It would be safer not to run the command but just exit
> in that case.--

Hmm. It is simple enough to patch the one use of putenv, but there are 34 other calls to setenv, which has the same problem. I am tempted to ignore it, as it is extremely unlikely for this ever to happen, and adding error checking everywhere reduces the code readability.

But the consequences, as you mention, could include data loss, which argues for being on the safe side. In that case, we would probably want an "xsetenv" to die() if we fail to avoid cluttering the code everywhere.

I dunno. If we're going to do it, it is probably maint-worthy. Junio?
-Peff
Previous: Marinescu Paul danNext: Junio C Hamano
Message 2 of 4 in “Running commands in wrong environment”
  1. Marinescu Paul danDec 3, 2009
  2. Jeff KingDec 4, 2009
  3. Junio C HamanoDec 4, 2009
  4. Jeff KingDec 6, 2009

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.