Skip to contentSkip to conversation

setup tests

PATCH In review Nguyễn Thái Ngọc Duy 3 participants 23 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

cover setup tests

These tests are created according to [1] and its following discussions. I have yet to create tests for the last 16 cases, which might be simpler. Tests from 8-15 are usually copy of 0-7 with some modification. If you find bugs in 0-7, stop reading 8-15, it's just wasting time.

The rules are bent a bit the way the code does it, specifically:

- GIT_WORK_TREE is relative to cwd, not GIT_DIR
- core.worktree is always effective regardless GIT_DIR/--git-dir

Also I assume that when cwd is outside worktree, cwd should be unchanged (therefore prefix is NULL). This is the behavior when GIT_DIR and GIT_WORK_TREE are set. Let's apply it to all other cases where cwd may be outside worktree.

Adjusting the expected results is not hard. So it's up to you guys. Once we agree on something, I can update the tests.

Also when GIT_DIR is set, .git _file_ is not recognized because setup_explicit_git_dir() does not accept it. There are a _lot_ of failed tests due to this. I probably should fix that, otherwise tests #8-15 may not be very reliable.

[1] http://mid.gmane.org/20101020085859.GA13135@do

Nguyễn Thái Ngọc Duy (18):
rev-parse: add --internal-cwd and --internal-git-dir for tests Add t1510 for setup tests
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

 builtin/rev-parse.c   |   11 +
 t/t1510-repo-setup.sh | 2483 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 2494 insertions(+), 0 deletions(-)
 create mode 100755 t/t1510-repo-setup.sh
#1 lore raw

PATCH 1/18 rev-parse: add --internal-cwd and --internal-git-dir for tests

--internal-cwd is obvious, no way else to expose it for testing.

--internal-git-dir is introduced because --git-dir prepares its output suitable for scripting. For tests, it must be exactly what git stores.

---
 builtin/rev-parse.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
builtin/rev-parse.c +11 -0
index a5a1c86..454a25c 100644
@@ -642,6 +642,17 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 				putchar('\n');
 				continue;
 			}
+			if (!strcmp(arg, "--internal-cwd")) {
+				static char cwd[PATH_MAX];
+				if (!getcwd(cwd, PATH_MAX))
+					die_errno("unable to get current working directory");
+				puts(cwd);
+				continue;
+			}
+			if (!strcmp(arg, "--internal-git-dir")) {
+				puts(get_git_dir());
+				continue;
+			}
 			if (!strcmp(arg, "--git-dir")) {
 				const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
 				static char cwd[PATH_MAX];
Signature · 1 line
1.7.0.2.445.gcbdb3
#2 lore raw

Re: [WIP PATCH 01/18] rev-parse: add --internal-cwd and --internal-git-dir for tests

Quoted 4 lines · Nguyễn Thái Ngọc Duy

--internal-cwd is obvious, no way else to expose it for testing.

--internal-git-dir is introduced because --git-dir prepares its output suitable for scripting. For tests, it must be exactly what git stores.

Hmm. Forget this is used in tests, would it make sense to do this with trace_printf, at the end of setup, as in your earlier patch?

I think it might: just like the exec: lines provide context about what command is being traced, such trace: cwd: lines would make it clearer what paths that are being output might be referring to.

Returning to the topic of tests, is it possible to get at these variables using an external command that is run by git? pre-commit hook, maybe. Testing of other symptoms is also possible, as in Frédéric's example.

#3 lore raw

Re: [WIP PATCH 01/18] rev-parse: add --internal-cwd and --internal-git-dir for tests

2010/10/24 Jonathan Nieder <[email protected]>:

Quoted 9 lines
Quoted 4 lines · Nguyễn Thái Ngọc Duy

--internal-cwd is obvious, no way else to expose it for testing.

--internal-git-dir is introduced because --git-dir prepares its output suitable for scripting. For tests, it must be exactly what git stores.

Hmm.  Forget this is used in tests, would it make sense to do this with trace_printf, at the end of setup, as in your earlier patch?

trace_printf surely does. But "the end of setup" is unclear. As of now, setup ends when setup_* function _and_ setup_git_env() are called. There are cases that setup_* finishes without calling setup_git_env(), or setup_git_env() is called way before setup_* is finished.

Quoted 3 lines

I think it might: just like the exec: lines provide context about what command is being traced, such trace: cwd: lines would make it clearer what paths that are being output might be referring to.

Also prefix them all with "setup:", something like

setup: git_dir: ../.git
setup: work_tree: /my/git/worktree
setup: cwd: /my/git/worktree
setup: prefix: sub/

would be easy to be grepped from GIT_TRACE, to read and to test_cmp.

Quoted 4 lines

Returning to the topic of tests, is it possible to get at these variables using an external command that is run by git?  pre-commit hook, maybe.  Testing of other symptoms is also possible, as in Frédéric's example.

Why do hooks need these? git_dir, prefix are already accessible via --git-dir, --show-prefix, --show-toplevel. Current cwd can be determined with --is-inside-work-tree: if it returns true, current cwd is worktree root, otherwise it is original cwd.

Signature · 1 line
Duy
#4 lore raw

Re: [WIP PATCH 01/18] rev-parse: add --internal-cwd and --internal-git-dir for tests

Quoted 6 lines · Nguyen Thai Ngoc Duy

2010/10/24 Jonathan Nieder <[email protected]>:

Quoted 3 lines

I think it might: just like the exec: lines provide context about what command is being traced, such trace: cwd: lines would make it clearer what paths that are being output might be referring to.

Quoted 6 lines

Also prefix them all with "setup:", something like

setup: git_dir: ../.git
setup: work_tree: /my/git/worktree
setup: cwd: /my/git/worktree
setup: prefix: sub/

I guess that those paths would be c-quoted, if necessary (trailing space, embedded newline, quotes, etc.)?

Signature · 3 lines
Jakub Narebski
Poland
ShadeHawk on #git
#5 lore raw

Re: [WIP PATCH 01/18] rev-parse: add --internal-cwd and --internal-git-dir for tests

Quoted 10 lines · Jakub Narebski
Quoted 8 lines · Nguyen Thai Ngoc Duy

2010/10/24 Jonathan Nieder <[email protected]>:

Quoted 3 lines

I think it might: just like the exec: lines provide context about what command is being traced, such trace: cwd: lines would make it clearer what paths that are being output might be referring to.

Also prefix them all with "setup:", something like

Quoted 7 lines
Quoted 4 lines

setup: git_dir: ../.git
setup: work_tree: /my/git/worktree
setup: cwd: /my/git/worktree
setup: prefix: sub/

I guess that those paths would be c-quoted, if necessary (trailing space, embedded newline, quotes, etc.)?

For the sake of grep (because '\n' may break lines), yes.

Signature · 1 line
Duy
#6 lore raw

PATCH 2/18 Add t1510 for setup tests

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |   56 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)
 create mode 100755 t/t1510-repo-setup.sh
