Git development
 help / color / mirror / Atom feed
From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH 03/17] t0003: use `--git-dir` for bare repo attribute tests
Date: Thu, 02 Apr 2026 14:33:09 +0000	[thread overview]
Message-ID: <a4f7a6df516c848936e6952dac8ca02ccb0ac643.1775140403.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2076.git.1775140403.gitgitgadget@gmail.com>

From: Johannes Schindelin <johannes.schindelin@gmx.de>

The bare repo tests in t0003-attributes.sh currently `cd` into the bare
repository inside subshells, relying on implicit discovery. Restructure
these tests to pass `--git-dir=bare.git` to the `attr_check` and
`attr_check_source` helpers instead. This makes the code much easier to
read, and also makes bare repo access explicit, i.e. compatible with an
eventual `safe.bareRepository=explicit` default.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 t/t0003-attributes.sh | 66 ++++++++++++++++++-------------------------
 1 file changed, 27 insertions(+), 39 deletions(-)

diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index 582e207aa1..3a34f5dbc2 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -346,17 +346,14 @@ test_expect_success 'setup bare' '
 
 test_expect_success 'bare repository: check that .gitattribute is ignored' '
 	(
-		cd bare.git &&
-		(
-			echo "f	test=f" &&
-			echo "a/i test=a/i"
-		) >.gitattributes &&
-		attr_check f unspecified &&
-		attr_check a/f unspecified &&
-		attr_check a/c/f unspecified &&
-		attr_check a/i unspecified &&
-		attr_check subdir/a/i unspecified
-	)
+		echo "f	test=f" &&
+		echo "a/i test=a/i"
+	) >bare.git/.gitattributes &&
+	attr_check f unspecified --git-dir=bare.git &&
+	attr_check a/f unspecified --git-dir=bare.git &&
+	attr_check a/c/f unspecified --git-dir=bare.git &&
+	attr_check a/i unspecified --git-dir=bare.git &&
+	attr_check subdir/a/i unspecified --git-dir=bare.git
 '
 
 bad_attr_source_err="fatal: bad --attr-source or GIT_ATTR_SOURCE"
@@ -449,41 +446,32 @@ test_expect_success 'diff without repository with attr source' '
 '
 
 test_expect_success 'bare repository: with --source' '
-	(
-		cd bare.git &&
-		attr_check_source foo/bar/f f tag-1 &&
-		attr_check_source foo/bar/a/i n tag-1 &&
-		attr_check_source foo/bar/f unspecified tag-2 &&
-		attr_check_source foo/bar/a/i m tag-2 &&
-		attr_check_source foo/bar/g g tag-2 &&
-		attr_check_source foo/bar/g unspecified tag-1
-	)
+	attr_check_source foo/bar/f f tag-1 --git-dir=bare.git &&
+	attr_check_source foo/bar/a/i n tag-1 --git-dir=bare.git &&
+	attr_check_source foo/bar/f unspecified tag-2 --git-dir=bare.git &&
+	attr_check_source foo/bar/a/i m tag-2 --git-dir=bare.git &&
+	attr_check_source foo/bar/g g tag-2 --git-dir=bare.git &&
+	attr_check_source foo/bar/g unspecified tag-1 --git-dir=bare.git
 '
 
 test_expect_success 'bare repository: check that --cached honors index' '
-	(
-		cd bare.git &&
-		GIT_INDEX_FILE=../.git/index \
-		git check-attr --cached --stdin --all <../stdin-all |
-		sort >actual &&
-		test_cmp ../specified-all actual
-	)
+	GIT_INDEX_FILE=.git/index \
+	git --git-dir=bare.git check-attr --cached --stdin --all <stdin-all |
+	sort >actual &&
+	test_cmp specified-all actual
 '
 
 test_expect_success 'bare repository: test info/attributes' '
+	mkdir -p bare.git/info &&
 	(
-		cd bare.git &&
-		mkdir info &&
-		(
-			echo "f	test=f" &&
-			echo "a/i test=a/i"
-		) >info/attributes &&
-		attr_check f f &&
-		attr_check a/f f &&
-		attr_check a/c/f f &&
-		attr_check a/i a/i &&
-		attr_check subdir/a/i unspecified
-	)
+		echo "f	test=f" &&
+		echo "a/i test=a/i"
+	) >bare.git/info/attributes &&
+	attr_check f f --git-dir=bare.git &&
+	attr_check a/f f --git-dir=bare.git &&
+	attr_check a/c/f f --git-dir=bare.git &&
+	attr_check a/i a/i --git-dir=bare.git &&
+	attr_check subdir/a/i unspecified --git-dir=bare.git
 '
 
 test_expect_success 'binary macro expanded by -a' '
