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

[PATCH] rebase: exec leaks GIT_DIR to environment

From
Jacob Keller <jacob.e.keller@intel.com>
Date
Oct 28, 2017, 00:01 UTC
Message-ID
<20171028000152.2760-1-jacob.e.keller@intel.com>
From: Jacob Keller <jacob.keller@gmail.com>

I noticed a failure with git rebase interactive mode which causes "exec" commands to be run with GIT_DIR set. When GIT_DIR is in the environment, then any command which results in running a git command in a subdirectory will fail because GIT_DIR=".git".

This unfortunately breaks one of my project's Makefiles, which uses git-describe to find the version information, but does so from within a sub directory.

I'm in the process of running a bisect to find where this got introduced, but I suspect it's part of the rebase--helper changes that happened a while ago.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
---
 t/t3404-rebase-interactive.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 3704dbb2ecf6..60ab5136f702 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -108,6 +108,17 @@ test_expect_success 'rebase -i with the exec command runs from tree root' '
 	rm -fr subdir
 '
 
+test_expect_failure 'rebase -i with the exec git commands in subdirs still work' '
+	test_when_finished "rm -ff subdir" &&
+	test_when_finished "git rebase --abort" &&
+	git checkout master &&
+	mkdir subdir && (cd subdir &&
+	set_fake_editor &&
+	FAKE_LINES="1 exec_>cd_subdir_&&_git_rev-parse_--is-inside-work-tree" \
+		git rebase -i HEAD^
+	)
+'
+
 test_expect_success 'rebase -i with the exec command checks tree cleanness' '
 	git checkout master &&
 	set_fake_editor &&
-- 
2.11.1.4.gad8c7cd
Next: Johannes Schindelin
Message 1 of 12 in “rebase: exec leaks GIT_DIR to environment”
  1. rebase: exec leaks GIT_DIR to environmentJacob Keller, Oct 28, 2017
  2. Johannes SchindelinOct 28, 2017
  3. Jacob KellerOct 28, 2017
  4. Phillip WoodOct 29, 2017
  5. Junio C HamanoOct 30, 2017
  6. Jacob KellerOct 30, 2017
  7. Junio C HamanoOct 30, 2017
  8. Jacob KellerOct 30, 2017
  9. Phillip WoodOct 30, 2017
  10. Johannes SchindelinOct 30, 2017
  11. Jacob KellerOct 31, 2017
  12. Jacob KellerOct 30, 2017

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.