t/t1510-repo-setup.sh new file +56 -0
new file mode 100755
index 0000000..d618787
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+test_description='Tests of cwd/prefix/worktree/gitdir setup in all cases'
+
+. ./test-lib.sh
+
+# A few principles for repo setup:
+#
+# 1. GIT_DIR is relative to user's cwd. This directory is refered as
+#    "git_dir" below. Auto discovered repo is also "git_dir".
+#    --git-dir is equivalent to GIT_DIR.
+#
+# 2. core.worktree is relative to git_dir
+#
+# 3. GIT_WORK_TREE is relative to user's cwd. --work-tree is
+#    equivalent to GIT_WORK_TREE.
+#
+# 4. .git file is relative to git_dir. Note that the repo where .git
+#    file points to is not considered "git_dir" in the above.
+#
+# 5. GIT_WORK_TREE is only effective if GIT_DIR is
+#    set (hence "Effective GIT_WORK_TREE"
+#    below). Uneffective GIT_WORK_TREE should be warned.
+#
+# 6. Effective GIT_WORK_TREE will override core.worktree
+#
+# 7. During repo discovery, if "." is found a repo, it is considered a
+#    bare repo unless core.worktree is set
+#
+# 8. core.bare conflicts with core.worktree
+#
+# 9. Effective GIT_WORK_TREE will override core.bare
+#
+# 10. When user's cwd is outside worktree, cwd will remain unchanged,
+#     prefix be NULL.
+
+test_repo() {
+	(
+	if [ -n "$1" ]; then cd "$1"; fi &&
+	git symbolic-ref HEAD >/dev/null && # git_dir reachability test first
+	git rev-parse --internal-git-dir >result &&
+	git rev-parse --show-toplevel >>result &&
+	git rev-parse --internal-cwd >>result &&
+	git rev-parse --show-prefix >>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
Signature · 1 line
1.7.0.2.445.gcbdb3
#7 lore raw

PATCH 3/18 t1510: setup case #0

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)
t/t1510-repo-setup.sh +44 -0
index d618787..88edf4d 100755
@@ -53,4 +53,48 @@ 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 && test_repo 0
+.git
+$TRASH_DIRECTORY/0
+$TRASH_DIRECTORY/0
+EOF
+'
+
+test_expect_success '#0: in subdir' '
+	cat >0/sub/expected <<EOF && test_repo 0/sub
+.git
+$TRASH_DIRECTORY/0
+$TRASH_DIRECTORY/0
+sub/
+EOF
+'
+
 test_done
Signature · 1 line
1.7.0.2.445.gcbdb3
#8 lore raw

PATCH 4/18 t1510: setup case #1

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)
t/t1510-repo-setup.sh +42 -0
index 88edf4d..d450b4a 100755
@@ -97,4 +97,46 @@ sub/
 EOF
 '
 
+#
+# 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: same as case #0 (with warnings perhaps)
+
+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 && cd ..
+'
+
+# FIXME: check for warning that GIT_WORK_TREE is ignored
+test_expect_failure '#1: at root' '
+	cat >1/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/1
+$TRASH_DIRECTORY/1
+EOF
+	GIT_WORK_TREE=non-existent test_repo 1
+'
+
+# FIXME: check for warning that GIT_WORK_TREE is ignored
+test_expect_failure '#1: in subdir' '
+	cat >1/sub/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/1
+$TRASH_DIRECTORY/1
+sub/
+EOF
+	GIT_WORK_TREE=non-existent test_repo 1/sub
+'
+
 test_done
Signature · 1 line
1.7.0.2.445.gcbdb3
#9 lore raw

PATCH 5/18 t1510: setup case #2

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |   63 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 63 insertions(+), 0 deletions(-)
t/t1510-repo-setup.sh +63 -0
index d450b4a..20ad6d4 100755
@@ -139,4 +139,67 @@ EOF
 	GIT_WORK_TREE=non-existent 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 &&
+$TRASH_DIRECTORY/2/.git
+$TRASH_DIRECTORY/2
+$TRASH_DIRECTORY/2
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/2/.git" test_repo 2
+'
+
+test_expect_success '#2: in subdir' '
+	cat >2/sub/expected <<EOF &&
+$TRASH_DIRECTORY/2/.git
+$TRASH_DIRECTORY/2/sub
+$TRASH_DIRECTORY/2/sub
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/2/.git" test_repo 2/sub
+'
+
+test_expect_success '#2: relative GIT_DIR at root' '
+	cat >2/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/2
+$TRASH_DIRECTORY/2
+EOF
+	GIT_DIR=.git test_repo 2
+'
+
+test_expect_success '#2: relative GIT_DIR in subdir' '
+	cat >2/sub/expected <<EOF &&
+../.git
+$TRASH_DIRECTORY/2/sub
+$TRASH_DIRECTORY/2/sub
+EOF
+	GIT_DIR=../.git test_repo 2/sub
+'
+
 test_done
