git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Richard Weinberger <richard@nod.at>,
	Philip Oakley <philipoakley@iee.org>,
	Jonathan Nieder <jrnieder@gmail.com>,
	git@vger.kernel.org
Subject: [DONOTAPPLY PATCH 1/3] environment: set GIT_WORK_TREE when we figure out work tree
Date: Tue, 26 Mar 2013 16:11:40 -0400	[thread overview]
Message-ID: <20130326201140.GA22522@sigill.intra.peff.net> (raw)
In-Reply-To: <20130326200851.GA22080@sigill.intra.peff.net>

If we end up in a sub-process where GIT_WORK_TREE is not set
but GIT_DIR is, we assume the current directory is the root
of the working tree. Since future patches will change that
assumption, let's defensively start setting GIT_WORK_TREE
explicitly.

Signed-off-by: Jeff King <peff@peff.net>
---
I didn't test this very well (in fact, I only noticed the issue after
having written the other two patches, as without it, those ones break
every external command which wants to run in a working tree). I would
not be surprised if there is some code path which sets GIT_DIR but not
this, or if there is some other weird fallout from having GIT_WORK_TREE
set explicitly.

 environment.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/environment.c b/environment.c
index 92c5dff..be2e509 100644
--- a/environment.c
+++ b/environment.c
@@ -194,6 +194,7 @@ void set_git_work_tree(const char *new_work_tree)
 	}
 	git_work_tree_initialized = 1;
 	work_tree = xstrdup(real_path(new_work_tree));
+	setenv(GIT_WORK_TREE_ENVIRONMENT, work_tree, 1);
 }
 
 const char *get_git_work_tree(void)
-- 
1.8.2.13.g0f18d3c

  reply	other threads:[~2013-03-26 20:12 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-25 21:38 git ate my home directory :-( Richard Weinberger
2013-03-25 21:43 ` Jonathan Nieder
2013-03-25 22:02   ` Junio C Hamano
2013-03-25 22:08     ` Jonathan Nieder
2013-03-25 22:15       ` Junio C Hamano
2013-03-25 22:06   ` Junio C Hamano
2013-03-25 22:09     ` Richard Weinberger
2013-03-25 22:15       ` Jonathan Nieder
2013-03-25 22:20       ` Junio C Hamano
2013-03-25 22:27         ` Richard Weinberger
2013-03-25 22:13     ` Jonathan Nieder
2013-03-25 22:21       ` Brandon Casey
2013-03-26  8:02     ` Philip Oakley
2013-03-26  9:48       ` Duy Nguyen
2013-03-26 15:04         ` Jeff King
2013-03-26 16:32           ` Junio C Hamano
2013-03-27 13:05           ` Duy Nguyen
2013-03-26 21:47         ` Philip Oakley
2013-03-26 13:07       ` Richard Weinberger
2013-03-26 14:56         ` Jeff King
2013-03-26 17:06           ` Richard Weinberger
2013-03-26 17:20             ` demerphq
2013-03-26 17:48               ` Jeff King
2013-03-26 19:08                 ` demerphq
2013-03-26 17:41             ` Jeff King
2013-03-26 18:20               ` Junio C Hamano
2013-03-26 20:08                 ` Jeff King
2013-03-26 20:11                   ` Jeff King [this message]
2013-03-26 20:16                     ` [DONOTAPPLY PATCH 1/3] environment: set GIT_WORK_TREE when we figure out work tree Jonathan Nieder
2013-03-26 20:12                   ` [DONOTAPPLY PATCH 2/3] setup: warn about implicit worktree with $GIT_DIR Jeff King
2013-03-26 20:21                     ` Jonathan Nieder
2013-03-26 20:27                       ` Jeff King
2013-03-26 20:35                         ` Jonathan Nieder
2013-03-27  8:24                         ` Matthieu Moy
2013-03-26 20:13                   ` [DONOTAPPLY PATCH 3/3] setup: treat GIT_DIR without GIT_WORK_TREE as a bare repo Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130326201140.GA22522@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=philipoakley@iee.org \
    --cc=richard@nod.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).