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

[WIP PATCH 06/26] Tweak init/clone to work properly with GIT_HARDENED_SETUP=1

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Feb 16, 2010, 16:04 UTC
Message-ID
<1266336317-607-7-git-send-email-pclouds@gmail.com>
In-Reply-To
<1266336317-607-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin-init-db.c             |    4 ++++
 t/t0000-basic.sh              |    2 ++
 t/t0001-init.sh               |    2 ++
 t/t0003-attributes.sh         |    2 ++
 t/t5600-clone-fail-cleanup.sh |    2 ++
 t/t5601-clone.sh              |    2 ++
 t/t5602-clone-remote-exec.sh  |    2 ++
 t/t5700-clone-reference.sh    |    2 ++
 t/t5701-clone-local.sh        |    2 ++
 t/t5702-clone-options.sh      |    2 ++
 t/t5704-bundle.sh             |    2 ++
 t/t5705-clone-2gb.sh          |    2 ++
 t/t5706-clone-branch.sh       |    2 ++
 13 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/builtin-init-db.c b/builtin-init-db.c
index dd84cae..22b2b07 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -195,6 +195,7 @@ static int create_default_files(const char *template_path)
 	 * from it after installing.
 	 */
 	copy_templates(template_path);
+	startup_info->have_repository = 1;
 
 	git_config(git_default_config, NULL);
 	is_bare_repository_cfg = init_is_bare_repository;
@@ -286,6 +287,9 @@ int init_db(const char *template_dir, unsigned int flags)
 	char *path;
 	int len, reinit;
 
+	/* init_db's caller mush have called set_git_dir() */
+	startup_info->have_set_gitdir = 1;
+
 	safe_create_dir(get_git_dir(), 0);
 
 	init_is_bare_repository = is_bare_repository();
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index f4ca4fc..0a4be17 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -28,6 +28,8 @@ then
 	exit 1
 fi
 
+export GIT_HARDENED_SETUP=1
+
 . ./test-lib.sh
 
 ################################################################
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 5386504..0dd6ffa 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -4,6 +4,8 @@ test_description='git init'
 
 . ./test-lib.sh
 