Signature · 1 line
1.7.0.2.445.gcbdb3
#10 lore raw

PATCH 6/18 t1510: setup case #3

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |  255 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 255 insertions(+), 0 deletions(-)
t/t1510-repo-setup.sh +255 -0
index 20ad6d4..508b7e2 100755
@@ -202,4 +202,259 @@ 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 at root' '
+	cat >3/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/3
+$TRASH_DIRECTORY/3
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/3" test_repo 3
+'
+
+test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE(rel) at root' '
+	cat >3/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/3
+$TRASH_DIRECTORY/3
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=. test_repo 3
+'
+
+test_expect_success '#3: GIT_DIR, GIT_WORK_TREE at root' '
+	cat >3/expected <<EOF &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY/3
+$TRASH_DIRECTORY/3
+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(rel) at root' '
+	cat >3/expected <<EOF &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY/3
+$TRASH_DIRECTORY/3
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/3/.git" GIT_WORK_TREE=. test_repo 3
+'
+
+test_expect_success '#3: GIT_DIR(rel), GIT_WORKTREE in subdir' '
+	cat >3/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY/3
+$TRASH_DIRECTORY/3
+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(rel) in subdir' '
+	cat >3/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY/3
+$TRASH_DIRECTORY/3
+sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../.. test_repo 3/sub/sub
+'
+
+test_expect_success '#3: GIT_DIR, GIT_WORKTREE in subdir' '
+	cat >3/sub/expected <<EOF &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY/3
+$TRASH_DIRECTORY/3
+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(rel) in subdir' '
+	cat >3/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY/3
+$TRASH_DIRECTORY/3
+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 &&
+.git
+$TRASH_DIRECTORY/3/wt
+$TRASH_DIRECTORY/3
+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 &&
+.git
+$TRASH_DIRECTORY/3/wt
+$TRASH_DIRECTORY/3
+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 &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY/3/wt
+$TRASH_DIRECTORY/3
+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 &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY/3/wt
+$TRASH_DIRECTORY/3
+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 &&
+../../.git
+$TRASH_DIRECTORY/3/wt
+$TRASH_DIRECTORY/3/sub/sub
+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 &&
+../../.git
+$TRASH_DIRECTORY/3/wt
+$TRASH_DIRECTORY/3/sub/sub
+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 &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY/3/wt
+$TRASH_DIRECTORY/3/sub/sub
+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 &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY/3/wt
+$TRASH_DIRECTORY/3/sub/sub
+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 &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/3/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+3/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/3/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 3/sub/sub
+'
+
 test_done
Signature · 1 line
1.7.0.2.445.gcbdb3
#11 lore raw

PATCH 7/18 t1510: setup case #4

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |  131 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 131 insertions(+), 0 deletions(-)
t/t1510-repo-setup.sh +131 -0
index 508b7e2..ee2b02a 100755
@@ -457,4 +457,135 @@ 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:
+#
+#  - worktree is at core.worktree
+#  - cwd is at worktree root
+#  - prefix is calculated
+#  - git_dir is discovered
+#  - cwd can be outside worktree
+
+test_expect_success '#4: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 4 4/sub 4/sub/sub 4.wt 4.wt/sub 4/wt 4/wt/sub &&
+	cd 4 && git init && cd ..
+'
+
+test_expect_success '#4: core.worktree(rel), at root' '
+	cat >4/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/4
+$TRASH_DIRECTORY/4
+EOF
+	git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree .. &&
+	test_repo 4
+'
+
+test_expect_success '#4: core.worktree, at root' '
+	cat >4/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/4
+$TRASH_DIRECTORY/4
+EOF
+	git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree "$TRASH_DIRECTORY/4" &&
+	test_repo 4
+'
+
+test_expect_failure '#4: core.worktree(rel), in subdir' '
+	cat >4/sub/sub/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/4
+$TRASH_DIRECTORY/4
+sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree .. &&
+	test_repo 4/sub/sub
+'
+
+test_expect_success '#4: core.worktree, in subdir' '
+	cat >4/sub/sub/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/4
+$TRASH_DIRECTORY/4
+sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree "$TRASH_DIRECTORY/4" &&
+	test_repo 4/sub/sub
+'
+
+test_expect_success '#4: core.worktree=wt(rel), at root' '
+	cat >4/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/4/wt
+$TRASH_DIRECTORY/4
+EOF
+	git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree ../wt &&
+	test_repo 4
+'
+
+test_expect_success '#4: core.worktree=wt, at root' '
+	cat >4/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/4/wt
+$TRASH_DIRECTORY/4
+EOF
+	git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree "$TRASH_DIRECTORY/4/wt" &&
+	test_repo 4
+'
+
+test_expect_failure '#4: core.worktree=wt(rel), in subdir' '
+	cat >4/sub/sub/expected <<EOF &&
+../../.git
+$TRASH_DIRECTORY/4/wt
+$TRASH_DIRECTORY/4/sub/sub
+EOF
+	git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree ../wt &&
+	test_repo 4/sub/sub
+'
+
+test_expect_failure '#4: core.worktree=wt, in subdir' '
+	cat >4/sub/sub/expected <<EOF &&
+../../.git
+$TRASH_DIRECTORY/4/wt
+$TRASH_DIRECTORY/4/sub/sub
+EOF
+	git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree "$TRASH_DIRECTORY/4/wt" &&
+	test_repo 4/sub/sub
+'
+
+test_expect_failure '#4: core.worktree=..(rel), at root' '
+	cat >4/expected <<EOF &&
+4/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+4/
+EOF
+	git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree ../.. &&
+	test_repo 4
+'
+
+test_expect_failure '#4: core.worktree=.., at root' '
+	cat >4/expected <<EOF &&
+4/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+4/
+EOF
+	git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree "$TRASH_DIRECTORY/4" &&
+	test_repo 4
+'
+
 test_done
