All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/34] repo setup test cases
@ 2010-10-27 14:49 Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 01/34] builtins: print setup info if repo is found Nguyễn Thái Ngọc Duy
                   ` (40 more replies)
  0 siblings, 41 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

A complete series after the WIP [1]. The rules are bent a bit, see 2/34.

178/376 test cases fail, but mostly because GIT_DIR=.git-file is
not supported. I'll send a bandage series shortly that will bring the
number of failed test cases to 20.

[1] 1287922310-14678-1-git-send-email-pclouds@gmail.com

Nguyễn Thái Ngọc Duy (34):
  builtins: print setup info if repo is found
  Add t1510 and basic rules that run repo setup
  t1510: setup case #0
  t1510: setup case #1
  t1510: setup case #2
  t1510: setup case #3
  t1510: setup case #4
  t1510: setup case #5
  t1510: setup case #6
  t1510: setup case #7
  t1510: setup case #8
  t1510: setup case #9
  t1510: setup case #10
  t1510: setup case #11
  t1510: setup case #12
  t1510: setup case #13
  t1510: setup case #14
  t1510: setup case #15
  t1510: setup case #16
  t1510: setup case #17
  t1510: setup case #18
  t1510: setup case #19
  t1510: setup case #20
  t1510: setup case #21
  t1510: setup case #22
  t1510: setup case #23
  t1510: setup case #24
  t1510: setup case #25
  t1510: setup case #26
  t1510: setup case #27
  t1510: setup case #28
  t1510: setup case #29
  t1510: setup case #30
  t1510: setup case #31

 cache.h               |    1 +
 git.c                 |   36 +
 t/t1510-repo-setup.sh | 4515 +++++++++++++++++++++++++++++++++++++++++++++++++
 trace.c               |   11 +
 4 files changed, 4563 insertions(+), 0 deletions(-)
 create mode 100755 t/t1510-repo-setup.sh

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH 01/34] builtins: print setup info if repo is found
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 02/34] Add t1510 and basic rules that run repo setup Nguyễn Thái Ngọc Duy
                   ` (39 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 It's not perfect. "setup: " lines won't always appear. That can be
 done once setup code is cleaned up a bit.

 cache.h |    1 +
 git.c   |   36 ++++++++++++++++++++++++++++++++++++
 trace.c |   11 +++++++++++
 3 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/cache.h b/cache.h
index 33decd9..d5ccf40 100644
--- a/cache.h
+++ b/cache.h
@@ -1058,6 +1058,7 @@ extern void *alloc_object_node(void);
 extern void alloc_report(void);
 
 /* trace.c */
+int has_trace_fd();
 __attribute__((format (printf, 1, 2)))
 extern void trace_printf(const char *format, ...);
 __attribute__((format (printf, 2, 3)))
diff --git a/git.c b/git.c
index 50a1401..22ade18 100644
--- a/git.c
+++ b/git.c
@@ -244,6 +244,29 @@ struct cmd_struct {
 	int option;
 };
 
+static const char *quote_crnl(const char *path)
+{
+	static char new_path[PATH_MAX];
+	const char *p2 = path;
+	char *p1 = new_path;
+
+	if (!path)
+		return NULL;
+
+	while (*p2) {
+		switch (*p2) {
+		case '\\': *p1++ = '\\'; *p1++ = '\\'; break;
+		case '\n': *p1++ = '\\'; *p1++ = 'n'; break;
+		case '\r': *p1++ = '\\'; *p1++ = 'r'; break;
+		default:
+			*p1++ = *p2;
+		}
+		p2++;
+	}
+	*p1 = '\0';
+	return new_path;
+}
+
 static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 {
 	int status, help;
@@ -264,6 +287,19 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 			use_pager = check_pager_config(p->cmd);
 		if (use_pager == -1 && p->option & USE_PAGER)
 			use_pager = 1;
+
+		if ((p->option & (RUN_SETUP | RUN_SETUP_GENTLY)) &&
+		    startup_info->have_repository && /* get_git_dir() may set up repo, avoid that */
+		    has_trace_fd()) {
+			char cwd[PATH_MAX];
+			if (!getcwd(cwd, PATH_MAX))
+				die("Unable to get current working directory");
+
+			trace_printf("setup: git_dir: %s\n", quote_crnl(get_git_dir()));
+			trace_printf("setup: worktree: %s\n", quote_crnl(get_git_work_tree()));
+			trace_printf("setup: cwd: %s\n", quote_crnl(cwd));
+			trace_printf("setup: prefix: %s\n", quote_crnl(prefix));
+		}
 	}
 	commit_pager_choice();
 
diff --git a/trace.c b/trace.c
index 1e560cb..fbf7de0 100644
--- a/trace.c
+++ b/trace.c
@@ -29,6 +29,17 @@ void do_nothing(size_t unused)
 {
 }
 
+int has_trace_fd()
+{
+	char *trace = getenv("GIT_TRACE");
+
+	if (!trace || !strcmp(trace, "") ||
+	    !strcmp(trace, "0") || !strcasecmp(trace, "false"))
+		return 0;
+
+	return 1;
+}
+
 /* Get a trace file descriptor from GIT_TRACE env variable. */
 static int get_trace_fd(int *need_close)
 {
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 02/34] Add t1510 and basic rules that run repo setup
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 01/34] builtins: print setup info if repo is found Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 15:37   ` Nguyen Thai Ngoc Duy
  2010-10-27 14:49 ` [PATCH 03/34] t1510: setup case #0 Nguyễn Thái Ngọc Duy
                   ` (38 subsequent siblings)
  40 siblings, 1 reply; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   59 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)
 create mode 100755 t/t1510-repo-setup.sh

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
new file mode 100755
index 0000000..218eb35
--- /dev/null
+++ b/t/t1510-repo-setup.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+test_description='Tests of cwd/prefix/worktree/gitdir setup in all cases'
+
+. ./test-lib.sh
+
+#
+# A few rules for repo setup:
+#
+# 1. GIT_DIR is relative to user's cwd. --git-dir is equivalent to
+#    GIT_DIR.
+#
+# 2. .git file is relative to git_dir. .git file is basically symlink
+#    in disguise. The directory where .git file points to will become
+#    new git_dir.
+#
+# 3. core.worktree is relative to git_dir.
+#
+# 4. GIT_WORK_TREE is relative to user's cwd. --work-tree is
+#    equivalent to GIT_WORK_TREE.
+#
+# 5. GIT_WORK_TREE/core.worktree is only effective if GIT_DIR is set
+#    Uneffective worktree settings should be warned.
+#
+# 6. Effective GIT_WORK_TREE overrides core.worktree and core.bare
+#
+# 7. Effective core.worktree conflicts with core.bare
+#
+# 8. If GIT_DIR is set but neither worktree nor bare setting is given,
+#    original cwd becomes worktree.
+#
+# 9. If .git discovery is done inside a repo, the repo becomes a bare
+#    repo. .git discovery is performed if GIT_DIR is not set.
+#
+# 10. If no worktree is available, cwd remains unchanged, prefix is
+#     NULL.
+#
+# 11. When user's cwd is outside worktree, cwd remains unchanged,
+#     prefix is NULL.
+#
+
+test_repo() {
+	(
+	if [ -n "$1" ]; then cd "$1"; fi &&
+	if [ -f trace ]; then rm trace; fi &&
+	GIT_TRACE="`pwd`/trace" git symbolic-ref HEAD >/dev/null &&
+	grep '^setup: ' trace >result &&
+	test_cmp expected result
+	)
+}
+
+# Bit 0 = GIT_WORK_TREE
+# Bit 1 = GIT_DIR
+# Bit 2 = core.worktree
+# Bit 3 = .git is a file
+# Bit 4 = bare repo
+# Case# = encoding of the above 5 bits
+
+test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 03/34] t1510: setup case #0
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 01/34] builtins: print setup info if repo is found Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 02/34] Add t1510 and basic rules that run repo setup Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 04/34] t1510: setup case #1 Nguyễn Thái Ngọc Duy
                   ` (37 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 218eb35..d94a2d6 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -56,4 +56,51 @@ test_repo() {
 # Bit 4 = bare repo
 # Case# = encoding of the above 5 bits
 
+#
+# Case #0
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is not set
+#  - core.worktree is not set
+#  - .git is a directory
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+#  - worktree is .git's parent directory
+#  - cwd is at worktree root dir
+#  - prefix is calculated
+#  - git_dir is set to ".git"
+#  - cwd can't be outside worktree
+
+test_expect_success '#0: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 0 0/sub &&
+	cd 0 && git init && cd ..
+'
+
+test_expect_success '#0: at root' '
+	cat >0/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/0
+setup: cwd: $TRASH_DIRECTORY/0
+setup: prefix: (null)
+EOF
+	test_repo 0
+'
+
+test_expect_success '#0: in subdir' '
+	cat >0/sub/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/0
+setup: cwd: $TRASH_DIRECTORY/0
+setup: prefix: sub/
+EOF
+	test_repo 0/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 04/34] t1510: setup case #1
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (2 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 03/34] t1510: setup case #0 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 05/34] t1510: setup case #2 Nguyễn Thái Ngọc Duy
                   ` (36 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index d94a2d6..0ff659a 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -103,4 +103,50 @@ EOF
 	test_repo 0/sub
 '
 
+#
+# case #1
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is not set
+#  - core.worktree is not set
+#  - .git is a directory
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+# GIT_WORK_TREE is ignored -> #0
+
+test_expect_success '#1: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 1 1/sub 1.wt 1.wt/sub 1/wt 1/wt/sub &&
+	cd 1 &&
+	git init &&
+	export GIT_WORK_TREE=non-existent &&
+	cd ..
+'
+
+test_expect_failure '#1: at root' '
+	cat >1/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/1
+setup: cwd: $TRASH_DIRECTORY/1
+setup: prefix: (null)
+EOF
+	test_repo 1
+'
+
+test_expect_failure '#1: in subdir' '
+	cat >1/sub/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/1
+setup: cwd: $TRASH_DIRECTORY/1
+setup: prefix: sub/
+EOF
+	test_repo 1/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 05/34] t1510: setup case #2
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (3 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 04/34] t1510: setup case #1 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 06/34] t1510: setup case #3 Nguyễn Thái Ngọc Duy
                   ` (35 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   67 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 0ff659a..bf008c6 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -149,4 +149,71 @@ EOF
 	test_repo 1/sub
 '
 
+#
+# case #2
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is set
+#  - core.worktree is not set
+#  - .git is a directory
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+#  - worktree is at original cwd
+#  - cwd is unchanged
+#  - prefix is NULL
+#  - git_dir is set to $GIT_DIR
+#  - cwd can't be outside worktree
+
+test_expect_success '#2: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 2 2/sub &&
+	cd 2 && git init && cd ..
+'
+
+test_expect_success '#2: at root' '
+	cat >2/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/2/.git
+setup: worktree: $TRASH_DIRECTORY/2
+setup: cwd: $TRASH_DIRECTORY/2
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/2/.git" test_repo 2
+'
+
+test_expect_success '#2: in subdir' '
+	cat >2/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/2/.git
+setup: worktree: $TRASH_DIRECTORY/2/sub
+setup: cwd: $TRASH_DIRECTORY/2/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/2/.git" test_repo 2/sub
+'
+
+test_expect_success '#2: relative GIT_DIR at root' '
+	cat >2/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/2
+setup: cwd: $TRASH_DIRECTORY/2
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git test_repo 2
+'
+
+test_expect_success '#2: relative GIT_DIR in subdir' '
+	cat >2/sub/expected <<EOF &&
+setup: git_dir: ../.git
+setup: worktree: $TRASH_DIRECTORY/2/sub
+setup: cwd: $TRASH_DIRECTORY/2/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../.git test_repo 2/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 06/34] t1510: setup case #3
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (4 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 05/34] t1510: setup case #2 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 07/34] t1510: setup case #4 Nguyễn Thái Ngọc Duy
                   ` (34 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |  267 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 267 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index bf008c6..e1b8958 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -216,4 +216,271 @@ EOF
 	GIT_DIR=../.git test_repo 2/sub
 '
 
+#
+# case #3
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is set
+#  - core.worktree is not set
+#  - .git is a directory
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+#  - worktree is set to $GIT_WORK_TREE
+#  - cwd is at worktree root
+#  - prefix is calculated
+#  - git_dir is set to $GIT_DIR
+#  - cwd can be outside worktree
+
+test_expect_success '#3: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 3 3/sub 3/sub/sub 3.wt 3.wt/sub 3/wt 3/wt/sub &&
+	cd 3 && git init && cd ..
+'
+
+test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
+	cat >3/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/3
+setup: cwd: $TRASH_DIRECTORY/3
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/3" test_repo 3
+'
+
+test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
+	cat >3/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/3
+setup: cwd: $TRASH_DIRECTORY/3
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=. test_repo 3
+'
+
+test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=root at root' '
+	cat >3/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY/3
+setup: cwd: $TRASH_DIRECTORY/3
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/3/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/3" test_repo 3
+'
+
+test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
+	cat >3/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY/3
+setup: cwd: $TRASH_DIRECTORY/3
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/3/.git" GIT_WORK_TREE=. test_repo 3
+'
+
+test_expect_success '#3: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
+	cat >3/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY/3
+setup: cwd: $TRASH_DIRECTORY/3
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY/3" test_repo 3/sub/sub
+'
+
+test_expect_success '#3: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
+	cat >3/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY/3
+setup: cwd: $TRASH_DIRECTORY/3
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../.. test_repo 3/sub/sub
+'
+
+test_expect_success '#3: GIT_DIR, GIT_WORKTREE=root in subdir' '
+	cat >3/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY/3
+setup: cwd: $TRASH_DIRECTORY/3
+setup: prefix: sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/3/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/3" test_repo 3/sub
+'
+
+test_expect_success '#3: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
+	cat >3/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY/3
+setup: cwd: $TRASH_DIRECTORY/3
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/3/.git" GIT_WORK_TREE=../.. test_repo 3/sub/sub
+'
+
+test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
+	cat >3/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/3/wt
+setup: cwd: $TRASH_DIRECTORY/3
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/3/wt" test_repo 3
+'
+
+test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
+	cat >3/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/3/wt
+setup: cwd: $TRASH_DIRECTORY/3
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=wt test_repo 3
+'
+
+test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
+	cat >3/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY/3/wt
+setup: cwd: $TRASH_DIRECTORY/3
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/3/.git" GIT_WORK_TREE=wt test_repo 3
+'
+
+test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt at root' '
+	cat >3/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY/3/wt
+setup: cwd: $TRASH_DIRECTORY/3
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/3/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/3/wt" test_repo 3
+'
+
+test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
+	cat >3/sub/sub/expected <<EOF &&
+setup: git_dir: ../../.git
+setup: worktree: $TRASH_DIRECTORY/3/wt
+setup: cwd: $TRASH_DIRECTORY/3/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY/3/wt" test_repo 3/sub/sub
+'
+
+test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >3/sub/sub/expected <<EOF &&
+setup: git_dir: ../../.git
+setup: worktree: $TRASH_DIRECTORY/3/wt
+setup: cwd: $TRASH_DIRECTORY/3/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../../wt test_repo 3/sub/sub
+'
+
+test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >3/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY/3/wt
+setup: cwd: $TRASH_DIRECTORY/3/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/3/.git" GIT_WORK_TREE=../../wt test_repo 3/sub/sub
+'
+
+test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
+	cat >3/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY/3/wt
+setup: cwd: $TRASH_DIRECTORY/3/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/3/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/3/wt" test_repo 3/sub/sub
+'
+
+test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
+	cat >3/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 3/
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 3
+'
+
+test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
+	cat >3/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 3/
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=.. test_repo 3
+'
+
+test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
+	cat >3/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 3/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/3/.git" GIT_WORK_TREE=.. test_repo 3
+'
+
+test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=.. at root' '
+	cat >3/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 3/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/3/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 3
+'
+
+test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
+	cat >3/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 3/sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 3/sub/sub
+'
+
+test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
+	cat >3/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 3/sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../../.. test_repo 3/sub/sub
+'
+
+test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
+	cat >3/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 3/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/3/.git" GIT_WORK_TREE=../../../ test_repo 3/sub/sub
+'
+
+test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
+	cat >3/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/3/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 3/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/3/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 3/sub/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 07/34] t1510: setup case #4
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (5 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 06/34] t1510: setup case #3 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 08/34] t1510: setup case #5 Nguyễn Thái Ngọc Duy
                   ` (33 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index e1b8958..6617792 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -483,4 +483,50 @@ EOF
 	GIT_DIR="$TRASH_DIRECTORY/3/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 3/sub/sub
 '
 
+#
+# case #4
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is not set
+#  - core.worktree is set
+#  - .git is a directory
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+# core.worktree is ignored -> #0
+
+test_expect_success '#4: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 4 4/sub &&
+	cd 4 &&
+	git init &&
+	git config core.worktree non-existent &&
+	cd ..
+'
+
+test_expect_failure '#4: at root' '
+	cat >4/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/4
+setup: cwd: $TRASH_DIRECTORY/4
+setup: prefix: (null)
+EOF
+	test_repo 4
+'
+
+test_expect_failure '#4: in subdir' '
+	cat >4/sub/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/4
+setup: cwd: $TRASH_DIRECTORY/4
+setup: prefix: sub/
+EOF
+	test_repo 4/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 08/34] t1510: setup case #5
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (6 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 07/34] t1510: setup case #4 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 09/34] t1510: setup case #6 Nguyễn Thái Ngọc Duy
                   ` (32 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 6617792..3d0498a 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -529,4 +529,51 @@ EOF
 	test_repo 4/sub
 '
 
+#
+# case #5
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is not set
+#  - core.worktree is set
+#  - .git is a directory
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+# GIT_WORK_TREE/core.worktree are ignored -> #0
+
+test_expect_success '#5: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 5 5/sub &&
+	cd 5 &&
+	git init &&
+	git config core.worktree non-existent &&
+	export GIT_WORK_TREE=non-existent-too &&
+	cd ..
+'
+
+test_expect_failure '#5: at root' '
+	cat >5/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/5
+setup: cwd: $TRASH_DIRECTORY/5
+setup: prefix: (null)
+EOF
+	test_repo 5
+'
+
+test_expect_failure '#5: in subdir' '
+	cat >5/sub/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/5
+setup: cwd: $TRASH_DIRECTORY/5
+setup: prefix: sub/
+EOF
+	test_repo 5/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 09/34] t1510: setup case #6
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (7 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 08/34] t1510: setup case #5 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 10/34] t1510: setup case #7 Nguyễn Thái Ngọc Duy
                   ` (31 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |  291 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 291 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 3d0498a..6e69ad7 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -576,4 +576,295 @@ EOF
 	test_repo 5/sub
 '
 
+#
+# case #6
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is set
+#  - core.worktree is set
+#  - .git is a directory
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+#  - worktree is at core.worktree
+#  - cwd is at worktree root
+#  - prefix is calculated
+#  - git_dir is at $GIT_DIR
+#  - cwd can be outside worktree
+
+test_expect_success '#6: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 6 6/sub 6/sub/sub 6.wt 6.wt/sub 6/wt 6/wt/sub &&
+	cd 6 && git init && cd ..
+'
+
+test_expect_success '#6: GIT_DIR(rel), core.worktree=.. at root' '
+	cat >6/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/6
+setup: cwd: $TRASH_DIRECTORY/6
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
+	GIT_DIR=.git test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR(rel), core.worktree=..(rel) at root' '
+	cat >6/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/6
+setup: cwd: $TRASH_DIRECTORY/6
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
+	GIT_DIR=.git test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR, core.worktree=.. at root' '
+	cat >6/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/6/.git
+setup: worktree: $TRASH_DIRECTORY/6
+setup: cwd: $TRASH_DIRECTORY/6
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR, core.worktree=..(rel) at root' '
+	cat >6/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/6/.git
+setup: worktree: $TRASH_DIRECTORY/6
+setup: cwd: $TRASH_DIRECTORY/6
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6
+'
+
+test_expect_failure '#6: GIT_DIR(rel), core.worktree=.. in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/6/.git
+setup: worktree: $TRASH_DIRECTORY/6
+setup: cwd: $TRASH_DIRECTORY/6
+setup: prefix: sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
+	GIT_DIR=../../.git test_repo 6/sub/sub
+'
+
+test_expect_failure '#6: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/6/.git
+setup: worktree: $TRASH_DIRECTORY/6
+setup: cwd: $TRASH_DIRECTORY/6
+setup: prefix: sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
+	GIT_DIR=../../.git test_repo 6/sub/sub
+'
+
+test_expect_success '#6: GIT_DIR, core.worktree=.. in subdir' '
+	cat >6/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/6/.git
+setup: worktree: $TRASH_DIRECTORY/6
+setup: cwd: $TRASH_DIRECTORY/6
+setup: prefix: sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6/sub
+'
+
+test_expect_success '#6: GIT_DIR, core.worktree=..(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/6/.git
+setup: worktree: $TRASH_DIRECTORY/6
+setup: cwd: $TRASH_DIRECTORY/6
+setup: prefix: sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6/sub/sub
+'
+
+test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt at root' '
+	cat >6/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/6/wt
+setup: cwd: $TRASH_DIRECTORY/6
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
+	GIT_DIR=.git test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt(rel) at root' '
+	cat >6/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/6/wt
+setup: cwd: $TRASH_DIRECTORY/6
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
+	GIT_DIR=.git test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR, core.worktree=../wt(rel) at root' '
+	cat >6/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/6/.git
+setup: worktree: $TRASH_DIRECTORY/6/wt
+setup: cwd: $TRASH_DIRECTORY/6
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR, core.worktree=../wt at root' '
+	cat >6/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/6/.git
+setup: worktree: $TRASH_DIRECTORY/6/wt
+setup: cwd: $TRASH_DIRECTORY/6
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+setup: git_dir: ../../.git
+setup: worktree: $TRASH_DIRECTORY/6/wt
+setup: cwd: $TRASH_DIRECTORY/6/sub/sub
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
+	GIT_DIR=../../.git test_repo 6/sub/sub
+'
+
+test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+setup: git_dir: ../../.git
+setup: worktree: $TRASH_DIRECTORY/6/wt
+setup: cwd: $TRASH_DIRECTORY/6/sub/sub
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
+	GIT_DIR=../../.git test_repo 6/sub/sub
+'
+
+test_expect_success '#6: GIT_DIR, core.worktree=../wt(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/6/.git
+setup: worktree: $TRASH_DIRECTORY/6/wt
+setup: cwd: $TRASH_DIRECTORY/6/sub/sub
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6/sub/sub
+'
+
+test_expect_success '#6: GIT_DIR, core.worktree=../wt in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/6/.git
+setup: worktree: $TRASH_DIRECTORY/6/wt
+setup: cwd: $TRASH_DIRECTORY/6/sub/sub
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6/sub/sub
+'
+
+test_expect_success '#6: GIT_DIR(rel), core.worktree=../.. at root' '
+	cat >6/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 6/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR=.git test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR(rel), core.worktree=../..(rel) at root' '
+	cat >6/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 6/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../../ &&
+	GIT_DIR=.git test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR, core.worktree=../..(rel) at root' '
+	cat >6/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/6/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 6/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../../ &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR, core.worktree=../.. at root' '
+	cat >6/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/6/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 6/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6
+'
+
+test_expect_failure '#6: GIT_DIR(rel), core.worktree=../.. in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/6/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 6/sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR=../../.git test_repo 6/sub/sub
+'
+
+test_expect_failure '#6: GIT_DIR(rel), core.worktree=../..(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/6/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 6/sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../.. &&
+	GIT_DIR=../../.git test_repo 6/sub/sub
+'
+
+test_expect_success '#6: GIT_DIR, core.worktree=../..(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/6/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 6/sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../.. &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6/sub/sub
+'
+
+test_expect_success '#6: GIT_DIR, core.worktree=../.. in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/6/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 6/sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6/sub/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 10/34] t1510: setup case #7
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (8 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 09/34] t1510: setup case #6 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 11/34] t1510: setup case #8 Nguyễn Thái Ngọc Duy
                   ` (30 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |  266 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 266 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 6e69ad7..968a5b2 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -867,4 +867,270 @@ EOF
 	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6/sub/sub
 '
 
+#
+# case #7
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is set
+#  - core.worktree is set
+#  - .git is a directory
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+# core.worktree is overridden by GIT_WORK_TREE -> #3
+
+test_expect_success '#7: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 7 7/sub 7/sub/sub 7.wt 7.wt/sub 7/wt 7/wt/sub &&
+	cd 7 &&
+	git init &&
+	git config core.worktree non-existent &&
+	cd ..
+'
+
+test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
+	cat >7/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/7
+setup: cwd: $TRASH_DIRECTORY/7
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/7" test_repo 7
+'
+
+test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
+	cat >7/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/7
+setup: cwd: $TRASH_DIRECTORY/7
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=. test_repo 7
+'
+
+test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=root at root' '
+	cat >7/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY/7
+setup: cwd: $TRASH_DIRECTORY/7
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/7/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/7" test_repo 7
+'
+
+test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
+	cat >7/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY/7
+setup: cwd: $TRASH_DIRECTORY/7
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/7/.git" GIT_WORK_TREE=. test_repo 7
+'
+
+test_expect_success '#7: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
+	cat >7/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY/7
+setup: cwd: $TRASH_DIRECTORY/7
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY/7" test_repo 7/sub/sub
+'
+
+test_expect_success '#7: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
+	cat >7/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY/7
+setup: cwd: $TRASH_DIRECTORY/7
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../.. test_repo 7/sub/sub
+'
+
+test_expect_success '#7: GIT_DIR, GIT_WORKTREE=root in subdir' '
+	cat >7/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY/7
+setup: cwd: $TRASH_DIRECTORY/7
+setup: prefix: sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/7/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/7" test_repo 7/sub
+'
+
+test_expect_success '#7: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
+	cat >7/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY/7
+setup: cwd: $TRASH_DIRECTORY/7
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/7/.git" GIT_WORK_TREE=../.. test_repo 7/sub/sub
+'
+
+test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
+	cat >7/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/7/wt
+setup: cwd: $TRASH_DIRECTORY/7
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/7/wt" test_repo 7
+'
+
+test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
+	cat >7/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/7/wt
+setup: cwd: $TRASH_DIRECTORY/7
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=wt test_repo 7
+'
+
+test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
+	cat >7/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY/7/wt
+setup: cwd: $TRASH_DIRECTORY/7
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/7/.git" GIT_WORK_TREE=wt test_repo 7
+'
+
+test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt at root' '
+	cat >7/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY/7/wt
+setup: cwd: $TRASH_DIRECTORY/7
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/7/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/7/wt" test_repo 7
+'
+
+test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
+	cat >7/sub/sub/expected <<EOF &&
+setup: git_dir: ../../.git
+setup: worktree: $TRASH_DIRECTORY/7/wt
+setup: cwd: $TRASH_DIRECTORY/7/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY/7/wt" test_repo 7/sub/sub
+'
+
+test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >7/sub/sub/expected <<EOF &&
+setup: git_dir: ../../.git
+setup: worktree: $TRASH_DIRECTORY/7/wt
+setup: cwd: $TRASH_DIRECTORY/7/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../../wt test_repo 7/sub/sub
+'
+
+test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >7/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY/7/wt
+setup: cwd: $TRASH_DIRECTORY/7/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/7/.git" GIT_WORK_TREE=../../wt test_repo 7/sub/sub
+'
+
+test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
+	cat >7/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY/7/wt
+setup: cwd: $TRASH_DIRECTORY/7/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/7/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/7/wt" test_repo 7/sub/sub
+'
+
+test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
+	cat >7/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 7/
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 7
+'
+
+test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
+	cat >7/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 7/
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=.. test_repo 7
+'
+
+test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
+	cat >7/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 7/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/7/.git" GIT_WORK_TREE=.. test_repo 7
+'
+
+test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=.. at root' '
+	cat >7/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 7/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/7/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 7
+'
+
+test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
+	cat >7/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 7/sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 7/sub/sub
+'
+
+test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
+	cat >7/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 7/sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../../.. test_repo 7/sub/sub
+'
+
+test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
+	cat >7/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 7/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/7/.git" GIT_WORK_TREE=../../../ test_repo 7/sub/sub
+'
+
+test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
+	cat >7/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/7/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 7/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/7/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 7/sub/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 11/34] t1510: setup case #8
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (9 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 10/34] t1510: setup case #7 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 12/34] t1510: setup case #9 Nguyễn Thái Ngọc Duy
                   ` (29 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 968a5b2..5ca9f4a 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -1133,4 +1133,51 @@ EOF
 	GIT_DIR="$TRASH_DIRECTORY/7/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 7/sub/sub
 '
 
+#
+# case #8
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is not set
+#  - core.worktree is not set
+#  - .git is a file
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+# #0 except that git_dir is set by .git file
+
+test_expect_success '#8: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 8 8/sub &&
+	cd 8 &&
+	git init &&
+	mv .git ../8.git &&
+	echo gitdir: ../8.git >.git &&
+	cd ..
+'
+
+test_expect_success '#8: at root' '
+	cat >8/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/8.git
+setup: worktree: $TRASH_DIRECTORY/8
+setup: cwd: $TRASH_DIRECTORY/8
+setup: prefix: (null)
+EOF
+	test_repo 8
+'
+
+test_expect_success '#8: in subdir' '
+	cat >8/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/8.git
+setup: worktree: $TRASH_DIRECTORY/8
+setup: cwd: $TRASH_DIRECTORY/8
+setup: prefix: sub/
+EOF
+	test_repo 8/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 12/34] t1510: setup case #9
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (10 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 11/34] t1510: setup case #8 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 13/34] t1510: setup case #10 Nguyễn Thái Ngọc Duy
                   ` (28 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 5ca9f4a..1406a8d 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -1180,4 +1180,51 @@ EOF
 	test_repo 8/sub
 '
 
+#
+# case #9
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is not set
+#  - core.worktree is not set
+#  - .git is a file
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+# #1 except that git_dir is set by .git file
+
+test_expect_success '#9: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 9 9/sub 9.wt 9.wt/sub 9/wt 9/wt/sub &&
+	cd 9 &&
+	git init &&
+	mv .git ../9.git &&
+	echo gitdir: ../9.git >.git &&
+	cd ..
+'
+
+test_expect_failure '#9: at root' '
+	cat >9/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/9.git
+setup: worktree: $TRASH_DIRECTORY/9
+setup: cwd: $TRASH_DIRECTORY/9
+setup: prefix: (null)
+EOF
+	GIT_WORK_TREE=non-existent test_repo 9
+'
+
+test_expect_failure '#9: in subdir' '
+	cat >9/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/9.git
+setup: worktree: $TRASH_DIRECTORY/9
+setup: cwd: $TRASH_DIRECTORY/9
+setup: prefix: sub/
+EOF
+	GIT_WORK_TREE=non-existent test_repo 9/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 13/34] t1510: setup case #10
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (11 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 12/34] t1510: setup case #9 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 14/34] t1510: setup case #11 Nguyễn Thái Ngọc Duy
                   ` (27 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   67 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 1406a8d..73b18a2 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -1227,4 +1227,71 @@ EOF
 	GIT_WORK_TREE=non-existent test_repo 9/sub
 '
 
+#
+# case #10
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is set
+#  - core.worktree is not set
+#  - .git is a file
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+# #2 except that git_dir is set by .git file
+
+test_expect_success '#10: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 10 10/sub &&
+	cd 10 &&
+	git init &&
+	mv .git ../10.git &&
+	echo gitdir: ../10.git >.git &&
+	cd ..
+'
+
+test_expect_failure '#10: at root' '
+	cat >10/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/10.git
+setup: worktree: $TRASH_DIRECTORY/10
+setup: cwd: $TRASH_DIRECTORY/10
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/10/.git" test_repo 10
+'
+
+test_expect_failure '#10: in subdir' '
+	cat >10/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/10.git
+setup: worktree: $TRASH_DIRECTORY/10/sub
+setup: cwd: $TRASH_DIRECTORY/10/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/10/.git" test_repo 10/sub
+'
+
+test_expect_failure '#10: relative GIT_DIR at root' '
+	cat >10/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/10.git
+setup: worktree: $TRASH_DIRECTORY/10
+setup: cwd: $TRASH_DIRECTORY/10
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git test_repo 10
+'
+
+test_expect_failure '#10: relative GIT_DIR in subdir' '
+	cat >10/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/10.git
+setup: worktree: $TRASH_DIRECTORY/10/sub
+setup: cwd: $TRASH_DIRECTORY/10/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../.git test_repo 10/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 14/34] t1510: setup case #11
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (12 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 13/34] t1510: setup case #10 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 15/34] t1510: setup case #12 Nguyễn Thái Ngọc Duy
                   ` (26 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |  267 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 267 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 73b18a2..844d204 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -1294,4 +1294,271 @@ EOF
 	GIT_DIR=../.git test_repo 10/sub
 '
 
+#
+# case #11
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is set
+#  - core.worktree is not set
+#  - .git is a file
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+# #3 except that git_dir is set by .git file
+
+test_expect_success '#11: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 11 11/sub 11/sub/sub 11.wt 11.wt/sub 11/wt 11/wt/sub &&
+	cd 11 &&
+	git init &&
+	mv .git ../11.git &&
+	echo gitdir: ../11.git >.git &&
+	cd ..
+'
+
+test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
+	cat >11/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY/11
+setup: cwd: $TRASH_DIRECTORY/11
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/11" test_repo 11
+'
+
+test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
+	cat >11/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY/11
+setup: cwd: $TRASH_DIRECTORY/11
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=. test_repo 11
+'
+
+test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=root at root' '
+	cat >11/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY/11
+setup: cwd: $TRASH_DIRECTORY/11
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/11/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/11" test_repo 11
+'
+
+test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
+	cat >11/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY/11
+setup: cwd: $TRASH_DIRECTORY/11
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/11/.git" GIT_WORK_TREE=. test_repo 11
+'
+
+test_expect_failure '#11: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
+	cat >11/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY/11
+setup: cwd: $TRASH_DIRECTORY/11
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY/11" test_repo 11/sub/sub
+'
+
+test_expect_failure '#11: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
+	cat >11/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY/11
+setup: cwd: $TRASH_DIRECTORY/11
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../.. test_repo 11/sub/sub
+'
+
+test_expect_failure '#11: GIT_DIR, GIT_WORKTREE=root in subdir' '
+	cat >11/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY/11
+setup: cwd: $TRASH_DIRECTORY/11
+setup: prefix: sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/11/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/11" test_repo 11/sub
+'
+
+test_expect_failure '#11: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
+	cat >11/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY/11
+setup: cwd: $TRASH_DIRECTORY/11
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/11/.git" GIT_WORK_TREE=../.. test_repo 11/sub/sub
+'
+
+test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
+	cat >11/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY/11/wt
+setup: cwd: $TRASH_DIRECTORY/11
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/11/wt" test_repo 11
+'
+
+test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
+	cat >11/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY/11/wt
+setup: cwd: $TRASH_DIRECTORY/11
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=wt test_repo 11
+'
+
+test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
+	cat >11/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY/11/wt
+setup: cwd: $TRASH_DIRECTORY/11
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/11/.git" GIT_WORK_TREE=wt test_repo 11
+'
+
+test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=wt at root' '
+	cat >11/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY/11/wt
+setup: cwd: $TRASH_DIRECTORY/11
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/11/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/11/wt" test_repo 11
+'
+
+test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
+	cat >11/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY/11/wt
+setup: cwd: $TRASH_DIRECTORY/11/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY/11/wt" test_repo 11/sub/sub
+'
+
+test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >11/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY/11/wt
+setup: cwd: $TRASH_DIRECTORY/11/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../../wt test_repo 11/sub/sub
+'
+
+test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >11/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY/11/wt
+setup: cwd: $TRASH_DIRECTORY/11/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/11/.git" GIT_WORK_TREE=../../wt test_repo 11/sub/sub
+'
+
+test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
+	cat >11/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY/11/wt
+setup: cwd: $TRASH_DIRECTORY/11/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/11/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/11/wt" test_repo 11/sub/sub
+'
+
+test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
+	cat >11/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 11/
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 11
+'
+
+test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
+	cat >11/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 11/
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=.. test_repo 11
+'
+
+test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
+	cat >11/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 11/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/11/.git" GIT_WORK_TREE=.. test_repo 11
+'
+
+test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=.. at root' '
+	cat >11/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 11/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/11/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 11
+'
+
+test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
+	cat >11/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 11/sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 11/sub/sub
+'
+
+test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
+	cat >11/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 11/sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../../.. test_repo 11/sub/sub
+'
+
+test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
+	cat >11/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 11/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/11/.git" GIT_WORK_TREE=../../../ test_repo 11/sub/sub
+'
+
+test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
+	cat >11/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/11.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 11/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/11/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 11/sub/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 15/34] t1510: setup case #12
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (13 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 14/34] t1510: setup case #11 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 16/34] t1510: setup case #13 Nguyễn Thái Ngọc Duy
                   ` (25 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 844d204..22a8894 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -1561,4 +1561,53 @@ EOF
 	GIT_DIR="$TRASH_DIRECTORY/11/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 11/sub/sub
 '
 
+#
+# case #12
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is not set
+#  - core.worktree is set
+#  - .git is a file
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+# #4 except that git_dir is set by .git file
+
+
+test_expect_success '#12: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 12 12/sub 12/sub/sub 12.wt 12.wt/sub 12/wt 12/wt/sub &&
+	cd 12 &&
+	git init &&
+	git config core.worktree non-existent &&
+	mv .git ../12.git &&
+	echo gitdir: ../12.git >.git &&
+	cd ..
+'
+
+test_expect_failure '#12: at root' '
+	cat >12/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/12.git
+setup: worktree: $TRASH_DIRECTORY/12
+setup: cwd: $TRASH_DIRECTORY/12
+setup: prefix: (null)
+EOF
+	test_repo 12
+'
+
+test_expect_failure '#12: in subdir' '
+	cat >12/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/12.git
+setup: worktree: $TRASH_DIRECTORY/12
+setup: cwd: $TRASH_DIRECTORY/12
+setup: prefix: sub/
+EOF
+	test_repo 12/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 16/34] t1510: setup case #13
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (14 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 15/34] t1510: setup case #12 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 17/34] t1510: setup case #14 Nguyễn Thái Ngọc Duy
                   ` (24 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 22a8894..ec0a993 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -1610,4 +1610,53 @@ EOF
 	test_repo 12/sub
 '
 
+#
+# case #13
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is not set
+#  - core.worktree is set
+#  - .git is a file
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+# #5 except that git_dir is set by .git file
+
+test_expect_success '#13: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 13 13/sub 13/sub/sub 13.wt 13.wt/sub 13/wt 13/wt/sub &&
+	cd 13 &&
+	git init &&
+	git config core.worktree non-existent &&
+	export GIT_WORK_TREE=non-existent too &&
+	mv .git ../13.git &&
+	echo gitdir: ../13.git >.git &&
+	cd ..
+'
+
+test_expect_failure '#13: at root' '
+	cat >13/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/13.git
+setup: worktree: $TRASH_DIRECTORY/13
+setup: cwd: $TRASH_DIRECTORY/13
+setup: prefix: (null)
+EOF
+	test_repo 13
+'
+
+test_expect_failure '#13: in subdir' '
+	cat >13/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/13.git
+setup: worktree: $TRASH_DIRECTORY/13
+setup: cwd: $TRASH_DIRECTORY/13
+setup: prefix: sub/
+EOF
+	test_repo 13/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 17/34] t1510: setup case #14
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (15 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 16/34] t1510: setup case #13 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 18/34] t1510: setup case #15 Nguyễn Thái Ngọc Duy
                   ` (23 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |  291 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 291 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index ec0a993..0cd00ea 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -1659,4 +1659,295 @@ EOF
 	test_repo 13/sub
 '
 
+#
+# case #14
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is set
+#  - core.worktree is set
+#  - .git is a file
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+# #6 except that git_dir is set by .git file
+
+test_expect_success '#14: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 14 14/sub 14/sub/sub 14.wt 14.wt/sub 14/wt 14/wt/sub &&
+	cd 14 &&
+	git init &&
+	mv .git ../14.git &&
+	echo gitdir: ../14.git >.git &&
+	cd ..
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=.. at root' '
+	cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
+	GIT_DIR=.git test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=..(rel) at root' '
+	cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
+	GIT_DIR=.git test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=.. at root' '
+	cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=..(rel) at root' '
+	cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=.. in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
+	GIT_DIR=../../.git test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
+	GIT_DIR=../../.git test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=.. in subdir' '
+	cat >14/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14/sub
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=..(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=../wt at root' '
+	cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14/wt
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
+	GIT_DIR=.git test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=../wt(rel) at root' '
+	cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14/wt
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../wt &&
+	GIT_DIR=.git test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=../wt(rel) at root' '
+	cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14/wt
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../wt &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=../wt at root' '
+	cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14/wt
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=../wt in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14/wt
+setup: cwd: $TRASH_DIRECTORY/14/sub/sub
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
+	GIT_DIR=../../.git test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=../wt(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14/wt
+setup: cwd: $TRASH_DIRECTORY/14/sub/sub
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../wt &&
+	GIT_DIR=../../.git test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=../wt(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14/wt
+setup: cwd: $TRASH_DIRECTORY/14/sub/sub
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../wt &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=../wt in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14/wt
+setup: cwd: $TRASH_DIRECTORY/14/sub/sub
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=../.. at root' '
+	cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 14/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR=.git test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=../..(rel) at root' '
+	cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 14/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../../ &&
+	GIT_DIR=.git test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=../..(rel) at root' '
+	cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 14/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../../ &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=../.. at root' '
+	cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 14/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=../.. in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 14/sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR=../../.git test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=../..(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 14/sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../.. &&
+	GIT_DIR=../../.git test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=../..(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 14/sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../.. &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=../.. in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 14/sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14/sub/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 18/34] t1510: setup case #15
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (16 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 17/34] t1510: setup case #14 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 19/34] t1510: setup case #16 Nguyễn Thái Ngọc Duy
                   ` (22 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |  268 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 268 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 0cd00ea..47c8814 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -1950,4 +1950,272 @@ EOF
 	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14/sub/sub
 '
 
+#
+# case #15
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is set
+#  - core.worktree is set
+#  - .git is a file
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+# #7 except that git_dir is set by .git file
+
+test_expect_success '#15: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 15 15/sub 15/sub/sub 15.wt 15.wt/sub 15/wt 15/wt/sub &&
+	cd 15 &&
+	git init &&
+	git config core.worktree non-existent &&
+	mv .git ../15.git &&
+	echo gitdir: ../15.git >.git &&
+	cd ..
+'
+
+test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
+	cat >15/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY/15
+setup: cwd: $TRASH_DIRECTORY/15
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/15" test_repo 15
+'
+
+test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
+	cat >15/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY/15
+setup: cwd: $TRASH_DIRECTORY/15
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=. test_repo 15
+'
+
+test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=root at root' '
+	cat >15/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY/15
+setup: cwd: $TRASH_DIRECTORY/15
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/15/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/15" test_repo 15
+'
+
+test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
+	cat >15/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY/15
+setup: cwd: $TRASH_DIRECTORY/15
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/15/.git" GIT_WORK_TREE=. test_repo 15
+'
+
+test_expect_failure '#15: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
+	cat >15/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY/15
+setup: cwd: $TRASH_DIRECTORY/15
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY/15" test_repo 15/sub/sub
+'
+
+test_expect_failure '#15: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
+	cat >15/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY/15
+setup: cwd: $TRASH_DIRECTORY/15
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../.. test_repo 15/sub/sub
+'
+
+test_expect_failure '#15: GIT_DIR, GIT_WORKTREE=root in subdir' '
+	cat >15/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY/15
+setup: cwd: $TRASH_DIRECTORY/15
+setup: prefix: sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/15/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/15" test_repo 15/sub
+'
+
+test_expect_failure '#15: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
+	cat >15/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY/15
+setup: cwd: $TRASH_DIRECTORY/15
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/15/.git" GIT_WORK_TREE=../.. test_repo 15/sub/sub
+'
+
+test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
+	cat >15/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY/15/wt
+setup: cwd: $TRASH_DIRECTORY/15
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/15/wt" test_repo 15
+'
+
+test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
+	cat >15/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY/15/wt
+setup: cwd: $TRASH_DIRECTORY/15
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=wt test_repo 15
+'
+
+test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
+	cat >15/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY/15/wt
+setup: cwd: $TRASH_DIRECTORY/15
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/15/.git" GIT_WORK_TREE=wt test_repo 15
+'
+
+test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=wt at root' '
+	cat >15/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY/15/wt
+setup: cwd: $TRASH_DIRECTORY/15
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/15/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/15/wt" test_repo 15
+'
+
+test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
+	cat >15/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY/15/wt
+setup: cwd: $TRASH_DIRECTORY/15/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY/15/wt" test_repo 15/sub/sub
+'
+
+test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >15/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY/15/wt
+setup: cwd: $TRASH_DIRECTORY/15/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../../wt test_repo 15/sub/sub
+'
+
+test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >15/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY/15/wt
+setup: cwd: $TRASH_DIRECTORY/15/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/15/.git" GIT_WORK_TREE=../../wt test_repo 15/sub/sub
+'
+
+test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
+	cat >15/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY/15/wt
+setup: cwd: $TRASH_DIRECTORY/15/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/15/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/15/wt" test_repo 15/sub/sub
+'
+
+test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
+	cat >15/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 15/
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 15
+'
+
+test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
+	cat >15/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 15/
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=.. test_repo 15
+'
+
+test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
+	cat >15/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 15/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/15/.git" GIT_WORK_TREE=.. test_repo 15
+'
+
+test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=.. at root' '
+	cat >15/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 15/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/15/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 15
+'
+
+test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
+	cat >15/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 15/sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 15/sub/sub
+'
+
+test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
+	cat >15/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 15/sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../../.. test_repo 15/sub/sub
+'
+
+test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
+	cat >15/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 15/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/15/.git" GIT_WORK_TREE=../../../ test_repo 15/sub/sub
+'
+
+test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
+	cat >15/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/15.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 15/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/15/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 15/sub/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 19/34] t1510: setup case #16
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (17 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 18/34] t1510: setup case #15 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 20/34] t1510: setup case #17 Nguyễn Thái Ngọc Duy
                   ` (21 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |  135 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 135 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 47c8814..a856d7c 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -2218,4 +2218,139 @@ EOF
 	GIT_DIR="$TRASH_DIRECTORY/15/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 15/sub/sub
 '
 
+#
+# case #16.1
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is not set
+#  - core.worktree is not set
+#  - .git is a directory
+#  - cwd is inside .git
+#
+# Output:
+#
+#  - no worktree
+#  - cwd is unchanged
+#  - prefix is NULL
+#  - git_dir is set
+#  - cwd can't be outside worktree
+
+test_expect_success '#16.1: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 16 16/sub &&
+	cd 16 &&
+	git init &&
+	mkdir .git/wt .git/wt/sub &&
+	cd ..
+'
+
+test_expect_success '#16.1: at .git' '
+	cat >16/.git/expected <<EOF &&
+setup: git_dir: .
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/16/.git
+setup: prefix: (null)
+EOF
+	test_repo 16/.git
+'
+
+test_expect_success '#16.1: in .git/wt' '
+	cat >16/.git/wt/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/16/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/16/.git/wt
+setup: prefix: (null)
+EOF
+	test_repo 16/.git/wt
+'
+
+test_expect_success '#16.1: in .git/wt/sub' '
+	cat >16/.git/wt/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/16/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/16/.git/wt/sub
+setup: prefix: (null)
+EOF
+	test_repo 16/.git/wt/sub
+'
+
+#
+# case #16.2
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is not set
+#  - core.worktree is not set
+#  - .git is a directory
+#  - core.bare is set
+#
+# Output:
+#
+#  - no worktree
+#  - cwd is unchanged
+#  - prefix is NULL
+#  - git_dir is set
+#  - cwd can't be outside worktree
+
+test_expect_success '#16.2: setup' '
+	git config --file="$TRASH_DIRECTORY/16/.git/config" core.bare true
+'
+
+test_expect_success '#16.2: at .git' '
+	cat >16/.git/expected <<EOF &&
+setup: git_dir: .
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/16/.git
+setup: prefix: (null)
+EOF
+	test_repo 16/.git
+'
+
+test_expect_success '#16.2: in .git/wt' '
+	cat >16/.git/wt/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/16/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/16/.git/wt
+setup: prefix: (null)
+EOF
+	test_repo 16/.git/wt
+'
+
+test_expect_success '#16.2: in .git/wt/sub' '
+	cat >16/.git/wt/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/16/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/16/.git/wt/sub
+setup: prefix: (null)
+EOF
+	test_repo 16/.git/wt/sub
+'
+
+test_expect_success '#16.2: at root' '
+	cat >16/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/16
+setup: prefix: (null)
+EOF
+	test_repo 16
+'
+
+test_expect_failure '#16.2: in subdir' '
+	cat >16/sub/expected <<EOF &&
+setup: git_dir: ../.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/16/sub
+setup: prefix: (null)
+EOF
+	test_repo 16/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 20/34] t1510: setup case #17
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (18 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 19/34] t1510: setup case #16 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 21/34] t1510: setup case #18 Nguyễn Thái Ngọc Duy
                   ` (20 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |  128 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 128 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index a856d7c..b015f91 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -2353,4 +2353,132 @@ EOF
 	test_repo 16/sub
 '
 
+#
+# case #17.1
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is not set
+#  - core.worktree is not set
+#  - .git is a directory
+#  - cwd is inside .git
+#
+# Output:
+#
+# GIT_WORK_TREE is ignored -> #16.1 (with warnings perhaps)
+
+test_expect_success '#17.1: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 17 17/sub &&
+	cd 17 &&
+	git init &&
+	mkdir .git/wt .git/wt/sub &&
+	export GIT_WORK_TREE=non-existent &&
+	cd ..
+'
+
+test_expect_failure '#17.1: at .git' '
+	cat >17/.git/expected <<EOF &&
+setup: git_dir: .
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/17/.git
+setup: prefix: (null)
+EOF
+	test_repo 17/.git
+'
+
+test_expect_failure '#17.1: in .git/wt' '
+	cat >17/.git/wt/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/17/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/17/.git/wt
+setup: prefix: (null)
+EOF
+	test_repo 17/.git/wt
+'
+
+test_expect_failure '#17.1: in .git/wt/sub' '
+	cat >17/.git/wt/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/17/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/17/.git/wt/sub
+setup: prefix: (null)
+EOF
+	test_repo 17/.git/wt/sub
+'
+
+#
+# case #17.2
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is not set
+#  - core.worktree is not set
+#  - .git is a directory
+#  - core.bare is set
+#
+# Output:
+#
+# GIT_WORK_TREE is ignored -> #16.2 (with warnings perhaps)
+
+test_expect_success '#17.2: setup' '
+	git config --file="$TRASH_DIRECTORY/17/.git/config" core.bare true
+'
+
+test_expect_failure '#17.2: at .git' '
+	cat >17/.git/expected <<EOF &&
+setup: git_dir: .
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/17/.git
+setup: prefix: (null)
+EOF
+	test_repo 17/.git
+'
+
+test_expect_failure '#17.2: in .git/wt' '
+	cat >17/.git/wt/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/17/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/17/.git/wt
+setup: prefix: (null)
+EOF
+	test_repo 17/.git/wt
+'
+
+test_expect_failure '#17.2: in .git/wt/sub' '
+	cat >17/.git/wt/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/17/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/17/.git/wt/sub
+setup: prefix: (null)
+EOF
+	test_repo 17/.git/wt/sub
+'
+
+test_expect_failure '#17.2: at root' '
+	cat >17/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/17
+setup: prefix: (null)
+EOF
+	test_repo 17
+'
+
+test_expect_failure '#17.2: in subdir' '
+	cat >17/sub/expected <<EOF &&
+setup: git_dir: ../.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/17/sub
+setup: prefix: (null)
+EOF
+	test_repo 17/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 21/34] t1510: setup case #18
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (19 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 20/34] t1510: setup case #17 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 22/34] t1510: setup case #19 Nguyễn Thái Ngọc Duy
                   ` (19 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   71 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index b015f91..0d32a6d 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -2481,4 +2481,75 @@ EOF
 	test_repo 17/sub
 '
 
+#
+# case #18
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is set
+#  - core.worktree is not set
+#  - .git is a directory
+#  - core.bare is set
+#
+# Output:
+#
+#  - no worktree (rule #8)
+#  - cwd is unchanged
+#  - prefix is NULL
+#  - git_dir is set to $GIT_DIR
+#  - cwd can't be outside worktree
+
+test_expect_success '#18: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 18 18/sub &&
+	cd 18 &&
+	git init &&
+	mkdir .git/wt .git/wt/sub &&
+	git config core.bare true &&
+	cd ..
+'
+
+test_expect_success '#18: (rel) at root' '
+	cat >18/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/18
+setup: prefix: (null)
+EOF
+	 GIT_DIR=.git test_repo 18
+'
+
+test_expect_success '#18: at root' '
+	cat >18/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/18/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/18
+setup: prefix: (null)
+EOF
+	 GIT_DIR="$TRASH_DIRECTORY/18/.git" test_repo 18
+'
+
+test_expect_success '#18: (rel) in subdir' '
+	cat >18/sub/expected <<EOF &&
+setup: git_dir: ../.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/18/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../.git test_repo 18/sub
+'
+
+test_expect_success '#18: in subdir' '
+	cat >18/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/18/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/18/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/18/.git" test_repo 18/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 22/34] t1510: setup case #19
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (20 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 21/34] t1510: setup case #18 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 23/34] t1510: setup case #20 Nguyễn Thái Ngọc Duy
                   ` (18 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |  266 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 266 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 0d32a6d..802bd5f 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -2552,4 +2552,270 @@ EOF
 	GIT_DIR="$TRASH_DIRECTORY/18/.git" test_repo 18/sub
 '
 
+#
+# case #19
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is set
+#  - .git is a directory
+#  - core.worktree is not set
+#  - core.bare is set
+#
+# Output:
+#
+# bare repo is overridden by GIT_WORK_TREE -> #3
+
+test_expect_success '#19: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 19 19/sub 19/sub/sub 19.wt 19.wt/sub 19/wt 19/wt/sub &&
+	cd 19 &&
+	git init &&
+	git config core.bare true &&
+	cd ..
+'
+
+test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
+	cat >19/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/19
+setup: cwd: $TRASH_DIRECTORY/19
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/19" test_repo 19
+'
+
+test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
+	cat >19/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/19
+setup: cwd: $TRASH_DIRECTORY/19
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=. test_repo 19
+'
+
+test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=root at root' '
+	cat >19/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY/19
+setup: cwd: $TRASH_DIRECTORY/19
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/19/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/19" test_repo 19
+'
+
+test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
+	cat >19/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY/19
+setup: cwd: $TRASH_DIRECTORY/19
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/19/.git" GIT_WORK_TREE=. test_repo 19
+'
+
+test_expect_success '#19: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
+	cat >19/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY/19
+setup: cwd: $TRASH_DIRECTORY/19
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY/19" test_repo 19/sub/sub
+'
+
+test_expect_success '#19: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
+	cat >19/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY/19
+setup: cwd: $TRASH_DIRECTORY/19
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../.. test_repo 19/sub/sub
+'
+
+test_expect_success '#19: GIT_DIR, GIT_WORKTREE=root in subdir' '
+	cat >19/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY/19
+setup: cwd: $TRASH_DIRECTORY/19
+setup: prefix: sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/19/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/19" test_repo 19/sub
+'
+
+test_expect_success '#19: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
+	cat >19/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY/19
+setup: cwd: $TRASH_DIRECTORY/19
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/19/.git" GIT_WORK_TREE=../.. test_repo 19/sub/sub
+'
+
+test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
+	cat >19/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/19/wt
+setup: cwd: $TRASH_DIRECTORY/19
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/19/wt" test_repo 19
+'
+
+test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
+	cat >19/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/19/wt
+setup: cwd: $TRASH_DIRECTORY/19
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=wt test_repo 19
+'
+
+test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
+	cat >19/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY/19/wt
+setup: cwd: $TRASH_DIRECTORY/19
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/19/.git" GIT_WORK_TREE=wt test_repo 19
+'
+
+test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt at root' '
+	cat >19/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY/19/wt
+setup: cwd: $TRASH_DIRECTORY/19
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/19/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/19/wt" test_repo 19
+'
+
+test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
+	cat >19/sub/sub/expected <<EOF &&
+setup: git_dir: ../../.git
+setup: worktree: $TRASH_DIRECTORY/19/wt
+setup: cwd: $TRASH_DIRECTORY/19/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY/19/wt" test_repo 19/sub/sub
+'
+
+test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >19/sub/sub/expected <<EOF &&
+setup: git_dir: ../../.git
+setup: worktree: $TRASH_DIRECTORY/19/wt
+setup: cwd: $TRASH_DIRECTORY/19/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../../wt test_repo 19/sub/sub
+'
+
+test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >19/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY/19/wt
+setup: cwd: $TRASH_DIRECTORY/19/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/19/.git" GIT_WORK_TREE=../../wt test_repo 19/sub/sub
+'
+
+test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
+	cat >19/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY/19/wt
+setup: cwd: $TRASH_DIRECTORY/19/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/19/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/19/wt" test_repo 19/sub/sub
+'
+
+test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
+	cat >19/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 19/
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 19
+'
+
+test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
+	cat >19/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 19/
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=.. test_repo 19
+'
+
+test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
+	cat >19/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 19/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/19/.git" GIT_WORK_TREE=.. test_repo 19
+'
+
+test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=.. at root' '
+	cat >19/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 19/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/19/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 19
+'
+
+test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
+	cat >19/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 19/sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 19/sub/sub
+'
+
+test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
+	cat >19/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 19/sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../../.. test_repo 19/sub/sub
+'
+
+test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
+	cat >19/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 19/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/19/.git" GIT_WORK_TREE=../../../ test_repo 19/sub/sub
+'
+
+test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
+	cat >19/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/19/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 19/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/19/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 19/sub/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 23/34] t1510: setup case #20
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (21 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 22/34] t1510: setup case #19 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 24/34] t1510: setup case #21 Nguyễn Thái Ngọc Duy
                   ` (17 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |  128 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 128 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 802bd5f..dc82736 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -2818,4 +2818,132 @@ EOF
 	GIT_DIR="$TRASH_DIRECTORY/19/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 19/sub/sub
 '
 
+#
+# case #20.1
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is not set
+#  - core.worktree is set
+#  - .git is a directory
+#  - cwd is inside .git
+#
+# Output:
+#
+# core.worktree is ignored -> #16.1
+
+test_expect_success '#20.1: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 20 20/sub &&
+	cd 20 &&
+	git init &&
+	git config core.worktree non-existent &&
+	mkdir .git/wt .git/wt/sub &&
+	cd ..
+'
+
+test_expect_failure '#20.1: at .git' '
+	cat >20/.git/expected <<EOF &&
+setup: git_dir: .
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/20/.git
+setup: prefix: (null)
+EOF
+	test_repo 20/.git
+'
+
+test_expect_failure '#20.1: in .git/wt' '
+	cat >20/.git/wt/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/20/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/20/.git/wt
+setup: prefix: (null)
+EOF
+	test_repo 20/.git/wt
+'
+
+test_expect_failure '#20.1: in .git/wt/sub' '
+	cat >20/.git/wt/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/20/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/20/.git/wt/sub
+setup: prefix: (null)
+EOF
+	test_repo 20/.git/wt/sub
+'
+
+#
+# case #20.2
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is not set
+#  - core.worktree is set
+#  - .git is a directory
+#  - core.bare is set
+#
+# Output:
+#
+# core.worktree is ignored -> #16.2
+
+test_expect_success '#20.2: setup' '
+	git config --file="$TRASH_DIRECTORY/20/.git/config" core.bare true
+'
+
+test_expect_success '#20.2: at .git' '
+	cat >20/.git/expected <<EOF &&
+setup: git_dir: .
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/20/.git
+setup: prefix: (null)
+EOF
+	test_repo 20/.git
+'
+
+test_expect_success '#20.2: in .git/wt' '
+	cat >20/.git/wt/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/20/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/20/.git/wt
+setup: prefix: (null)
+EOF
+	test_repo 20/.git/wt
+'
+
+test_expect_success '#20.2: in .git/wt/sub' '
+	cat >20/.git/wt/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/20/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/20/.git/wt/sub
+setup: prefix: (null)
+EOF
+	test_repo 20/.git/wt/sub
+'
+
+test_expect_success '#20.2: at root' '
+	cat >20/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/20
+setup: prefix: (null)
+EOF
+	test_repo 20
+'
+
+test_expect_failure '#20.2: in subdir' '
+	cat >20/sub/expected <<EOF &&
+setup: git_dir: ../.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/20/sub
+setup: prefix: (null)
+EOF
+	test_repo 20/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 24/34] t1510: setup case #21
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (22 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 23/34] t1510: setup case #20 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 25/34] t1510: setup case #22 Nguyễn Thái Ngọc Duy
                   ` (16 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |  129 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 129 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index dc82736..8e3fffb 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -2946,4 +2946,133 @@ EOF
 	test_repo 20/sub
 '
 
+#
+# case #21.1
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is not set
+#  - core.worktree is set
+#  - .git is a directory
+#  - cwd is inside .git
+#
+# Output:
+#
+# GIT_WORK_TREE/core.worktree are ignored -> #20.1
+
+test_expect_success '#21.1: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 21 21/sub &&
+	cd 21 &&
+	git init &&
+	git config core.worktree non-existent &&
+	export GIT_WORK_TREE=non-existent-too &&
+	mkdir .git/wt .git/wt/sub &&
+	cd ..
+'
+
+test_expect_failure '#21.1: at .git' '
+	cat >21/.git/expected <<EOF &&
+setup: git_dir: .
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/21/.git
+setup: prefix: (null)
+EOF
+	test_repo 21/.git
+'
+
+test_expect_failure '#21.1: in .git/wt' '
+	cat >21/.git/wt/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/21/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/21/.git/wt
+setup: prefix: (null)
+EOF
+	test_repo 21/.git/wt
+'
+
+test_expect_failure '#21.1: in .git/wt/sub' '
+	cat >21/.git/wt/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/21/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/21/.git/wt/sub
+setup: prefix: (null)
+EOF
+	test_repo 21/.git/wt/sub
+'
+
+#
+# case #21.2
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is not set
+#  - core.worktree is set
+#  - .git is a directory
+#  - core.bare is set
+#
+# Output:
+#
+# GIT_WORK_TREE/core.worktree are ignored -> #20.2
+
+test_expect_success '#21.2: setup' '
+	git config --file="$TRASH_DIRECTORY/21/.git/config" core.bare true
+'
+
+test_expect_failure '#21.2: at .git' '
+	cat >21/.git/expected <<EOF &&
+setup: git_dir: .
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/21/.git
+setup: prefix: (null)
+EOF
+	test_repo 21/.git
+'
+
+test_expect_failure '#21.2: in .git/wt' '
+	cat >21/.git/wt/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/21/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/21/.git/wt
+setup: prefix: (null)
+EOF
+	test_repo 21/.git/wt
+'
+
+test_expect_failure '#21.2: in .git/wt/sub' '
+	cat >21/.git/wt/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/21/.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/21/.git/wt/sub
+setup: prefix: (null)
+EOF
+	test_repo 21/.git/wt/sub
+'
+
+test_expect_failure '#21.2: at root' '
+	cat >21/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/21
+setup: prefix: (null)
+EOF
+	test_repo 21
+'
+
+test_expect_failure '#21.2: in subdir' '
+	cat >21/sub/expected <<EOF &&
+setup: git_dir: ../.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/21/sub
+setup: prefix: (null)
+EOF
+	test_repo 21/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 25/34] t1510: setup case #22
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (23 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 24/34] t1510: setup case #21 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 26/34] t1510: setup case #23 Nguyễn Thái Ngọc Duy
                   ` (15 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |  333 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 333 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 8e3fffb..5d66c34 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -3075,4 +3075,337 @@ EOF
 	test_repo 21/sub
 '
 
+#
+# case #22.1
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is set
+#  - core.worktree is set
+#  - .git is a directory
+#  - cwd is inside .git
+#
+# Output:
+#
+# bare attribute is ignored
+#
+#  - worktree is at core.worktree
+#  - cwd is at worktree root
+#  - prefix is calculated
+#  - git_dir is at $GIT_DIR
+#  - cwd can be outside worktree
+
+test_expect_success '#22.1: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 22 &&
+	cd 22 &&
+	git init &&
+	mkdir .git/sub .git/wt .git/wt/sub &&
+	cd ..
+'
+
+test_expect_success '#22.1: GIT_DIR(rel), core.worktree=. at .git' '
+	cat >22/.git/expected <<EOF &&
+setup: git_dir: .
+setup: worktree: $TRASH_DIRECTORY/22/.git
+setup: cwd: $TRASH_DIRECTORY/22/.git
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22/.git" &&
+	GIT_DIR=. test_repo 22/.git
+'
+
+test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.(rel) at .git' '
+	cat >22/.git/expected <<EOF &&
+setup: git_dir: .
+setup: worktree: $TRASH_DIRECTORY/22/.git
+setup: cwd: $TRASH_DIRECTORY/22/.git
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree . &&
+	GIT_DIR=. test_repo 22/.git
+'
+
+test_expect_success '#22.1: GIT_DIR, core.worktree=. at .git' '
+	cat >22/.git/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22/.git
+setup: cwd: $TRASH_DIRECTORY/22/.git
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22/.git" &&
+	GIT_DIR="$TRASH_DIRECTORY/22/.git" test_repo 22/.git
+'
+
+test_expect_success '#22.1: GIT_DIR, core.worktree=.(rel) at root' '
+	cat >22/.git/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22/.git
+setup: cwd: $TRASH_DIRECTORY/22/.git
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree . &&
+	GIT_DIR="$TRASH_DIRECTORY/22/.git" test_repo 22/.git
+'
+
+test_expect_failure '#22.1: GIT_DIR(rel), core.worktree=. in .git/sub' '
+	cat >22/.git/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22/.git
+setup: cwd: $TRASH_DIRECTORY/22/.git
+setup: prefix: sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22/.git" &&
+	GIT_DIR=.. test_repo 22/.git/sub
+'
+
+test_expect_failure '#22.1: GIT_DIR(rel), core.worktree=.(rel) in .git/sub' '
+	cat >22/.git/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22/.git
+setup: cwd: $TRASH_DIRECTORY/22/.git
+setup: prefix: sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree . &&
+	GIT_DIR=.. test_repo 22/.git/sub/
+'
+
+test_expect_success '#22.1: GIT_DIR, core.worktree=. in .git/sub' '
+	cat >22/.git/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22/.git
+setup: cwd: $TRASH_DIRECTORY/22/.git
+setup: prefix: sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22/.git" &&
+	GIT_DIR="$TRASH_DIRECTORY/22/.git" test_repo 22/.git/sub
+'
+
+test_expect_success '#22.1: GIT_DIR, core.worktree=.(rel) in .git/sub' '
+	cat >22/.git/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22/.git
+setup: cwd: $TRASH_DIRECTORY/22/.git
+setup: prefix: sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree . &&
+	GIT_DIR="$TRASH_DIRECTORY/22/.git" test_repo 22/.git/sub
+'
+
+test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt at .git' '
+	cat >22/.git/expected <<EOF &&
+setup: git_dir: .
+setup: worktree: $TRASH_DIRECTORY/22/.git/wt
+setup: cwd: $TRASH_DIRECTORY/22/.git
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22/.git/wt" &&
+	GIT_DIR=. test_repo 22/.git
+'
+
+test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt(rel) at .git' '
+	cat >22/.git/expected <<EOF &&
+setup: git_dir: .
+setup: worktree: $TRASH_DIRECTORY/22/.git/wt
+setup: cwd: $TRASH_DIRECTORY/22/.git
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree wt &&
+	GIT_DIR=. test_repo 22/.git
+'
+
+test_expect_success '#22.1: GIT_DIR, core.worktree=wt(rel) at .git' '
+	cat >22/.git/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22/.git/wt
+setup: cwd: $TRASH_DIRECTORY/22/.git
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree wt &&
+	GIT_DIR="$TRASH_DIRECTORY/22/.git" test_repo 22/.git
+'
+
+test_expect_success '#22.1: GIT_DIR, core.worktree=wt at .git' '
+	cat >22/.git/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22/.git/wt
+setup: cwd: $TRASH_DIRECTORY/22/.git
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22/.git/wt" &&
+	GIT_DIR="$TRASH_DIRECTORY/22/.git" test_repo 22/.git
+'
+
+test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt in .git/sub' '
+	cat >22/.git/sub/expected <<EOF &&
+setup: git_dir: ..
+setup: worktree: $TRASH_DIRECTORY/22/.git/wt
+setup: cwd: $TRASH_DIRECTORY/22/.git/sub
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22/.git/wt" &&
+	GIT_DIR=.. test_repo 22/.git/sub
+'
+
+test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt(rel) in .git/sub' '
+	cat >22/.git/sub/expected <<EOF &&
+setup: git_dir: ..
+setup: worktree: $TRASH_DIRECTORY/22/.git/wt
+setup: cwd: $TRASH_DIRECTORY/22/.git/sub
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree wt &&
+	GIT_DIR=.. test_repo 22/.git/sub
+'
+
+test_expect_success '#22.1: GIT_DIR, core.worktree=wt(rel) in .git/sub' '
+	cat >22/.git/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22/.git/wt
+setup: cwd: $TRASH_DIRECTORY/22/.git/sub
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree wt &&
+	GIT_DIR="$TRASH_DIRECTORY/22/.git" test_repo 22/.git/sub
+'
+
+test_expect_success '#22.1: GIT_DIR, core.worktree=wt in .git/sub' '
+	cat >22/.git/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22/.git/wt
+setup: cwd: $TRASH_DIRECTORY/22/.git/sub
+setup: prefix: (null)
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22/.git/wt" &&
+	GIT_DIR="$TRASH_DIRECTORY/22/.git" test_repo 22/.git/sub
+'
+
+test_expect_failure '#22.1: GIT_DIR(rel), core.worktree=.. at .git' '
+	cat >22/.git/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22
+setup: cwd: $TRASH_DIRECTORY/22
+setup: prefix: .git/
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22" &&
+	GIT_DIR=. test_repo 22/.git
+'
+
+test_expect_failure '#22.1: GIT_DIR(rel), core.worktree=..(rel) at .git' '
+	cat >22/.git/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22
+setup: cwd: $TRASH_DIRECTORY/22
+setup: prefix: .git/
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree .. &&
+	GIT_DIR=. test_repo 22/.git
+'
+
+test_expect_success '#22.1: GIT_DIR, core.worktree=..(rel) at .git' '
+	cat >22/.git/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22
+setup: cwd: $TRASH_DIRECTORY/22
+setup: prefix: .git/
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree .. &&
+	GIT_DIR="$TRASH_DIRECTORY/22/.git" test_repo 22/.git
+'
+
+test_expect_success '#22.1: GIT_DIR, core.worktree=.. at .git' '
+	cat >22/.git/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22
+setup: cwd: $TRASH_DIRECTORY/22
+setup: prefix: .git/
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22" &&
+	GIT_DIR="$TRASH_DIRECTORY/22/.git" test_repo 22/.git
+'
+
+test_expect_failure '#22.1: GIT_DIR(rel), core.worktree=.. in .git/sub' '
+	cat >22/.git/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22
+setup: cwd: $TRASH_DIRECTORY/22
+setup: prefix: .git/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22" &&
+	GIT_DIR=.. test_repo 22/.git/sub
+'
+
+test_expect_failure '#22.1: GIT_DIR(rel), core.worktree=..(rel) in .git/sub' '
+	cat >22/.git/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22
+setup: cwd: $TRASH_DIRECTORY/22
+setup: prefix: .git/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree .. &&
+	GIT_DIR=.. test_repo 22/.git/sub
+'
+
+test_expect_success '#22.1: GIT_DIR, core.worktree=..(rel) in .git/sub' '
+	cat >22/.git/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22
+setup: cwd: $TRASH_DIRECTORY/22
+setup: prefix: .git/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree .. &&
+	GIT_DIR="$TRASH_DIRECTORY/22/.git" test_repo 22/.git/sub
+'
+
+test_expect_success '#22.1: GIT_DIR, core.worktree=.. in .git/sub' '
+	cat >22/.git/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/22/.git
+setup: worktree: $TRASH_DIRECTORY/22
+setup: cwd: $TRASH_DIRECTORY/22
+setup: prefix: .git/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22" &&
+	GIT_DIR="$TRASH_DIRECTORY/22/.git" test_repo 22/.git/sub
+'
+
+#
+# case #22.2
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is set
+#  - core.worktree is set
+#  - .git is a directory
+#  - core.bare is set
+#
+# Output:
+#
+# core.worktree and core.bare conflict, won't fly.
+
+test_expect_success '#22.2: setup' '
+	git config --file="$TRASH_DIRECTORY/22/.git/config" core.bare true
+'
+
+test_expect_failure '#22.2: at .git' '
+	(
+	cd 22/.git &&
+	GIT_DIR=. test_must_fail git symbolic-ref HEAD 2>result &&
+	grep "core.bare and core.worktree do not make sense" result
+	)
+'
+
+test_expect_failure '#22.2: at root' '
+	(
+	cd 22 &&
+	GIT_DIR=.git test_must_fail git symbolic-ref HEAD 2>result &&
+	grep "core.bare and core.worktree do not make sense" result
+	)
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 26/34] t1510: setup case #23
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (24 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 25/34] t1510: setup case #22 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 27/34] t1510: setup case #24 Nguyễn Thái Ngọc Duy
                   ` (14 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |  267 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 267 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 5d66c34..30743d6 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -3408,4 +3408,271 @@ test_expect_failure '#22.2: at root' '
 	)
 '
 
+#
+# case #23
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is set
+#  - core.worktree is set
+#  - .git is a directory
+#  - core.bare is set
+#
+# Output:
+#
+# core.worktree is overridden by GIT_WORK_TREE -> #19
+
+test_expect_success '#23: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 23 23/sub 23/sub/sub 23.wt 23.wt/sub 23/wt 23/wt/sub &&
+	cd 23 &&
+	git init &&
+	git config core.bare true &&
+	git config core.worktree non-existent &&
+	cd ..
+'
+
+test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
+	cat >23/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/23
+setup: cwd: $TRASH_DIRECTORY/23
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/23" test_repo 23
+'
+
+test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
+	cat >23/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/23
+setup: cwd: $TRASH_DIRECTORY/23
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=. test_repo 23
+'
+
+test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=root at root' '
+	cat >23/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY/23
+setup: cwd: $TRASH_DIRECTORY/23
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/23/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/23" test_repo 23
+'
+
+test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
+	cat >23/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY/23
+setup: cwd: $TRASH_DIRECTORY/23
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/23/.git" GIT_WORK_TREE=. test_repo 23
+'
+
+test_expect_success '#23: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
+	cat >23/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY/23
+setup: cwd: $TRASH_DIRECTORY/23
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY/23" test_repo 23/sub/sub
+'
+
+test_expect_success '#23: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
+	cat >23/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY/23
+setup: cwd: $TRASH_DIRECTORY/23
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../.. test_repo 23/sub/sub
+'
+
+test_expect_success '#23: GIT_DIR, GIT_WORKTREE=root in subdir' '
+	cat >23/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY/23
+setup: cwd: $TRASH_DIRECTORY/23
+setup: prefix: sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/23/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/23" test_repo 23/sub
+'
+
+test_expect_success '#23: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
+	cat >23/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY/23
+setup: cwd: $TRASH_DIRECTORY/23
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/23/.git" GIT_WORK_TREE=../.. test_repo 23/sub/sub
+'
+
+test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
+	cat >23/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/23/wt
+setup: cwd: $TRASH_DIRECTORY/23
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/23/wt" test_repo 23
+'
+
+test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
+	cat >23/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/23/wt
+setup: cwd: $TRASH_DIRECTORY/23
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=wt test_repo 23
+'
+
+test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
+	cat >23/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY/23/wt
+setup: cwd: $TRASH_DIRECTORY/23
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/23/.git" GIT_WORK_TREE=wt test_repo 23
+'
+
+test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt at root' '
+	cat >23/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY/23/wt
+setup: cwd: $TRASH_DIRECTORY/23
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/23/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/23/wt" test_repo 23
+'
+
+test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
+	cat >23/sub/sub/expected <<EOF &&
+setup: git_dir: ../../.git
+setup: worktree: $TRASH_DIRECTORY/23/wt
+setup: cwd: $TRASH_DIRECTORY/23/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY/23/wt" test_repo 23/sub/sub
+'
+
+test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >23/sub/sub/expected <<EOF &&
+setup: git_dir: ../../.git
+setup: worktree: $TRASH_DIRECTORY/23/wt
+setup: cwd: $TRASH_DIRECTORY/23/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../../wt test_repo 23/sub/sub
+'
+
+test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >23/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY/23/wt
+setup: cwd: $TRASH_DIRECTORY/23/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/23/.git" GIT_WORK_TREE=../../wt test_repo 23/sub/sub
+'
+
+test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
+	cat >23/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY/23/wt
+setup: cwd: $TRASH_DIRECTORY/23/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/23/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/23/wt" test_repo 23/sub/sub
+'
+
+test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
+	cat >23/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 23/
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 23
+'
+
+test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
+	cat >23/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 23/
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=.. test_repo 23
+'
+
+test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
+	cat >23/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 23/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/23/.git" GIT_WORK_TREE=.. test_repo 23
+'
+
+test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=.. at root' '
+	cat >23/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 23/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/23/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 23
+'
+
+test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
+	cat >23/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 23/sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 23/sub/sub
+'
+
+test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
+	cat >23/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 23/sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../../.. test_repo 23/sub/sub
+'
+
+test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
+	cat >23/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 23/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/23/.git" GIT_WORK_TREE=../../../ test_repo 23/sub/sub
+'
+
+test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
+	cat >23/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/23/.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 23/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/23/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 23/sub/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 27/34] t1510: setup case #24
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (25 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 26/34] t1510: setup case #23 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 28/34] t1510: setup case #25 Nguyễn Thái Ngọc Duy
                   ` (13 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 30743d6..2660e72 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -3675,4 +3675,52 @@ EOF
 	GIT_DIR="$TRASH_DIRECTORY/23/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 23/sub/sub
 '
 
+#
+# case #24
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is not set
+#  - core.worktree is not set
+#  - .git is a file
+#  - core.bare is set
+#
+# Output:
+#
+# #16.2 except git_dir is set according to .git file
+
+test_expect_success '#24: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 24 24/sub &&
+	cd 24 &&
+	git init &&
+	git config core.bare true &&
+	mv .git ../24.git &&
+	echo gitdir: ../24.git >.git &&
+	cd ..
+'
+
+test_expect_success '#24: at root' '
+	cat >24/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/24.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/24
+setup: prefix: (null)
+EOF
+	test_repo 24
+'
+
+test_expect_success '#24: in subdir' '
+	cat >24/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/24.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/24/sub
+setup: prefix: (null)
+EOF
+	test_repo 24/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 28/34] t1510: setup case #25
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (26 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 27/34] t1510: setup case #24 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 29/34] t1510: setup case #26 Nguyễn Thái Ngọc Duy
                   ` (12 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 2660e72..e53ff90 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -3723,4 +3723,53 @@ EOF
 	test_repo 24/sub
 '
 
+#
+# case #25
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is not set
+#  - core.worktree is not set
+#  - .git is a file
+#  - core.bare is set
+#
+# Output:
+#
+# #17.2 except git_dir is set according to .git file
+
+test_expect_success '#25: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 25 25/sub &&
+	cd 25 &&
+	git init &&
+	git config core.bare true &&
+	export GIT_WORK_TREE=non-existent &&
+	mv .git ../25.git &&
+	echo gitdir: ../25.git >.git &&
+	cd ..
+'
+
+test_expect_failure '#25: at root' '
+	cat >25/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/25.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/25
+setup: prefix: (null)
+EOF
+	test_repo 25
+'
+
+test_expect_failure '#25: in subdir' '
+	cat >25/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/25.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/25/sub
+setup: prefix: (null)
+EOF
+	test_repo 25/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 29/34] t1510: setup case #26
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (27 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 28/34] t1510: setup case #25 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 30/34] t1510: setup case #27 Nguyễn Thái Ngọc Duy
                   ` (11 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   68 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index e53ff90..b1efec5 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -3772,4 +3772,72 @@ EOF
 	test_repo 25/sub
 '
 
+#
+# case #26
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is set
+#  - core.worktree is not set
+#  - .git is a file
+#  - core.bare is set
+#
+# Output:
+#
+# #18 except git_dir is set according to .git file
+
+test_expect_success '#26: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 26 26/sub &&
+	cd 26 &&
+	git init &&
+	git config core.bare true &&
+	mv .git ../26.git &&
+	echo gitdir: ../26.git >.git &&
+	cd ..
+'
+
+test_expect_failure '#26: (rel) at root' '
+	cat >26/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/26.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/26
+setup: prefix: (null)
+EOF
+	 GIT_DIR=.git test_repo 26
+'
+
+test_expect_failure '#26: at root' '
+	cat >26/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/26.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/26
+setup: prefix: (null)
+EOF
+	 GIT_DIR="$TRASH_DIRECTORY/26/.git" test_repo 26
+'
+
+test_expect_failure '#26: (rel) in subdir' '
+	cat >26/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/26.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/26/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../.git test_repo 26/sub
+'
+
+test_expect_failure '#26: in subdir' '
+	cat >26/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/26.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/26/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/26/.git" test_repo 26/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 30/34] t1510: setup case #27
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (28 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 29/34] t1510: setup case #26 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 31/34] t1510: setup case #28 Nguyễn Thái Ngọc Duy
                   ` (10 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |  268 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 268 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index b1efec5..b0ba763 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -3840,4 +3840,272 @@ EOF
 	GIT_DIR="$TRASH_DIRECTORY/26/.git" test_repo 26/sub
 '
 
+#
+# case #27
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is set
+#  - .git is a file
+#  - core.worktree is not set
+#  - core.bare is set
+#
+# Output:
+#
+# #19 except git_dir is set according to .git file
+
+test_expect_success '#27: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 27 27/sub 27/sub/sub 27.wt 27.wt/sub 27/wt 27/wt/sub &&
+	cd 27 &&
+	git init &&
+	git config core.bare true &&
+	mv .git ../27.git &&
+	echo gitdir: ../27.git >.git &&
+	cd ..
+'
+
+test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
+	cat >27/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY/27
+setup: cwd: $TRASH_DIRECTORY/27
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/27" test_repo 27
+'
+
+test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
+	cat >27/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY/27
+setup: cwd: $TRASH_DIRECTORY/27
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=. test_repo 27
+'
+
+test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=root at root' '
+	cat >27/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY/27
+setup: cwd: $TRASH_DIRECTORY/27
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/27/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/27" test_repo 27
+'
+
+test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
+	cat >27/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY/27
+setup: cwd: $TRASH_DIRECTORY/27
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/27/.git" GIT_WORK_TREE=. test_repo 27
+'
+
+test_expect_failure '#27: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
+	cat >27/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY/27
+setup: cwd: $TRASH_DIRECTORY/27
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY/27" test_repo 27/sub/sub
+'
+
+test_expect_failure '#27: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
+	cat >27/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY/27
+setup: cwd: $TRASH_DIRECTORY/27
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../.. test_repo 27/sub/sub
+'
+
+test_expect_failure '#27: GIT_DIR, GIT_WORKTREE=root in subdir' '
+	cat >27/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY/27
+setup: cwd: $TRASH_DIRECTORY/27
+setup: prefix: sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/27/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/27" test_repo 27/sub
+'
+
+test_expect_failure '#27: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
+	cat >27/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY/27
+setup: cwd: $TRASH_DIRECTORY/27
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/27/.git" GIT_WORK_TREE=../.. test_repo 27/sub/sub
+'
+
+test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
+	cat >27/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY/27/wt
+setup: cwd: $TRASH_DIRECTORY/27
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/27/wt" test_repo 27
+'
+
+test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
+	cat >27/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY/27/wt
+setup: cwd: $TRASH_DIRECTORY/27
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=wt test_repo 27
+'
+
+test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
+	cat >27/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY/27/wt
+setup: cwd: $TRASH_DIRECTORY/27
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/27/.git" GIT_WORK_TREE=wt test_repo 27
+'
+
+test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=wt at root' '
+	cat >27/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY/27/wt
+setup: cwd: $TRASH_DIRECTORY/27
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/27/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/27/wt" test_repo 27
+'
+
+test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
+	cat >27/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY/27/wt
+setup: cwd: $TRASH_DIRECTORY/27/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY/27/wt" test_repo 27/sub/sub
+'
+
+test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >27/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY/27/wt
+setup: cwd: $TRASH_DIRECTORY/27/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../../wt test_repo 27/sub/sub
+'
+
+test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >27/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY/27/wt
+setup: cwd: $TRASH_DIRECTORY/27/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/27/.git" GIT_WORK_TREE=../../wt test_repo 27/sub/sub
+'
+
+test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
+	cat >27/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY/27/wt
+setup: cwd: $TRASH_DIRECTORY/27/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/27/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/27/wt" test_repo 27/sub/sub
+'
+
+test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
+	cat >27/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 27/
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 27
+'
+
+test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
+	cat >27/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 27/
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=.. test_repo 27
+'
+
+test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
+	cat >27/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 27/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/27/.git" GIT_WORK_TREE=.. test_repo 27
+'
+
+test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=.. at root' '
+	cat >27/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 27/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/27/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 27
+'
+
+test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
+	cat >27/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 27/sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 27/sub/sub
+'
+
+test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
+	cat >27/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 27/sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../../.. test_repo 27/sub/sub
+'
+
+test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
+	cat >27/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 27/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/27/.git" GIT_WORK_TREE=../../../ test_repo 27/sub/sub
+'
+
+test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
+	cat >27/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/27.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 27/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/27/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 27/sub/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 31/34] t1510: setup case #28
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (29 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 30/34] t1510: setup case #27 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 32/34] t1510: setup case #29 Nguyễn Thái Ngọc Duy
                   ` (9 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index b0ba763..9221cd3 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -4108,4 +4108,53 @@ EOF
 	GIT_DIR="$TRASH_DIRECTORY/27/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 27/sub/sub
 '
 
+#
+# case #28
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is not set
+#  - core.worktree is set
+#  - .git is a file
+#  - core.bare is set
+#
+# Output:
+#
+# core.worktree is ignored -> #24
+
+test_expect_success '#28: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 28 28/sub &&
+	cd 28 &&
+	git init &&
+	git config core.bare true &&
+	git config core.worktree non-existent &&
+	mv .git ../28.git &&
+	echo gitdir: ../28.git >.git &&
+	cd ..
+'
+
+test_expect_success '#28: at root' '
+	cat >28/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/28.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/28
+setup: prefix: (null)
+EOF
+	test_repo 28
+'
+
+test_expect_success '#28: in subdir' '
+	cat >28/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/28.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/28/sub
+setup: prefix: (null)
+EOF
+	test_repo 28/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 32/34] t1510: setup case #29
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (30 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 31/34] t1510: setup case #28 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 33/34] t1510: setup case #30 Nguyễn Thái Ngọc Duy
                   ` (8 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 9221cd3..201761f 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -4157,4 +4157,53 @@ EOF
 	test_repo 28/sub
 '
 
+#
+# case #29
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is not set
+#  - core.worktree is set
+#  - .git is a file
+#  - core.bare is set
+#
+# Output:
+#
+# GIT_WORK_TREE/core.worktree are ignored -> #28
+
+test_expect_success '#29: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 29 29/sub &&
+	cd 29 &&
+	git init &&
+	git config core.bare true &&
+	export GIT_WORK_TREE=non-existent &&
+	mv .git ../29.git &&
+	echo gitdir: ../29.git >.git &&
+	cd ..
+'
+
+test_expect_failure '#29: at root' '
+	cat >29/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/29.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/29
+setup: prefix: (null)
+EOF
+	test_repo 29
+'
+
+test_expect_failure '#29: in subdir' '
+	cat >29/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/29.git
+setup: worktree: (null)
+setup: cwd: $TRASH_DIRECTORY/29/sub
+setup: prefix: (null)
+EOF
+	test_repo 29/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 33/34] t1510: setup case #30
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (31 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 32/34] t1510: setup case #29 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:49 ` [PATCH 34/34] t1510: setup case #31 Nguyễn Thái Ngọc Duy
                   ` (7 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 201761f..b095e24 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -4206,4 +4206,41 @@ EOF
 	test_repo 29/sub
 '
 
+#
+# case #30
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is set
+#  - core.worktree is set
+#  - .git is a file
+#  - core.bare is set
+#
+# Output:
+#
+# core.worktree and core.bare conflict, won't fly.
+
+test_expect_success '#30: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 30 &&
+	cd 30 &&
+	git init &&
+	git config core.bare true &&
+	git config core.worktree non-existent &&
+	mv .git ../30.git &&
+	echo gitdir: ../30.git >.git &&
+	cd ..
+'
+
+test_expect_failure '#30: at root' '
+	(
+	cd 30 &&
+	GIT_DIR=.git test_must_fail git symbolic-ref HEAD 2>result &&
+	grep "core.bare and core.worktree do not make sense" result
+	)
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 34/34] t1510: setup case #31
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (32 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 33/34] t1510: setup case #30 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:49 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:58 ` [PATCH 1/7] setup: support setting GIT_DIR=.git file Nguyễn Thái Ngọc Duy
                   ` (6 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:49 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t1510-repo-setup.sh |  269 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 269 insertions(+), 0 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index b095e24..9d24a0f 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -4243,4 +4243,273 @@ test_expect_failure '#30: at root' '
 	)
 '
 
+#
+# case #31
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is set
+#  - core.worktree is set
+#  - .git is a file
+#  - core.bare is set
+#
+# Output:
+#
+# #23 except git_dir is set according to .git file
+
+test_expect_success '#31: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 31 31/sub 31/sub/sub 31.wt 31.wt/sub 31/wt 31/wt/sub &&
+	cd 31 &&
+	git init &&
+	git config core.bare true &&
+	git config core.worktree non-existent &&
+	mv .git ../31.git &&
+	echo gitdir: ../31.git >.git &&
+	cd ..
+'
+
+test_expect_failure '#31: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
+	cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/31" test_repo 31
+'
+
+test_expect_failure '#31: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
+	cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=. test_repo 31
+'
+
+test_expect_failure '#31: GIT_DIR, GIT_WORK_TREE=root at root' '
+	cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/31/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/31" test_repo 31
+'
+
+test_expect_failure '#31: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
+	cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/31/.git" GIT_WORK_TREE=. test_repo 31
+'
+
+test_expect_failure '#31: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
+	cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY/31" test_repo 31/sub/sub
+'
+
+test_expect_failure '#31: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
+	cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../.. test_repo 31/sub/sub
+'
+
+test_expect_failure '#31: GIT_DIR, GIT_WORKTREE=root in subdir' '
+	cat >31/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/31/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/31" test_repo 31/sub
+'
+
+test_expect_failure '#31: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
+	cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/31/.git" GIT_WORK_TREE=../.. test_repo 31/sub/sub
+'
+
+test_expect_failure '#31: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
+	cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31/wt
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/31/wt" test_repo 31
+'
+
+test_expect_failure '#31: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
+	cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31/wt
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: (null)
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=wt test_repo 31
+'
+
+test_expect_failure '#31: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
+	cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31/wt
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/31/.git" GIT_WORK_TREE=wt test_repo 31
+'
+
+test_expect_failure '#31: GIT_DIR, GIT_WORK_TREE=wt at root' '
+	cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31/wt
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/31/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/31/wt" test_repo 31
+'
+
+test_expect_failure '#31: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
+	cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31/wt
+setup: cwd: $TRASH_DIRECTORY/31/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY/31/wt" test_repo 31/sub/sub
+'
+
+test_expect_failure '#31: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31/wt
+setup: cwd: $TRASH_DIRECTORY/31/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../../wt test_repo 31/sub/sub
+'
+
+test_expect_failure '#31: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31/wt
+setup: cwd: $TRASH_DIRECTORY/31/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/31/.git" GIT_WORK_TREE=../../wt test_repo 31/sub/sub
+'
+
+test_expect_failure '#31: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
+	cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31/wt
+setup: cwd: $TRASH_DIRECTORY/31/sub/sub
+setup: prefix: (null)
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/31/.git" GIT_WORK_TREE="$TRASH_DIRECTORY/31/wt" test_repo 31/sub/sub
+'
+
+test_expect_failure '#31: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
+	cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 31/
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 31
+'
+
+test_expect_failure '#31: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
+	cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 31/
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=.. test_repo 31
+'
+
+test_expect_failure '#31: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
+	cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 31/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/31/.git" GIT_WORK_TREE=.. test_repo 31
+'
+
+test_expect_failure '#31: GIT_DIR, GIT_WORK_TREE=.. at root' '
+	cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 31/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/31/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 31
+'
+
+test_expect_failure '#31: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
+	cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 31/sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 31/sub/sub
+'
+
+test_expect_failure '#31: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
+	cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 31/sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../../.. test_repo 31/sub/sub
+'
+
+test_expect_failure '#31: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
+	cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 31/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/31/.git" GIT_WORK_TREE=../../../ test_repo 31/sub/sub
+'
+
+test_expect_failure '#31: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
+	cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 31/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/31/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 31/sub/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 1/7] setup: support setting GIT_DIR=.git file
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (33 preceding siblings ...)
  2010-10-27 14:49 ` [PATCH 34/34] t1510: setup case #31 Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:58 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:58 ` [PATCH 2/7] unset: discard GIT_WORK_TREE if GIT_DIR is not set Nguyễn Thái Ngọc Duy
                   ` (5 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:58 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

---
 setup.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/setup.c b/setup.c
index a3b76de..2e7387d 100644
--- a/setup.c
+++ b/setup.c
@@ -317,17 +317,20 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
 				const char *work_tree_env, int *nongit_ok)
 {
 	static char buffer[1024 + 1];
-	const char *retval;
+	const char *retval, *gitfile;
 
 	if (PATH_MAX - 40 < strlen(gitdirenv))
 		die("'$%s' too big", GIT_DIR_ENVIRONMENT);
-	if (!is_git_directory(gitdirenv)) {
+	gitfile = read_gitfile_gently(gitdirenv);
+	if (!gitfile && !is_git_directory(gitdirenv)) {
 		if (nongit_ok) {
 			*nongit_ok = 1;
 			return NULL;
 		}
 		die("Not a git repository: '%s'", gitdirenv);
 	}
+	if (gitfile)
+		set_git_dir(gitfile);
 	if (!work_tree_env) {
 		retval = set_work_tree(gitdirenv);
 		/* config may override worktree */
@@ -341,7 +344,8 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
 			get_git_work_tree());
 	if (!retval || !*retval)
 		return NULL;
-	set_git_dir(make_absolute_path(gitdirenv));
+	if (!gitfile)
+		set_git_dir(make_absolute_path(gitdirenv));
 	if (chdir(work_tree_env) < 0)
 		die_errno ("Could not chdir to '%s'", work_tree_env);
 	strcat(buffer, "/");
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 2/7] unset: discard GIT_WORK_TREE if GIT_DIR is not set
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (34 preceding siblings ...)
  2010-10-27 14:58 ` [PATCH 1/7] setup: support setting GIT_DIR=.git file Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:58 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:58 ` [PATCH 3/7] setup: do not allow core.{bare,worktree} set at the same time Nguyễn Thái Ngọc Duy
                   ` (4 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:58 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

GIT_WORK_TREE can only be used together with GIT_DIR. Unfortunately
get_git_work_tree() checks that env variable unconditionally. As a
work around, discard the variable.
---
 setup.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/setup.c b/setup.c
index 2e7387d..992a944 100644
--- a/setup.c
+++ b/setup.c
@@ -364,14 +364,12 @@ static int cwd_contains_git_dir(const char **gitfile_dirp)
 	return is_git_directory(DEFAULT_GIT_DIR_ENVIRONMENT);
 }
 
-static const char *setup_discovered_git_dir(const char *work_tree_env,
-		int offset, int len, char *cwd, int *nongit_ok)
+static const char *setup_discovered_git_dir(int offset, int len, char *cwd, int *nongit_ok)
 {
 	int root_len;
 
 	inside_git_dir = 0;
-	if (!work_tree_env)
-		inside_work_tree = 1;
+	inside_work_tree = 1;
 	root_len = offset_1st_component(cwd);
 	git_work_tree_cfg = xstrndup(cwd, offset > root_len ? offset : root_len);
 	if (check_repository_format_gently(nongit_ok))
@@ -386,14 +384,12 @@ static const char *setup_discovered_git_dir(const char *work_tree_env,
 	return cwd + offset;
 }
 
-static const char *setup_bare_git_dir(const char *work_tree_env,
-		int offset, int len, char *cwd, int *nongit_ok)
+static const char *setup_bare_git_dir(int offset, int len, char *cwd, int *nongit_ok)
 {
 	int root_len;
 
 	inside_git_dir = 1;
-	if (!work_tree_env)
-		inside_work_tree = 0;
+	inside_work_tree = 0;
 	if (offset != len) {
 		if (chdir(cwd))
 			die_errno("Cannot come back to cwd");
@@ -457,6 +453,11 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
 	gitdirenv = getenv(GIT_DIR_ENVIRONMENT);
 	if (gitdirenv)
 		return setup_explicit_git_dir(gitdirenv, work_tree_env, nongit_ok);
+	else {
+		/* prevent get_git_work_tree() from using it because GIT_DIR is not set */
+		if (work_tree_env)
+			unsetenv(GIT_WORK_TREE_ENVIRONMENT);
+	}
 
 	if (!getcwd(cwd, sizeof(cwd)-1))
 		die_errno("Unable to read current working directory");
@@ -482,11 +483,9 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
 		current_device = get_device_or_die(".", NULL);
 	for (;;) {
 		if (cwd_contains_git_dir(&gitfile_dir))
-			return setup_discovered_git_dir(work_tree_env, offset,
-							len, cwd, nongit_ok);
+			return setup_discovered_git_dir(offset, len, cwd, nongit_ok);
 		if (is_git_directory("."))
-			return setup_bare_git_dir(work_tree_env, offset,
-							len, cwd, nongit_ok);
+			return setup_bare_git_dir(offset, len, cwd, nongit_ok);
 		while (--offset > ceil_offset && cwd[offset] != '/');
 		if (offset <= ceil_offset)
 			return setup_nongit(cwd, nongit_ok);
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 3/7] setup: do not allow core.{bare,worktree} set at the same time
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (35 preceding siblings ...)
  2010-10-27 14:58 ` [PATCH 2/7] unset: discard GIT_WORK_TREE if GIT_DIR is not set Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:58 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:58 ` [PATCH 4/7] setup: skip core.worktree if GIT_DIR is not set Nguyễn Thái Ngọc Duy
                   ` (3 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:58 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

---
 setup.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/setup.c b/setup.c
index 992a944..bbb430a 100644
--- a/setup.c
+++ b/setup.c
@@ -4,6 +4,8 @@
 static int inside_git_dir = -1;
 static int inside_work_tree = -1;
 
+static int has_core_worktree, has_core_bare;
+
 const char *prefix_path(const char *prefix, int len, const char *path)
 {
 	const char *orig = path;
@@ -245,6 +247,7 @@ void setup_work_tree(void)
 
 static int check_repository_format_gently(int *nongit_ok)
 {
+	has_core_worktree = has_core_bare = 0;
 	git_config(check_repository_format_version, NULL);
 	if (GIT_REPO_VERSION < repository_format_version) {
 		if (!nongit_ok)
@@ -256,6 +259,12 @@ static int check_repository_format_gently(int *nongit_ok)
 		*nongit_ok = -1;
 		return -1;
 	}
+	if (has_core_worktree && has_core_bare) {
+		if (!nongit_ok)
+			die("core.bare and core.worktree do not make sense");
+		*nongit_ok = -1;
+		return -1;
+	}
 	return 0;
 }
 
@@ -579,14 +588,20 @@ int check_repository_format_version(const char *var, const char *value, void *cb
 		shared_repository = git_config_perm(var, value);
 	else if (strcmp(var, "core.bare") == 0) {
 		is_bare_repository_cfg = git_config_bool(var, value);
-		if (is_bare_repository_cfg == 1)
+		if (is_bare_repository_cfg == 1) {
 			inside_work_tree = -1;
+			has_core_bare = 1;
+		}
 	} else if (strcmp(var, "core.worktree") == 0) {
 		if (!value)
 			return config_error_nonbool(var);
 		free(git_work_tree_cfg);
 		git_work_tree_cfg = xstrdup(value);
 		inside_work_tree = -1;
+
+		/* GIT_WORK_TREE overrides core.worktree */
+		if (!getenv(GIT_WORK_TREE_ENVIRONMENT))
+			has_core_worktree = 1;
 	}
 	return 0;
 }
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 4/7] setup: skip core.worktree if GIT_DIR is not set
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (36 preceding siblings ...)
  2010-10-27 14:58 ` [PATCH 3/7] setup: do not allow core.{bare,worktree} set at the same time Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:58 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:58 ` [PATCH 5/7] setup: rework core.worktree Nguyễn Thái Ngọc Duy
                   ` (2 subsequent siblings)
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:58 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

---
 setup.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/setup.c b/setup.c
index bbb430a..e8273c3 100644
--- a/setup.c
+++ b/setup.c
@@ -4,7 +4,7 @@
 static int inside_git_dir = -1;
 static int inside_work_tree = -1;
 
-static int has_core_worktree, has_core_bare;
+static int has_core_worktree, has_core_bare, has_git_dir_env;
 
 const char *prefix_path(const char *prefix, int len, const char *path)
 {
@@ -460,8 +460,10 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
 	 * validation.
 	 */
 	gitdirenv = getenv(GIT_DIR_ENVIRONMENT);
-	if (gitdirenv)
-		return setup_explicit_git_dir(gitdirenv, work_tree_env, nongit_ok);
+	if (gitdirenv) {
+		has_git_dir_env = 1;
+		return setup_explicit_git_dir(gitdirenv, work_tree_env, nongit_o, nongit_ok);
+	}
 	else {
 		/* prevent get_git_work_tree() from using it because GIT_DIR is not set */
 		if (work_tree_env)
@@ -593,6 +595,8 @@ int check_repository_format_version(const char *var, const char *value, void *cb
 			has_core_bare = 1;
 		}
 	} else if (strcmp(var, "core.worktree") == 0) {
+		if (!has_git_dir_env) /* only valid when GIT_DIR is set */
+			return 0;
 		if (!value)
 			return config_error_nonbool(var);
 		free(git_work_tree_cfg);
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 5/7] setup: rework core.worktree
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (37 preceding siblings ...)
  2010-10-27 14:58 ` [PATCH 4/7] setup: skip core.worktree if GIT_DIR is not set Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:58 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:58 ` [PATCH 6/7] get_git_work_tree: core.worktree relative to git_dir Nguyễn Thái Ngọc Duy
  2010-10-27 14:58 ` [PATCH 7/7] new failures Nguyễn Thái Ngọc Duy
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:58 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Now that core.worktree can only be effective inside
setup_explicit_git_dir, move the code up from setup_git_directory().
---
 setup.c |   48 +++++++++++++++++-------------------------------
 1 files changed, 17 insertions(+), 31 deletions(-)

diff --git a/setup.c b/setup.c
index e8273c3..1a4765d 100644
--- a/setup.c
+++ b/setup.c
@@ -323,7 +323,9 @@ const char *read_gitfile_gently(const char *path)
 }
 
 static const char *setup_explicit_git_dir(const char *gitdirenv,
-				const char *work_tree_env, int *nongit_ok)
+					  const char *work_tree_env,
+					  char *cwd, int len,
+					  int *nongit_ok)
 {
 	static char buffer[1024 + 1];
 	const char *retval, *gitfile;
@@ -340,23 +342,21 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
 	}
 	if (gitfile)
 		set_git_dir(gitfile);
-	if (!work_tree_env) {
-		retval = set_work_tree(gitdirenv);
-		/* config may override worktree */
-		if (check_repository_format_gently(nongit_ok))
-			return NULL;
-		return retval;
-	}
+	if (!work_tree_env)
+		set_work_tree(gitdirenv);
+
+	/* config may override worktree */
 	if (check_repository_format_gently(nongit_ok))
 		return NULL;
+
 	retval = get_relative_cwd(buffer, sizeof(buffer) - 1,
-			get_git_work_tree());
+				  get_git_work_tree());
 	if (!retval || !*retval)
 		return NULL;
 	if (!gitfile)
 		set_git_dir(make_absolute_path(gitdirenv));
-	if (chdir(work_tree_env) < 0)
-		die_errno ("Could not chdir to '%s'", work_tree_env);
+	if (chdir(get_git_work_tree()) < 0)
+		die_errno ("Could not chdir to '%s'", get_git_work_tree());
 	strcat(buffer, "/");
 	return retval;
 }
@@ -454,6 +454,10 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
 	if (nongit_ok)
 		*nongit_ok = 0;
 
+	if (!getcwd(cwd, sizeof(cwd)-1))
+		die_errno("Unable to read current working directory");
+	offset = len = strlen(cwd);
+
 	/*
 	 * If GIT_DIR is set explicitly, we're not going
 	 * to do any discovery, but we still do repository
@@ -462,7 +466,7 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
 	gitdirenv = getenv(GIT_DIR_ENVIRONMENT);
 	if (gitdirenv) {
 		has_git_dir_env = 1;
-		return setup_explicit_git_dir(gitdirenv, work_tree_env, nongit_o, nongit_ok);
+		return setup_explicit_git_dir(gitdirenv, work_tree_env, cwd, len, nongit_ok);
 	}
 	else {
 		/* prevent get_git_work_tree() from using it because GIT_DIR is not set */
@@ -470,9 +474,6 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
 			unsetenv(GIT_WORK_TREE_ENVIRONMENT);
 	}
 
-	if (!getcwd(cwd, sizeof(cwd)-1))
-		die_errno("Unable to read current working directory");
-
 	ceil_offset = longest_ancestor_length(cwd, env_ceiling_dirs);
 	if (ceil_offset < 0 && has_dos_drive_prefix(cwd))
 		ceil_offset = 1;
@@ -488,7 +489,6 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
 	 * - ../../.git/
 	 *   etc.
 	 */
-	offset = len = strlen(cwd);
 	one_filesystem = !git_env_bool("GIT_DISCOVERY_ACROSS_FILESYSTEM", 0);
 	if (one_filesystem)
 		current_device = get_device_or_die(".", NULL);
@@ -623,19 +623,5 @@ int check_repository_format(void)
  */
 const char *setup_git_directory(void)
 {
-	const char *retval = setup_git_directory_gently(NULL);
-
-	/* If the work tree is not the default one, recompute prefix */
-	if (inside_work_tree < 0) {
-		static char buffer[PATH_MAX + 1];
-		char *rel;
-		if (retval && chdir(retval))
-			die_errno ("Could not jump back into original cwd");
-		rel = get_relative_cwd(buffer, PATH_MAX, get_git_work_tree());
-		if (rel && *rel && chdir(get_git_work_tree()))
-			die_errno ("Could not jump to working directory");
-		return rel && *rel ? strcat(rel, "/") : NULL;
-	}
-
-	return retval;
+	return setup_git_directory_gently(NULL);
 }
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 6/7] get_git_work_tree: core.worktree relative to git_dir
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (38 preceding siblings ...)
  2010-10-27 14:58 ` [PATCH 5/7] setup: rework core.worktree Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:58 ` Nguyễn Thái Ngọc Duy
  2010-10-27 14:58 ` [PATCH 7/7] new failures Nguyễn Thái Ngọc Duy
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:58 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

---
 environment.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/environment.c b/environment.c
index de5581f..d41dcfb 100644
--- a/environment.c
+++ b/environment.c
@@ -153,8 +153,16 @@ const char *get_git_work_tree(void)
 		if (!work_tree && is_bare_repository_cfg < 1) {
 			work_tree = git_work_tree_cfg;
 			/* make_absolute_path also normalizes the path */
-			if (work_tree && !is_absolute_path(work_tree))
-				work_tree = xstrdup(make_absolute_path(git_path("%s", work_tree)));
+			if (work_tree && !is_absolute_path(work_tree)) {
+				char cwd[PATH_MAX];
+				if (!getcwd(cwd, PATH_MAX))
+					die("Could not get current working directory");
+				if (chdir(get_git_dir()))
+					die("Could not chdir to $GIT_DIR");
+				work_tree = xstrdup(make_absolute_path(work_tree));
+				if (chdir(cwd))
+					die("Could not chdir to previous working directory");
+			}
 		} else if (work_tree)
 			work_tree = xstrdup(make_absolute_path(work_tree));
 		git_work_tree_initialized = 1;
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 7/7] new failures
  2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
                   ` (39 preceding siblings ...)
  2010-10-27 14:58 ` [PATCH 6/7] get_git_work_tree: core.worktree relative to git_dir Nguyễn Thái Ngọc Duy
@ 2010-10-27 14:58 ` Nguyễn Thái Ngọc Duy
  40 siblings, 0 replies; 45+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-10-27 14:58 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy


git_dir changes are acceptable. The other two, hm...
---
 t/t1510-repo-setup.sh |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 9d24a0f..7dbccf4 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -781,7 +781,7 @@ EOF
 
 test_expect_success '#6: GIT_DIR(rel), core.worktree=../.. at root' '
 	cat >6/expected <<EOF &&
-setup: git_dir: .git
+setup: git_dir: $TRASH_DIRECTORY/6/.git
 setup: worktree: $TRASH_DIRECTORY
 setup: cwd: $TRASH_DIRECTORY
 setup: prefix: 6/
@@ -792,7 +792,7 @@ EOF
 
 test_expect_success '#6: GIT_DIR(rel), core.worktree=../..(rel) at root' '
 	cat >6/expected <<EOF &&
-setup: git_dir: .git
+setup: git_dir: $TRASH_DIRECTORY/6/.git
 setup: worktree: $TRASH_DIRECTORY
 setup: cwd: $TRASH_DIRECTORY
 setup: prefix: 6/
@@ -3713,7 +3713,7 @@ EOF
 	test_repo 24
 '
 
-test_expect_success '#24: in subdir' '
+test_expect_failure '#24: in subdir' '
 	cat >24/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/24.git
 setup: worktree: (null)
@@ -4147,7 +4147,7 @@ EOF
 	test_repo 28
 '
 
-test_expect_success '#28: in subdir' '
+test_expect_failure '#28: in subdir' '
 	cat >28/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/28.git
 setup: worktree: (null)
-- 
1.7.0.2.445.gcbdb3

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* Re: [PATCH 02/34] Add t1510 and basic rules that run repo setup
  2010-10-27 14:49 ` [PATCH 02/34] Add t1510 and basic rules that run repo setup Nguyễn Thái Ngọc Duy
@ 2010-10-27 15:37   ` Nguyen Thai Ngoc Duy
  2010-10-27 16:30     ` Jonathan Nieder
  0 siblings, 1 reply; 45+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2010-10-27 15:37 UTC (permalink / raw)
  To: git

2010/10/27 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>:
> +# 2. .git file is relative to git_dir. .git file is basically symlink
> +#    in disguise.

This is not completely followed in my tests. If .git is a true
symlink, its link is relative to .git itself. When .git is a file, it
would be more difficult to calculate path relative to .git (you can't
chdir to a file). In my tests, the link is relative to .git's parent
directory, not .git.
-- 
Duy

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 02/34] Add t1510 and basic rules that run repo setup
  2010-10-27 15:37   ` Nguyen Thai Ngoc Duy
@ 2010-10-27 16:30     ` Jonathan Nieder
  2010-10-28  0:16       ` Nguyen Thai Ngoc Duy
  0 siblings, 1 reply; 45+ messages in thread
From: Jonathan Nieder @ 2010-10-27 16:30 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy; +Cc: git

Nguyen Thai Ngoc Duy wrote:
> 2010/10/27 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>:

>> +# 2. .git file is relative to git_dir. .git file is basically symlink
>> +#    in disguise.
>
> This is not completely followed in my tests. If .git is a true
> symlink, its link is relative to .git itself. When .git is a file, it
> would be more difficult to calculate path relative to .git (you can't
> chdir to a file).

I'm not sure I understand:

 git init repo
 cd repo
 mv .git .git.real
 ln -s .git.real .git

The path ".git.real" is relative to "repo/", not "repo/.git/", no?
 
In other words, I don't you think you have to worry --- the test

> In my tests, the link is relative to .git's parent
> directory, not .git.

seems right.

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 02/34] Add t1510 and basic rules that run repo setup
  2010-10-27 16:30     ` Jonathan Nieder
@ 2010-10-28  0:16       ` Nguyen Thai Ngoc Duy
  0 siblings, 0 replies; 45+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2010-10-28  0:16 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git

On Wed, Oct 27, 2010 at 11:30 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Nguyen Thai Ngoc Duy wrote:
>> 2010/10/27 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>:
>
>>> +# 2. .git file is relative to git_dir. .git file is basically symlink
>>> +#    in disguise.
>>
>> This is not completely followed in my tests. If .git is a true
>> symlink, its link is relative to .git itself. When .git is a file, it
>> would be more difficult to calculate path relative to .git (you can't
>> chdir to a file).
>
> I'm not sure I understand:
>
>  git init repo
>  cd repo
>  mv .git .git.real
>  ln -s .git.real .git
>
> The path ".git.real" is relative to "repo/", not "repo/.git/", no?

Ah, ok. I was confused after writing all those tests.
-- 
Duy

^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2010-10-28  0:16 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 01/34] builtins: print setup info if repo is found Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 02/34] Add t1510 and basic rules that run repo setup Nguyễn Thái Ngọc Duy
2010-10-27 15:37   ` Nguyen Thai Ngoc Duy
2010-10-27 16:30     ` Jonathan Nieder
2010-10-28  0:16       ` Nguyen Thai Ngoc Duy
2010-10-27 14:49 ` [PATCH 03/34] t1510: setup case #0 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 04/34] t1510: setup case #1 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 05/34] t1510: setup case #2 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 06/34] t1510: setup case #3 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 07/34] t1510: setup case #4 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 08/34] t1510: setup case #5 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 09/34] t1510: setup case #6 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 10/34] t1510: setup case #7 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 11/34] t1510: setup case #8 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 12/34] t1510: setup case #9 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 13/34] t1510: setup case #10 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 14/34] t1510: setup case #11 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 15/34] t1510: setup case #12 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 16/34] t1510: setup case #13 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 17/34] t1510: setup case #14 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 18/34] t1510: setup case #15 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 19/34] t1510: setup case #16 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 20/34] t1510: setup case #17 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 21/34] t1510: setup case #18 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 22/34] t1510: setup case #19 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 23/34] t1510: setup case #20 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 24/34] t1510: setup case #21 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 25/34] t1510: setup case #22 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 26/34] t1510: setup case #23 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 27/34] t1510: setup case #24 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 28/34] t1510: setup case #25 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 29/34] t1510: setup case #26 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 30/34] t1510: setup case #27 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 31/34] t1510: setup case #28 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 32/34] t1510: setup case #29 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 33/34] t1510: setup case #30 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 34/34] t1510: setup case #31 Nguyễn Thái Ngọc Duy
2010-10-27 14:58 ` [PATCH 1/7] setup: support setting GIT_DIR=.git file Nguyễn Thái Ngọc Duy
2010-10-27 14:58 ` [PATCH 2/7] unset: discard GIT_WORK_TREE if GIT_DIR is not set Nguyễn Thái Ngọc Duy
2010-10-27 14:58 ` [PATCH 3/7] setup: do not allow core.{bare,worktree} set at the same time Nguyễn Thái Ngọc Duy
2010-10-27 14:58 ` [PATCH 4/7] setup: skip core.worktree if GIT_DIR is not set Nguyễn Thái Ngọc Duy
2010-10-27 14:58 ` [PATCH 5/7] setup: rework core.worktree Nguyễn Thái Ngọc Duy
2010-10-27 14:58 ` [PATCH 6/7] get_git_work_tree: core.worktree relative to git_dir Nguyễn Thái Ngọc Duy
2010-10-27 14:58 ` [PATCH 7/7] new failures Nguyễn Thái Ngọc Duy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.