-- 
gitgitgadget


  parent reply	other threads:[~2026-04-02 14:33 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02 14:33 [PATCH 00/17] tests: access bare repositories explicitly Johannes Schindelin via GitGitGadget
2026-04-02 14:33 ` [PATCH 01/17] t0001: allow implicit bare repo discovery for aliased-command test Johannes Schindelin via GitGitGadget
2026-04-02 14:33 ` [PATCH 02/17] t0001: replace `cd`+`git` with `git --git-dir` in `check_config` Johannes Schindelin via GitGitGadget
2026-04-02 14:33 ` Johannes Schindelin via GitGitGadget [this message]
2026-04-02 14:33 ` [PATCH 04/17] t0056: allow implicit bare repo discovery for `-C` work-tree tests Johannes Schindelin via GitGitGadget
2026-04-02 14:33 ` [PATCH 05/17] t1020: use `--git-dir` instead of subshell for bare repo Johannes Schindelin via GitGitGadget
2026-04-02 14:33 ` [PATCH 06/17] t1900: avoid using `-C <dir>` for a bare repository Johannes Schindelin via GitGitGadget
2026-04-02 14:33 ` [PATCH 07/17] t2400: explicitly specify bare repo for `git worktree add` Johannes Schindelin via GitGitGadget
2026-04-02 14:33 ` [PATCH 08/17] t2406: use `--git-dir=.` for bare repository worktree repair Johannes Schindelin via GitGitGadget
2026-04-02 14:33 ` [PATCH 09/17] t5503: avoid discovering a bare repository Johannes Schindelin via GitGitGadget
2026-04-02 14:33 ` [PATCH 10/17] t5505: export `GIT_DIR` after `git init --bare` Johannes Schindelin via GitGitGadget
2026-04-02 14:33 ` [PATCH 11/17] t5509: specify bare repository path explicitly Johannes Schindelin via GitGitGadget
2026-04-02 20:44   ` Junio C Hamano
2026-04-03 14:22     ` Johannes Schindelin
2026-04-03 18:17       ` Junio C Hamano
2026-04-04 19:29         ` Johannes Schindelin
2026-04-02 14:33 ` [PATCH 12/17] t5540/t5541: avoid accessing a bare repository via `-C <dir>` Johannes Schindelin via GitGitGadget
2026-04-02 14:33 ` [PATCH 13/17] t5619: wrap `test_commit_bulk` in `GIT_DIR` subshell for bare repo Johannes Schindelin via GitGitGadget
2026-04-02 14:33 ` [PATCH 14/17] t6020: use `-C` for worktree, `--git-dir` for bare repository Johannes Schindelin via GitGitGadget
2026-04-02 14:33 ` [PATCH 15/17] t9210: pass `safe.bareRepository=all` to `scalar register` Johannes Schindelin via GitGitGadget
2026-04-02 14:33 ` [PATCH 16/17] t9700: stop relying on implicit bare repo discovery Johannes Schindelin via GitGitGadget
2026-04-02 14:33 ` [PATCH 17/17] git p4 clone --bare: need to be explicit about the gitdir Johannes Schindelin via GitGitGadget
2026-04-02 18:15 ` [PATCH 00/17] tests: access bare repositories explicitly Junio C Hamano
2026-04-04 19:45   ` Johannes Schindelin
2026-04-06 15:45     ` Junio C Hamano
2026-04-04 19:49 ` [PATCH v2 " Johannes Schindelin via GitGitGadget
2026-04-04 19:49   ` [PATCH v2 01/17] t0001: allow implicit bare repo discovery for aliased-command test Johannes Schindelin via GitGitGadget
2026-04-06 16:00     ` Junio C Hamano
2026-04-04 19:49   ` [PATCH v2 02/17] t0001: replace `cd`+`git` with `git --git-dir` in `check_config` Johannes Schindelin via GitGitGadget
2026-04-04 19:49   ` [PATCH v2 03/17] t0003: use `--git-dir` for bare repo attribute tests Johannes Schindelin via GitGitGadget
2026-04-04 19:49   ` [PATCH v2 04/17] t0056: allow implicit bare repo discovery for `-C` work-tree tests Johannes Schindelin via GitGitGadget
2026-04-04 19:49   ` [PATCH v2 05/17] t1020: use `--git-dir` instead of subshell for bare repo Johannes Schindelin via GitGitGadget
2026-04-04 19:49   ` [PATCH v2 06/17] t1900: avoid using `-C <dir>` for a bare repository Johannes Schindelin via GitGitGadget
2026-04-04 19:49   ` [PATCH v2 07/17] t2400: explicitly specify bare repo for `git worktree add` Johannes Schindelin via GitGitGadget
2026-04-04 19:49   ` [PATCH v2 08/17] t2406: use `--git-dir=.` for bare repository worktree repair Johannes Schindelin via GitGitGadget
2026-04-04 19:49   ` [PATCH v2 09/17] t5503: avoid discovering a bare repository Johannes Schindelin via GitGitGadget
2026-04-04 19:49   ` [PATCH v2 10/17] t5505: export `GIT_DIR` after `git init --bare` Johannes Schindelin via GitGitGadget
2026-04-04 19:49   ` [PATCH v2 11/17] t5509: specify bare repository path explicitly Johannes Schindelin via GitGitGadget
2026-04-04 19:49   ` [PATCH v2 12/17] t5540/t5541: avoid accessing a bare repository via `-C <dir>` Johannes Schindelin via GitGitGadget
2026-04-04 19:49   ` [PATCH v2 13/17] t5619: wrap `test_commit_bulk` in `GIT_DIR` subshell for bare repo Johannes Schindelin via GitGitGadget
2026-04-04 19:49   ` [PATCH v2 14/17] t6020: use `-C` for worktree, `--git-dir` for bare repository Johannes Schindelin via GitGitGadget
2026-04-04 19:49   ` [PATCH v2 15/17] t9210: pass `safe.bareRepository=all` to `scalar register` Johannes Schindelin via GitGitGadget
2026-04-04 19:49   ` [PATCH v2 16/17] t9700: stop relying on implicit bare repo discovery Johannes Schindelin via GitGitGadget
2026-04-04 19:49   ` [PATCH v2 17/17] git p4 clone --bare: need to be explicit about the gitdir Johannes Schindelin via GitGitGadget

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=a4f7a6df516c848936e6952dac8ca02ccb0ac643.1775140403.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    /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