Signature · 1 line
1.7.0.2.445.gcbdb3
#12 lore raw

PATCH 8/18 t1510: setup case #5

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |  135 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 135 insertions(+), 0 deletions(-)
t/t1510-repo-setup.sh +135 -0
index ee2b02a..87db2c6 100755
@@ -588,4 +588,139 @@ EOF
 	test_repo 4
 '
 
+#
+# 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 is only effective when GIT_DIR is
+# set, which is not the case. So it is the same as case #4.
+#
+#  - worktree is at core.worktree
+#  - cwd is at worktree root
+#  - prefix is calculated
+#  - git_dir is discovered
+#  - cwd can be outside worktree
+
+test_expect_success '#5: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 5 5/sub 5/sub/sub 5.wt 5.wt/sub 5/wt 5/wt/sub &&
+	cd 5 && git init && cd .. &&
+	export GIT_WORK_TREE=non-existent
+'
+
+test_expect_failure '#5: core.worktree(rel), at root' '
+	cat >5/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/5
+$TRASH_DIRECTORY/5
+EOF
+	git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree .. &&
+	test_repo 5
+'
+
+test_expect_failure '#5: core.worktree, at root' '
+	cat >5/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/5
+$TRASH_DIRECTORY/5
+EOF
+	git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree "$TRASH_DIRECTORY/5" &&
+	test_repo 5
+'
+
+test_expect_failure '#5: core.worktree(rel), in subdir' '
+	cat >5/sub/sub/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/5
+$TRASH_DIRECTORY/5
+sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree .. &&
+	test_repo 5/sub/sub
+'
+
+test_expect_failure '#5: core.worktree, in subdir' '
+	cat >5/sub/sub/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/5
+$TRASH_DIRECTORY/5
+sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree "$TRASH_DIRECTORY/5" &&
+	test_repo 5/sub/sub
+'
+
+test_expect_failure '#5: core.worktree=wt(rel), at root' '
+	cat >5/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/5/wt
+$TRASH_DIRECTORY/5
+EOF
+	git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree ../wt &&
+	test_repo 5
+'
+
+test_expect_failure '#5: core.worktree=wt, at root' '
+	cat >5/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/5/wt
+$TRASH_DIRECTORY/5
+EOF
+	git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree "$TRASH_DIRECTORY/5/wt" &&
+	test_repo 5
+'
+
+test_expect_failure '#5: core.worktree=wt(rel), in subdir' '
+	cat >5/sub/sub/expected <<EOF &&
+../../.git
+$TRASH_DIRECTORY/5/wt
+$TRASH_DIRECTORY/5/sub/sub
+EOF
+	git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree ../wt &&
+	test_repo 5/sub/sub
+'
+
+test_expect_failure '#5: core.worktree=wt, in subdir' '
+	cat >5/sub/sub/expected <<EOF &&
+../../.git
+$TRASH_DIRECTORY/5/wt
+$TRASH_DIRECTORY/5/sub/sub
+EOF
+	git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree "$TRASH_DIRECTORY/5/wt" &&
+	test_repo 5/sub/sub
+'
+
+test_expect_failure '#5: core.worktree=..(rel), at root' '
+	cat >5/expected <<EOF &&
+5/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+5/
+EOF
+	git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree ../.. &&
+	test_repo 5
+'
+
+test_expect_failure '#5: core.worktree=.., at root' '
+	cat >5/expected <<EOF &&
+5/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+5/
+EOF
+	git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree "$TRASH_DIRECTORY/5" &&
+	test_repo 5
+'
+
 test_done
Signature · 1 line
1.7.0.2.445.gcbdb3
#13 lore raw

PATCH 9/18 t1510: setup case #6

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |  279 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 279 insertions(+), 0 deletions(-)
t/t1510-repo-setup.sh +279 -0
index 87db2c6..7e902b0 100755
@@ -723,4 +723,283 @@ EOF
 	test_repo 5
 '
 
