Skip to content

Commit d66f68f

Browse files
sunshinecogitster
authored andcommitted
t1500: be considerate to future potential tests
The final batch of git-rev-parse tests work against a non-local object database named repo.git. This is done by renaming .git to repo.git and pointing GIT_DIR at it, but the name is never restored to .git at the end of the script, which can be problematic for tests added in the future. Be more friendly by instead making repo.git a copy of .git. Furthermore, make it clear that tests in repo.git will be independent from the results of earlier tests done in .git by initializing repo.git earlier in the test sequence. Likewise, bundle remaining preparation (such as directory creation) into a common setup test consistent with modern practice. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d92347f commit d66f68f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

t/t1500-rev-parse.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ test_rev_parse() {
3737

3838
ROOT=$(pwd)
3939

40+
test_expect_success 'setup' '
41+
mkdir -p sub/dir work &&
42+
cp -R .git repo.git
43+
'
44+
4045
test_rev_parse toplevel false false true '' .git
4146

4247
cd .git || exit 1
@@ -45,7 +50,6 @@ cd objects || exit 1
4550
test_rev_parse .git/objects/ false true false '' "$ROOT/.git"
4651
cd ../.. || exit 1
4752

48-
mkdir -p sub/dir || exit 1
4953
cd sub/dir || exit 1
5054
test_rev_parse subdirectory false false true sub/dir/ "$ROOT/.git"
5155
cd ../.. || exit 1
@@ -56,7 +60,6 @@ test_rev_parse 'core.bare = true' true false false
5660
git config --unset core.bare
5761
test_rev_parse 'core.bare undefined' false false true
5862

59-
mkdir work || exit 1
6063
cd work || exit 1
6164
GIT_DIR=../.git
6265
GIT_CONFIG="$(pwd)"/../.git/config
@@ -71,7 +74,6 @@ test_rev_parse 'GIT_DIR=../.git, core.bare = true' true false false ''
7174
git config --unset core.bare
7275
test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true ''
7376

74-
mv ../.git ../repo.git || exit 1
7577
GIT_DIR=../repo.git
7678
GIT_CONFIG="$(pwd)"/../repo.git/config
7779

0 commit comments

Comments
 (0)