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

[PATCH] Export GIT_DIR after setting it

From
MKmartin f. krafft <madduck@madduck.net>
Date
May 14, 2008, 23:23 UTC
Message-ID
<1210807401-11201-1-git-send-email-madduck@madduck.net>

git-sh-setup might set GIT_DIR, but not export it. When git-pull, for instance, calls cd_to_toplevel, it changes the working directory, and later calls git-ls-files, which does *not* inherit GIT_DIR since it's not imported. It thus does the detection again, but in a different environment, since the working directory changed. This breaks stuff subtly, especially when core.worktree is set.

The patch simply exports GIT_DIR and makes it work such that git-ls-files doesn't redo the work (wrongly).

Thanks to Björn Steinbrink for his help.
Signed-off-by: martin f. krafft <madduck@madduck.net>
---
 git-sh-setup.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index a44b1c7..de90f07 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -128,6 +128,7 @@ get_author_ident_from_commit () {
 if test -z "$NONGIT_OK"
 then
 	GIT_DIR=$(git rev-parse --git-dir) || exit
+	export GIT_DIR
 	if [ -z "$SUBDIRECTORY_OK" ]
 	then
 		test -z "$(git rev-parse --show-cdup)" || {
-- 
1.5.5.1
Next: Junio C Hamano
Message 1 of 9 in “Export GIT_DIR after setting it”
  1. Export GIT_DIR after setting itmartin f. krafft, May 14, 2008
  2. Junio C HamanoMay 15, 2008
  3. martin f. krafftMay 15, 2008
  4. Junio C HamanoMay 15, 2008
  5. Björn SteinbrinkMay 15, 2008
  6. martin f. krafftMay 15, 2008
  7. Björn SteinbrinkMay 15, 2008
  8. martin f. krafftMay 16, 2008
  9. martin f. krafftMay 20, 2008

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.