+#
+# 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), GIT_WORK_TREE at root' '
+	cat >6/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/6
+$TRASH_DIRECTORY/6
+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), GIT_WORK_TREE(rel) at root' '
+	cat >6/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/6
+$TRASH_DIRECTORY/6
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
+	GIT_DIR=.git test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR, GIT_WORK_TREE at root' '
+	cat >6/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6
+$TRASH_DIRECTORY/6
+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, GIT_WORK_TREE(rel) at root' '
+	cat >6/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6
+$TRASH_DIRECTORY/6
+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), GIT_WORKTREE in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6
+$TRASH_DIRECTORY/6
+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), GIT_WORKTREE(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6
+$TRASH_DIRECTORY/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, GIT_WORKTREE in subdir' '
+	cat >6/sub/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6
+$TRASH_DIRECTORY/6
+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, GIT_WORKTREE(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6
+$TRASH_DIRECTORY/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(rel), GIT_WORK_TREE=wt at root' '
+	cat >6/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/6/wt
+$TRASH_DIRECTORY/6
+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), GIT_WORK_TREE=wt(rel) at root' '
+	cat >6/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/6/wt
+$TRASH_DIRECTORY/6
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
+	GIT_DIR=.git test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
+	cat >6/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6/wt
+$TRASH_DIRECTORY/6
+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, GIT_WORK_TREE=wt at root' '
+	cat >6/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6/wt
+$TRASH_DIRECTORY/6
+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), GIT_WORK_TREE=wt in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+../../.git
+$TRASH_DIRECTORY/6/wt
+$TRASH_DIRECTORY/6/sub/sub
+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), GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+../../.git
+$TRASH_DIRECTORY/6/wt
+$TRASH_DIRECTORY/6/sub/sub
+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, GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6/wt
+$TRASH_DIRECTORY/6/sub/sub
+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, GIT_WORK_TREE=wt in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6/wt
+$TRASH_DIRECTORY/6/sub/sub
+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_failure '#6: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
+	cat >6/expected <<EOF &&
+6/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+6/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR=.git test_repo 6
+'
+
+test_expect_failure '#6: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
+	cat >6/expected <<EOF &&
+6/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+6/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../../ &&
+	GIT_DIR=.git test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
+	cat >6/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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, GIT_WORK_TREE=.. at root' '
+	cat >6/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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), GIT_WORK_TREE=.. in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+6/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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), GIT_WORK_TREE=..(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+6/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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, GIT_WORK_TREE=..(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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, GIT_WORK_TREE=.. in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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
Signature · 1 line
1.7.0.2.445.gcbdb3
#14 lore raw

PATCH 10/18 t1510: setup case #7

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |  261 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 261 insertions(+), 0 deletions(-)
t/t1510-repo-setup.sh +261 -0
index 7e902b0..2f36bfe 100755
@@ -1002,4 +1002,265 @@ 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, so this is the same as
+# case #3.
+#
+#  - worktree is at $GIT_WORK_TREE
+#  - cwd is at worktree root
+#  - prefix is calculated
+#  - git_dir is at $GIT_DIR
+#  - cwd can be outside worktree
+
+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 at root' '
+	cat >7/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/7
+$TRASH_DIRECTORY/7
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/7" test_repo 7
+'
+
+test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE(rel) at root' '
+	cat >7/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/7
+$TRASH_DIRECTORY/7
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=. test_repo 7
+'
+
+test_expect_success '#7: GIT_DIR, GIT_WORK_TREE at root' '
+	cat >7/expected <<EOF &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY/7
+$TRASH_DIRECTORY/7
+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(rel) at root' '
+	cat >7/expected <<EOF &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY/7
+$TRASH_DIRECTORY/7
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/7/.git" GIT_WORK_TREE=. test_repo 7
+'
+
+test_expect_success '#7: GIT_DIR(rel), GIT_WORKTREE in subdir' '
+	cat >7/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY/7
+$TRASH_DIRECTORY/7
+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(rel) in subdir' '
+	cat >7/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY/7
+$TRASH_DIRECTORY/7
+sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../.. test_repo 7/sub/sub
+'
+
+test_expect_success '#7: GIT_DIR, GIT_WORKTREE in subdir' '
+	cat >7/sub/expected <<EOF &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY/7
+$TRASH_DIRECTORY/7
+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(rel) in subdir' '
+	cat >7/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY/7
+$TRASH_DIRECTORY/7
+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 &&
+.git
+$TRASH_DIRECTORY/7/wt
+$TRASH_DIRECTORY/7
+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 &&
+.git
+$TRASH_DIRECTORY/7/wt
+$TRASH_DIRECTORY/7
+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 &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY/7/wt
+$TRASH_DIRECTORY/7
+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 &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY/7/wt
+$TRASH_DIRECTORY/7
+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 &&
+../../.git
+$TRASH_DIRECTORY/7/wt
+$TRASH_DIRECTORY/7/sub/sub
+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 &&
+../../.git
+$TRASH_DIRECTORY/7/wt
+$TRASH_DIRECTORY/7/sub/sub
+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 &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY/7/wt
+$TRASH_DIRECTORY/7/sub/sub
+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 &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY/7/wt
+$TRASH_DIRECTORY/7/sub/sub
+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 &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/7/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+7/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/7/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 7/sub/sub
+'
+
 test_done
Signature · 1 line
1.7.0.2.445.gcbdb3
#15 lore raw

PATCH 11/18 t1510: setup case #8

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |   52 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)
t/t1510-repo-setup.sh +52 -0
index 2f36bfe..c77c245 100755
@@ -1263,4 +1263,56 @@ 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:
+#
+# same as case #1 except that git_dir is set by .git file
+#
+#  - worktree is at .git file's parent directory
+#  - cwd is at worktree root
+#  - prefix is calculated
+#  - git_dir is set to where .git points to
+#  - cwd can't be outside worktree
+
+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 &&
+$TRASH_DIRECTORY/8.git
+$TRASH_DIRECTORY/8
+$TRASH_DIRECTORY/8
+EOF
+	test_repo 8
+'
+
+test_expect_success '#8: in subdir' '
+	cat >8/sub/expected <<EOF &&
+$TRASH_DIRECTORY/8.git
+$TRASH_DIRECTORY/8
+$TRASH_DIRECTORY/8
+sub/
+EOF
+	test_repo 8/sub
+'
+
 test_done
Signature · 1 line
1.7.0.2.445.gcbdb3
#16 lore raw

PATCH 12/18 t1510: setup case #9

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)
t/t1510-repo-setup.sh +48 -0
index c77c245..c516155 100755
@@ -1315,4 +1315,52 @@ 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:
+#
+# same as case #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 ..
+'
+
+# FIXME: check for warning that GIT_WORK_TREE is ignored
+test_expect_failure '#9: at root' '
+	cat >9/expected <<EOF &&
+$TRASH_DIRECTORY/9.git
+$TRASH_DIRECTORY/9
+$TRASH_DIRECTORY/9
+EOF
+	GIT_WORK_TREE=non-existent test_repo 9
+'
+
+# FIXME: check for warning that GIT_WORK_TREE is ignored
+test_expect_failure '#9: in subdir' '
+	cat >9/sub/expected <<EOF &&
+$TRASH_DIRECTORY/9.git
+$TRASH_DIRECTORY/9
+$TRASH_DIRECTORY/9
+sub/
+EOF
+	GIT_WORK_TREE=non-existent test_repo 9/sub
+'
+
 test_done