+export GIT_HARDENED_SETUP=1
+
 check_config () {
 	if test -d "$1" && test -f "$1/config" && test -d "$1/refs"
 	then
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index 1c77192..2ebb345 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -4,6 +4,8 @@ test_description=gitattributes
 
 . ./test-lib.sh
 
+export GIT_HARDENED_SETUP=1
+
 attr_check () {
 
 	path="$1"
diff --git a/t/t5600-clone-fail-cleanup.sh b/t/t5600-clone-fail-cleanup.sh
index ee06d28..424e6ad 100755
--- a/t/t5600-clone-fail-cleanup.sh
+++ b/t/t5600-clone-fail-cleanup.sh
@@ -11,6 +11,8 @@ remove the directory before attempting a clone again.'
 
 . ./test-lib.sh
 
+export GIT_HARDENED_SETUP=1
+
 test_expect_success \
     'clone of non-existent source should fail' \
     'test_must_fail git clone foo bar'
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 2147567..a598f75 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -4,6 +4,8 @@ test_description=clone
 
 . ./test-lib.sh
 
+export GIT_HARDENED_SETUP=1
+
 test_expect_success setup '
 
 	rm -fr .git &&
diff --git a/t/t5602-clone-remote-exec.sh b/t/t5602-clone-remote-exec.sh
index deffdae..a94c528 100755
--- a/t/t5602-clone-remote-exec.sh
+++ b/t/t5602-clone-remote-exec.sh
@@ -4,6 +4,8 @@ test_description=clone
 
 . ./test-lib.sh
 
+export GIT_HARDENED_SETUP=1
+
 test_expect_success setup '
 	echo "#!/bin/sh" > not_ssh
 	echo "echo \"\$*\" > not_ssh_output" >> not_ssh
diff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh
index 1c10916..2464f57 100755
--- a/t/t5700-clone-reference.sh
+++ b/t/t5700-clone-reference.sh
@@ -6,6 +6,8 @@
 test_description='test clone --reference'
 . ./test-lib.sh
 
+export GIT_HARDENED_SETUP=1
+
 base_dir=`pwd`
 
 U=$base_dir/UPLOAD_LOG
diff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh
index 8b4c356..3c3d6ed 100755
--- a/t/t5701-clone-local.sh
+++ b/t/t5701-clone-local.sh
@@ -3,6 +3,8 @@
 test_description='test local clone'
 . ./test-lib.sh
 
+export GIT_HARDENED_SETUP=1
+
 D=`pwd`
 
 test_expect_success 'preparing origin repository' '
diff --git a/t/t5702-clone-options.sh b/t/t5702-clone-options.sh
index 02cb024..63f59ba 100755
--- a/t/t5702-clone-options.sh
+++ b/t/t5702-clone-options.sh
@@ -3,6 +3,8 @@
 test_description='basic clone options'
 . ./test-lib.sh
 
+export GIT_HARDENED_SETUP=1
+
 test_expect_success 'setup' '
 
 	mkdir parent &&
diff --git a/t/t5704-bundle.sh b/t/t5704-bundle.sh
index a8f4419..507c838 100755
--- a/t/t5704-bundle.sh
+++ b/t/t5704-bundle.sh
@@ -3,6 +3,8 @@
 test_description='some bundle related tests'
 . ./test-lib.sh
 
+export GIT_HARDENED_SETUP=1
+
 test_expect_success 'setup' '
 
 	: > file &&
diff --git a/t/t5705-clone-2gb.sh b/t/t5705-clone-2gb.sh
index adfaae8..f63a557 100755
--- a/t/t5705-clone-2gb.sh
+++ b/t/t5705-clone-2gb.sh
@@ -3,6 +3,8 @@
 test_description='Test cloning a repository larger than 2 gigabyte'
 . ./test-lib.sh
 
+export GIT_HARDENED_SETUP=1
+
 test -z "$GIT_TEST_CLONE_2GB" &&
 say "Skipping expensive 2GB clone test; enable it with GIT_TEST_CLONE_2GB=t" &&
 test_done &&
diff --git a/t/t5706-clone-branch.sh b/t/t5706-clone-branch.sh
index f3f9a76..fbee0d0 100755
--- a/t/t5706-clone-branch.sh
+++ b/t/t5706-clone-branch.sh
@@ -3,6 +3,8 @@
 test_description='clone --branch option'
 . ./test-lib.sh
 
+export GIT_HARDENED_SETUP=1
+
 check_HEAD() {
 	echo refs/heads/"$1" >expect &&
 	git symbolic-ref HEAD >actual &&
-- 
1.7.0.195.g637a2
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 7 of 27 in “Git setup cleanup series”
  1. 00/26 Git setup cleanup seriesNguyễn Thái Ngọc Duy, Feb 16, 2010
  2. 01/26 rev-parse --git-dir: print relative gitdir correctlyNguyễn Thái Ngọc Duy, Feb 16, 2010
  3. 02/26 setup_git_directory*: Explicitly set git dirNguyễn Thái Ngọc Duy, Feb 16, 2010
  4. 03/26 Save setup_git_dir* info globally for later useNguyễn Thái Ngọc Duy, Feb 16, 2010
  5. 04/26 Add GIT_HARDENED_SETUP to detect gitdir/worktree related mis-setup errorsNguyễn Thái Ngọc Duy, Feb 16, 2010
  6. 05/26 enter_repo(): use setup_git_directory_gently internallyNguyễn Thái Ngọc Duy, Feb 16, 2010
  7. 06/26 Tweak init/clone to work properly with GIT_HARDENED_SETUP=1Nguyễn Thái Ngọc Duy, Feb 16, 2010
  8. 07/26 Support running setup_git_dir_gently() from the beginning for builtin commandsNguyễn Thái Ngọc Duy, Feb 16, 2010
  9. 08/26 config: move up gitdir setup to run_builtin()Nguyễn Thái Ngọc Duy, Feb 16, 2010
  10. 09/26 hash-object: move gitdir setup to run_builtin()Nguyễn Thái Ngọc Duy, Feb 16, 2010
  11. 10/26 shortlog: move up gitdir setup to run_builtin()Nguyễn Thái Ngọc Duy, Feb 16, 2010
  12. 11/26 Do not look for .git/info/exclude when gitdir is not set upNguyễn Thái Ngọc Duy, Feb 16, 2010
  13. 12/26 grep: move up gitdir setup to run_builtin()Nguyễn Thái Ngọc Duy, Feb 16, 2010
  14. 13/26 USE_PAGER should not be used without RUN_SETUP*Nguyễn Thái Ngọc Duy, Feb 16, 2010
  15. 14/26 Do not try to read $GIT_DIR/info/attributes if there is no repositoryNguyễn Thái Ngọc Duy, Feb 16, 2010
  16. 15/26 archive: move up gitdir setup to run_builtin()Nguyễn Thái Ngọc Duy, Feb 16, 2010
  17. 16/26 mailinfo: move up gitdir setup to run_builtin()Nguyễn Thái Ngọc Duy, Feb 16, 2010
  18. 17/26 check-ref-format: setup gitdir gentlyNguyễn Thái Ngọc Duy, Feb 16, 2010
  19. 18/26 verify-pack: set up gitdir gentlyNguyễn Thái Ngọc Duy, Feb 16, 2010
  20. 19/26 apply: move up gitdir setup to run_builtin()Nguyễn Thái Ngọc Duy, Feb 16, 2010
  21. 20/26 bundle: move up gitdir setup to run_builtin()Nguyễn Thái Ngọc Duy, Feb 16, 2010
  22. 21/26 diff: move up gitdir setup to run_builtin()Nguyễn Thái Ngọc Duy, Feb 16, 2010
  23. 22/26 help: move up gitdir setup to run_builtin()Nguyễn Thái Ngọc Duy, Feb 16, 2010
  24. 23/26 ls-remote: move up gitdir setup to run_builtin()Nguyễn Thái Ngọc Duy, Feb 16, 2010
  25. 24/26 var: move up gitdir setup to run_builtin()Nguyễn Thái Ngọc Duy, Feb 16, 2010
  26. 25/26 merge-file: move up gitdir setup to run_builtin()Nguyễn Thái Ngọc Duy, Feb 16, 2010
  27. 26/26 Turn on GIT_HARDENED_SETUP for the whole test suiteNguyễn Thái Ngọc Duy, Feb 16, 2010

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.