Add t1510 and basic rules that run repo setup
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Nov 26, 2010 at 22:31 UTC
03a2b6effaeaebef86a3c524ecd6c77c70f53273
1 file changed
+59
t/t1510-repo-setup.sh
new
+59
@@ -0,0 +1,59 @@
1
+#!/bin/sh
2
+
3
+test_description='Tests of cwd/prefix/worktree/gitdir setup in all cases'
4
+
5
+. ./test-lib.sh
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
+#
41
+
42
+test_repo() {
43
+ (
44
+ if test -n "$1"; then cd "$1"; fi &&
45
+ if test -f trace; then rm trace; fi &&
46
+ GIT_TRACE="`pwd`/trace" git symbolic-ref HEAD >/dev/null &&
47
+ grep '^setup: ' trace >result &&
48
+ test_cmp expected result
49
+ )
50
+}
51
+
52
+# Bit 0 = GIT_WORK_TREE
53
+# Bit 1 = GIT_DIR
54
+# Bit 2 = core.worktree
55
+# Bit 3 = .git is a file
56
+# Bit 4 = bare repo
57
+# Case# = encoding of the above 5 bits
58
+
59
+test_done