Signature · 1 line
1.7.0.2.445.gcbdb3
#17 lore raw

PATCH 13/18 t1510: setup case #10

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |   63 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 63 insertions(+), 0 deletions(-)
t/t1510-repo-setup.sh +63 -0
index c516155..31bacd7 100755
@@ -1363,4 +1363,67 @@ 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:
+#
+# same as case #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 &&
+$TRASH_DIRECTORY/10.git
+$TRASH_DIRECTORY/10
+$TRASH_DIRECTORY/10
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/10/.git" test_repo 10
+'
+
+test_expect_failure '#10: in subdir' '
+	cat >10/sub/expected <<EOF &&
+$TRASH_DIRECTORY/10.git
+$TRASH_DIRECTORY/10/sub
+$TRASH_DIRECTORY/10/sub
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/10/.git" test_repo 10/sub
+'
+
+test_expect_failure '#10: relative GIT_DIR at root' '
+	cat >10/expected <<EOF &&
+$TRASH_DIRECTORY/10.git
+$TRASH_DIRECTORY/10
+$TRASH_DIRECTORY/10
+EOF
+	GIT_DIR=.git test_repo 10
+'
+
+test_expect_failure '#10: relative GIT_DIR in subdir' '
+	cat >10/sub/expected <<EOF &&
+$TRASH_DIRECTORY/10.git
+$TRASH_DIRECTORY/10/sub
+$TRASH_DIRECTORY/10/sub
+EOF
+	GIT_DIR=../.git test_repo 10/sub
+'
+
 test_done
Signature · 1 line
1.7.0.2.445.gcbdb3
#18 lore raw

PATCH 14/18 t1510: setup case #11

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |  255 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 255 insertions(+), 0 deletions(-)
t/t1510-repo-setup.sh +255 -0
index 31bacd7..f8ab969 100755
@@ -1426,4 +1426,259 @@ 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:
+#
+# same as case #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 at root' '
+	cat >11/expected <<EOF &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY/11
+$TRASH_DIRECTORY/11
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/11" test_repo 11
+'
+
+test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE(rel) at root' '
+	cat >11/expected <<EOF &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY/11
+$TRASH_DIRECTORY/11
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=. test_repo 11
+'
+
+test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE at root' '
+	cat >11/expected <<EOF &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY/11
+$TRASH_DIRECTORY/11
+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(rel) at root' '
+	cat >11/expected <<EOF &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY/11
+$TRASH_DIRECTORY/11
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/11/.git" GIT_WORK_TREE=. test_repo 11
+'
+
+test_expect_failure '#11: GIT_DIR(rel), GIT_WORKTREE in subdir' '
+	cat >11/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY/11
+$TRASH_DIRECTORY/11
+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(rel) in subdir' '
+	cat >11/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY/11
+$TRASH_DIRECTORY/11
+sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../.. test_repo 11/sub/sub
+'
+
+test_expect_failure '#11: GIT_DIR, GIT_WORKTREE in subdir' '
+	cat >11/sub/expected <<EOF &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY/11
+$TRASH_DIRECTORY/11
+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(rel) in subdir' '
+	cat >11/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY/11
+$TRASH_DIRECTORY/11
+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 &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY/11/wt
+$TRASH_DIRECTORY/11
+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 &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY/11/wt
+$TRASH_DIRECTORY/11
+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 &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY/11/wt
+$TRASH_DIRECTORY/11
+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 &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY/11/wt
+$TRASH_DIRECTORY/11
+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 &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY/11/wt
+$TRASH_DIRECTORY/11/sub/sub
+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 &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY/11/wt
+$TRASH_DIRECTORY/11/sub/sub
+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 &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY/11/wt
+$TRASH_DIRECTORY/11/sub/sub
+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 &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY/11/wt
+$TRASH_DIRECTORY/11/sub/sub
+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 &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/11/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/11.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+11/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/11/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 11/sub/sub
+'
+
 test_done
Signature · 1 line
1.7.0.2.445.gcbdb3
#19 lore raw

PATCH 15/18 t1510: setup case #12

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |  132 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 132 insertions(+), 0 deletions(-)
t/t1510-repo-setup.sh +132 -0
index f8ab969..1516ff6 100755
@@ -1681,4 +1681,136 @@ 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:
+#
+# same as case #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 &&
+	mv .git ../12.git &&
+	echo gitdir: ../12.git >.git &&
+	cd ..
+'
+
+test_expect_failure '#12: core.worktree(rel), at root' '
+	cat >12/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY/12
+$TRASH_DIRECTORY/12
+EOF
+	git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree .. &&
+	test_repo 12
+'
+
+test_expect_success '#12: core.worktree, at root' '
+	cat >12/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY/12
+$TRASH_DIRECTORY/12
+EOF
+	git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree "$TRASH_DIRECTORY/12" &&
+	test_repo 12
+'
+
+test_expect_failure '#12: core.worktree(rel), in subdir' '
+	cat >12/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY/12
+$TRASH_DIRECTORY/12
+sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree .. &&
+	test_repo 12/sub/sub
+'
+
+test_expect_success '#12: core.worktree, in subdir' '
+	cat >12/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY/12
+$TRASH_DIRECTORY/12
+sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree "$TRASH_DIRECTORY/12" &&
+	test_repo 12/sub/sub
+'
+
+test_expect_failure '#12: core.worktree=wt(rel), at root' '
+	cat >12/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY/12/wt
+$TRASH_DIRECTORY/12
+EOF
+	git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree ../wt &&
+	test_repo 12
+'
+
+test_expect_success '#12: core.worktree=wt, at root' '
+	cat >12/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY/12/wt
+$TRASH_DIRECTORY/12
+EOF
+	git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree "$TRASH_DIRECTORY/12/wt" &&
+	test_repo 12
+'
+
+test_expect_failure '#12: core.worktree=wt(rel), in subdir' '
+	cat >12/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY/12/wt
+$TRASH_DIRECTORY/12/sub/sub
+EOF
+	git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree ../wt &&
+	test_repo 12/sub/sub
+'
+
+test_expect_success '#12: core.worktree=wt, in subdir' '
+	cat >12/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY/12/wt
+$TRASH_DIRECTORY/12/sub/sub
+EOF
+	git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree "$TRASH_DIRECTORY/12/wt" &&
+	test_repo 12/sub/sub
+'
+
+test_expect_failure '#12: core.worktree=..(rel), at root' '
+	cat >12/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+12/
+EOF
+	git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree ../.. &&
+	test_repo 12
+'
+
+test_expect_failure '#12: core.worktree=.., at root' '
+	cat >12/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+12/
+EOF
+	git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree "$TRASH_DIRECTORY/12" &&
+	test_repo 12
+'
+
 test_done
