tests: cosmetic improvements to the repo-setup test
Give an overview in "sh t1510-repo-setup.sh --help" output. Waste some vertical and horizontal space for clearer code. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Nieder committed
Jan 19, 2011 at 06:38 UTC
91c031df677f167ac772a3d6a9b3e391b436615c
1 file changed
+50
-44
t/t1510-repo-setup.sh
+50
-44
@@ -1,53 +1,59 @@
1
#!/bin/sh
2
3
-test_description='Tests of cwd/prefix/worktree/gitdir setup in all cases'
3
+test_description="Tests of cwd/prefix/worktree/gitdir setup in all cases
4
5
-. ./test-lib.sh
5
+A few rules for repo setup:
6
7
-#
8
-# A few rules for repo setup:
9
-#
10
-# 1. GIT_DIR is relative to user's cwd. --git-dir is equivalent to
11
-# GIT_DIR.
12
-#
13
-# 2. .git file is relative to parent directory. .git file is basically
14
-# symlink in disguise. The directory where .git file points to will
15
-# become new git_dir.
16
-#
17
-# 3. core.worktree is relative to git_dir.
18
-#
19
-# 4. GIT_WORK_TREE is relative to user's cwd. --work-tree is
20
-# equivalent to GIT_WORK_TREE.
21
-#
22
-# 5. GIT_WORK_TREE/core.worktree is only effective if GIT_DIR is set
23
-# Uneffective worktree settings should be warned.
24
-#
25
-# 6. Effective GIT_WORK_TREE overrides core.worktree and core.bare
26
-#
27
-# 7. Effective core.worktree conflicts with core.bare
28
-#
29
-# 8. If GIT_DIR is set but neither worktree nor bare setting is given,
30
-# original cwd becomes worktree.
31
-#
32
-# 9. If .git discovery is done inside a repo, the repo becomes a bare
33
-# repo. .git discovery is performed if GIT_DIR is not set.
34
-#
35
-# 10. If no worktree is available, cwd remains unchanged, prefix is
36
-# NULL.
37
-#
38
-# 11. When user's cwd is outside worktree, cwd remains unchanged,
39
-# prefix is NULL.
40
-#
7
+1. GIT_DIR is relative to user's cwd. --git-dir is equivalent to
8
+ GIT_DIR.
9
+
10
+2. .git file is relative to parent directory. .git file is basically
11
+ symlink in disguise. The directory where .git file points to will
12
+ become new git_dir.
13
+
14
+3. core.worktree is relative to git_dir.
15
+
16
+4. GIT_WORK_TREE is relative to user's cwd. --work-tree is
17
+ equivalent to GIT_WORK_TREE.
18
+
19
+5. GIT_WORK_TREE/core.worktree is only effective if GIT_DIR is set
20
+ Uneffective worktree settings should be warned.
21
+
22
+6. Effective GIT_WORK_TREE overrides core.worktree and core.bare
23
+
24
+7. Effective core.worktree conflicts with core.bare
25
+
26
+8. If GIT_DIR is set but neither worktree nor bare setting is given,
27
+ original cwd becomes worktree.
28
+
29
+9. If .git discovery is done inside a repo, the repo becomes a bare
30
+ repo. .git discovery is performed if GIT_DIR is not set.
31
+
32
+10. If no worktree is available, cwd remains unchanged, prefix is
33
+ NULL.
34
+
35
+11. When user's cwd is outside worktree, cwd remains unchanged,
36
+ prefix is NULL.
37
+"
38
+. ./test-lib.sh
39
42
-test_repo() {
40
+test_repo () {
41
(
44
- cd "$1" &&
45
- if test -n "$2"; then GIT_DIR="$2" && export GIT_DIR; fi &&
46
- if test -n "$3"; then GIT_WORK_TREE="$3" && export GIT_WORK_TREE; fi &&
47
- rm -f trace &&
48
- GIT_TRACE="`pwd`/trace" git symbolic-ref HEAD >/dev/null &&
49
- grep '^setup: ' trace >result &&
50
- test_cmp expected result
42
+ cd "$1" &&
43
+ if test -n "$2"
44
+ then
45
+ GIT_DIR="$2" &&
46
+ export GIT_DIR
47
+ fi &&
48
+ if test -n "$3"
49
+ then
50
+ GIT_WORK_TREE="$3" &&
51
+ export GIT_WORK_TREE
52
+ fi &&
53
+ rm -f trace &&
54
+ GIT_TRACE="$(pwd)/trace" git symbolic-ref HEAD >/dev/null &&
55
+ grep '^setup: ' trace >result &&
56
+ test_cmp expected result
57
)
58
}
59