Re: [PATCH 04/12] t: stop using GIT_CONFIG to cross repo boundaries

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH 04/12] t: stop using GIT_CONFIG to cross repo boundaries

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:00:25

Jeff King [off-list ref] writes:
Some tests want to check or set config in another
repository. E.g., t1000 creates repositories and makes sure
that their core.bare and core.worktree settings are what we
expect. We can do this with:

  GIT_CONFIG=$repo/.git/config git config ...

but it better shows the intent to just enter the repository
and let "git config" do the normal lookups:

  (cd $repo && git config ...)

In theory, this would cause us to use an extra subshell, but
in all such cases, we are actually already in a subshell.
Sure; alternatively we could use "git -C $there", but this rewrite
is fine by me.

Thanks.
quoted hunk
Signed-off-by: Jeff King <redacted>
---
 t/t0001-init.sh        | 4 ++--
 t/t5701-clone-local.sh | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index ddc8160..9b05fdf 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -12,8 +12,8 @@ check_config () {
 		echo "expected a directory $1, a file $1/config and $1/refs"
 		return 1
 	fi
-	bare=$(GIT_CONFIG="$1/config" git config --bool core.bare)
-	worktree=$(GIT_CONFIG="$1/config" git config core.worktree) ||
+	bare=$(cd "$1" && git config --bool core.bare)
+	worktree=$(cd "$1" && git config core.worktree) ||
 	worktree=unset
 
 	test "$bare" = "$2" && test "$worktree" = "$3" || {
diff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh
index c490368..3c087e9 100755
--- a/t/t5701-clone-local.sh
+++ b/t/t5701-clone-local.sh
@@ -12,8 +12,8 @@ test_expect_success 'preparing origin repository' '
 	: >file && git add . && git commit -m1 &&
 	git clone --bare . a.git &&
 	git clone --bare . x &&
-	test "$(GIT_CONFIG=a.git/config git config --bool core.bare)" = true &&
-	test "$(GIT_CONFIG=x/config git config --bool core.bare)" = true &&
+	test "$(cd a.git && git config --bool core.bare)" = true &&
+	test "$(cd x && git config --bool core.bare)" = true &&
 	git bundle create b1.bundle --all &&
 	git bundle create b2.bundle master &&
 	mkdir dir &&
@@ -24,7 +24,7 @@ test_expect_success 'preparing origin repository' '
 test_expect_success 'local clone without .git suffix' '
 	git clone -l -s a b &&
 	(cd b &&
-	test "$(GIT_CONFIG=.git/config git config --bool core.bare)" = false &&
+	test "$(git config --bool core.bare)" = false &&
 	git fetch)
 '

Re: [PATCH 04/12] t: stop using GIT_CONFIG to cross repo boundaries

From: Jeff King <hidden>
Date: 2016-06-15 23:00:26

On Fri, Mar 21, 2014 at 02:26:02PM -0700, Junio C Hamano wrote:
Jeff King [off-list ref] writes:
quoted
Some tests want to check or set config in another
repository. E.g., t1000 creates repositories and makes sure
that their core.bare and core.worktree settings are what we
expect. We can do this with:

  GIT_CONFIG=$repo/.git/config git config ...

but it better shows the intent to just enter the repository
and let "git config" do the normal lookups:

  (cd $repo && git config ...)

In theory, this would cause us to use an extra subshell, but
in all such cases, we are actually already in a subshell.
Sure; alternatively we could use "git -C $there", but this rewrite
is fine by me.
The existing callers all pass actual $GIT_DIRs, so I initially wrote it
as "git --git-dir=$repo config ...". Doing it as "-C" is perhaps nicer,
as callers could potentially pass a shorter string to the repo root,
and not bother with adding "/.git". However, t0001 needs the actual
$GIT_DIR (because it looks for things like the refs/ directory in the
same function), and the other callers are just passing bare repos.

So I'm fine with any of them. Feel free to mark it up if you have a
preference.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help