Signature · 1 line
1.7.0.2.445.gcbdb3
#20 lore raw

PATCH 16/18 t1510: setup case #13

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |  132 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 132 insertions(+), 0 deletions(-)
t/t1510-repo-setup.sh +132 -0
index 1516ff6..2a69a78 100755
@@ -1813,4 +1813,136 @@ EOF
 	test_repo 12
 '
 
+#
+# 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:
+#
+# same as case #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 &&
+	mv .git ../13.git &&
+	echo gitdir: ../13.git >.git &&
+	cd .. &&
+	export GIT_WORK_TREE=non-existent
+'
+
+test_expect_failure '#13: core.worktree(rel), at root' '
+	cat >13/expected <<EOF &&
+$TRASH_DIRECTORY/13.git
+$TRASH_DIRECTORY/13
+$TRASH_DIRECTORY/13
+EOF
+	git config --file="$TRASH_DIRECTORY/13.git/config" core.worktree .. &&
+	test_repo 13
+'
+
+test_expect_failure '#13: core.worktree, at root' '
+	cat >13/expected <<EOF &&
+$TRASH_DIRECTORY/13.git
+$TRASH_DIRECTORY/13
+$TRASH_DIRECTORY/13
+EOF
+	git config --file="$TRASH_DIRECTORY/13.git/config" core.worktree "$TRASH_DIRECTORY/13" &&
+	test_repo 13
+'
+
+test_expect_failure '#13: core.worktree(rel), in subdir' '
+	cat >13/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/13.git
+$TRASH_DIRECTORY/13
+$TRASH_DIRECTORY/13
+sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/13.git/config" core.worktree .. &&
+	test_repo 13/sub/sub
+'
+
+test_expect_failure '#13: core.worktree, in subdir' '
+	cat >13/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/13.git
+$TRASH_DIRECTORY/13
+$TRASH_DIRECTORY/13
+sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/13.git/config" core.worktree "$TRASH_DIRECTORY/13" &&
+	test_repo 13/sub/sub
+'
+
+test_expect_failure '#13: core.worktree=wt(rel), at root' '
+	cat >13/expected <<EOF &&
+$TRASH_DIRECTORY/13.git
+$TRASH_DIRECTORY/13/wt
+$TRASH_DIRECTORY/13
+EOF
+	git config --file="$TRASH_DIRECTORY/13.git/config" core.worktree ../wt &&
+	test_repo 13
+'
+
+test_expect_failure '#13: core.worktree=wt, at root' '
+	cat >13/expected <<EOF &&
+$TRASH_DIRECTORY/13.git
+$TRASH_DIRECTORY/13/wt
+$TRASH_DIRECTORY/13
+EOF
+	git config --file="$TRASH_DIRECTORY/13.git/config" core.worktree "$TRASH_DIRECTORY/13/wt" &&
+	test_repo 13
+'
+
+test_expect_failure '#13: core.worktree=wt(rel), in subdir' '
+	cat >13/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/13.git
+$TRASH_DIRECTORY/13/wt
+$TRASH_DIRECTORY/13/sub/sub
+EOF
+	git config --file="$TRASH_DIRECTORY/13.git/config" core.worktree ../wt &&
+	test_repo 13/sub/sub
+'
+
+test_expect_failure '#13: core.worktree=wt, in subdir' '
+	cat >13/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/13.git
+$TRASH_DIRECTORY/13/wt
+$TRASH_DIRECTORY/13/sub/sub
+EOF
+	git config --file="$TRASH_DIRECTORY/13.git/config" core.worktree "$TRASH_DIRECTORY/13/wt" &&
+	test_repo 13/sub/sub
+'
+
+test_expect_failure '#13: core.worktree=..(rel), at root' '
+	cat >13/expected <<EOF &&
+$TRASH_DIRECTORY/13.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+13/
+EOF
+	git config --file="$TRASH_DIRECTORY/13.git/config" core.worktree ../.. &&
+	test_repo 13
+'
+
+test_expect_failure '#13: core.worktree=.., at root' '
+	cat >13/expected <<EOF &&
+$TRASH_DIRECTORY/13.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+13/
+EOF
+	git config --file="$TRASH_DIRECTORY/13.git/config" core.worktree "$TRASH_DIRECTORY/13" &&
+	test_repo 13
+'
+
 test_done
Signature · 1 line
1.7.0.2.445.gcbdb3
#21 lore raw

PATCH 17/18 t1510: setup case #14

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |  279 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 279 insertions(+), 0 deletions(-)
t/t1510-repo-setup.sh +279 -0
index 2a69a78..5c1b96e 100755
@@ -1945,4 +1945,283 @@ EOF
 	test_repo 13
 '
 
+#
+# 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:
+#
+# same as case #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), GIT_WORK_TREE at root' '
+	cat >14/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/14
+$TRASH_DIRECTORY/14
+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), GIT_WORK_TREE(rel) at root' '
+	cat >14/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/14
+$TRASH_DIRECTORY/14
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
+	GIT_DIR=.git test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR, GIT_WORK_TREE at root' '
+	cat >14/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14
+$TRASH_DIRECTORY/14
+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, GIT_WORK_TREE(rel) at root' '
+	cat >14/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14
+$TRASH_DIRECTORY/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(rel), GIT_WORKTREE in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14
+$TRASH_DIRECTORY/14
+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), GIT_WORKTREE(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14
+$TRASH_DIRECTORY/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, GIT_WORKTREE in subdir' '
+	cat >14/sub/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14
+$TRASH_DIRECTORY/14
+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, GIT_WORKTREE(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14
+$TRASH_DIRECTORY/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(rel), GIT_WORK_TREE=wt at root' '
+	cat >14/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/14/wt
+$TRASH_DIRECTORY/14
+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), GIT_WORK_TREE=wt(rel) at root' '
+	cat >14/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/14/wt
+$TRASH_DIRECTORY/14
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../wt &&
+	GIT_DIR=.git test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
+	cat >14/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14/wt
+$TRASH_DIRECTORY/14
+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, GIT_WORK_TREE=wt at root' '
+	cat >14/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14/wt
+$TRASH_DIRECTORY/14
+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), GIT_WORK_TREE=wt in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+../../.git
+$TRASH_DIRECTORY/14/wt
+$TRASH_DIRECTORY/14/sub/sub
+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), GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+../../.git
+$TRASH_DIRECTORY/14/wt
+$TRASH_DIRECTORY/14/sub/sub
+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, GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14/wt
+$TRASH_DIRECTORY/14/sub/sub
+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, GIT_WORK_TREE=wt in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14/wt
+$TRASH_DIRECTORY/14/sub/sub
+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), GIT_WORK_TREE=.. at root' '
+	cat >14/expected <<EOF &&
+14/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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), GIT_WORK_TREE=..(rel) at root' '
+	cat >14/expected <<EOF &&
+14/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+14/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../../ &&
+	GIT_DIR=.git test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
+	cat >14/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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, GIT_WORK_TREE=.. at root' '
+	cat >14/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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), GIT_WORK_TREE=.. in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+14/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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), GIT_WORK_TREE=..(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+14/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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, GIT_WORK_TREE=..(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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, GIT_WORK_TREE=.. in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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
Signature · 1 line
1.7.0.2.445.gcbdb3
#22 lore raw

PATCH 18/18 t1510: setup case #15

In reply to Nguyễn Thái Ngọc Duy
---
 t/t1510-repo-setup.sh |  256 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 256 insertions(+), 0 deletions(-)
t/t1510-repo-setup.sh +256 -0
index 5c1b96e..f412890 100755
@@ -2224,4 +2224,260 @@ 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:
+#
+# same as case #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 at root' '
+	cat >15/expected <<EOF &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY/15
+$TRASH_DIRECTORY/15
+EOF
+	GIT_DIR=.git GIT_WORK_TREE="$TRASH_DIRECTORY/15" test_repo 15
+'
+
+test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE(rel) at root' '
+	cat >15/expected <<EOF &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY/15
+$TRASH_DIRECTORY/15
+EOF
+	GIT_DIR=.git GIT_WORK_TREE=. test_repo 15
+'
+
+test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE at root' '
+	cat >15/expected <<EOF &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY/15
+$TRASH_DIRECTORY/15
+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(rel) at root' '
+	cat >15/expected <<EOF &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY/15
+$TRASH_DIRECTORY/15
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/15/.git" GIT_WORK_TREE=. test_repo 15
+'
+
+test_expect_failure '#15: GIT_DIR(rel), GIT_WORKTREE in subdir' '
+	cat >15/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY/15
+$TRASH_DIRECTORY/15
+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(rel) in subdir' '
+	cat >15/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY/15
+$TRASH_DIRECTORY/15
+sub/sub/
+EOF
+	GIT_DIR=../../.git GIT_WORK_TREE=../.. test_repo 15/sub/sub
+'
+
+test_expect_failure '#15: GIT_DIR, GIT_WORKTREE in subdir' '
+	cat >15/sub/expected <<EOF &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY/15
+$TRASH_DIRECTORY/15
+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(rel) in subdir' '
+	cat >15/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY/15
+$TRASH_DIRECTORY/15
+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 &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY/15/wt
+$TRASH_DIRECTORY/15
+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 &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY/15/wt
+$TRASH_DIRECTORY/15
+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 &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY/15/wt
+$TRASH_DIRECTORY/15
+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 &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY/15/wt
+$TRASH_DIRECTORY/15
+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 &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY/15/wt
+$TRASH_DIRECTORY/15/sub/sub
+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 &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY/15/wt
+$TRASH_DIRECTORY/15/sub/sub
+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 &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY/15/wt
+$TRASH_DIRECTORY/15/sub/sub
+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 &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY/15/wt
+$TRASH_DIRECTORY/15/sub/sub
+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 &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+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 &&
+$TRASH_DIRECTORY/15.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+15/sub/sub/
+EOF
+	GIT_DIR="$TRASH_DIRECTORY/15/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 15/sub/sub
+'
+
 test_done
Signature · 1 line
1.7.0.2.445.gcbdb3