Skip to content

Commit af62cc1

Browse files
pcloudsgitster
authored andcommitted
t1510: setup case #16
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f7c8588 commit af62cc1

File tree

1 file changed

+135
-0
lines changed

1 file changed

+135
-0
lines changed

t/t1510-repo-setup.sh

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2225,4 +2225,139 @@ EOF
22252225
test_repo 15/sub/sub "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY"
22262226
'
22272227

2228+
#
2229+
# case #16.1
2230+
#
2231+
############################################################
2232+
#
2233+
# Input:
2234+
#
2235+
# - GIT_WORK_TREE is not set
2236+
# - GIT_DIR is not set
2237+
# - core.worktree is not set
2238+
# - .git is a directory
2239+
# - cwd is inside .git
2240+
#
2241+
# Output:
2242+
#
2243+
# - no worktree
2244+
# - cwd is unchanged
2245+
# - prefix is NULL
2246+
# - git_dir is set
2247+
# - cwd can't be outside worktree
2248+
2249+
test_expect_success '#16.1: setup' '
2250+
unset GIT_DIR GIT_WORK_TREE &&
2251+
mkdir 16 16/sub &&
2252+
cd 16 &&
2253+
git init &&
2254+
mkdir .git/wt .git/wt/sub &&
2255+
cd ..
2256+
'
2257+
2258+
test_expect_success '#16.1: at .git' '
2259+
cat >16/.git/expected <<EOF &&
2260+
setup: git_dir: .
2261+
setup: worktree: (null)
2262+
setup: cwd: $TRASH_DIRECTORY/16/.git
2263+
setup: prefix: (null)
2264+
EOF
2265+
test_repo 16/.git
2266+
'
2267+
2268+
test_expect_success '#16.1: in .git/wt' '
2269+
cat >16/.git/wt/expected <<EOF &&
2270+
setup: git_dir: $TRASH_DIRECTORY/16/.git
2271+
setup: worktree: (null)
2272+
setup: cwd: $TRASH_DIRECTORY/16/.git/wt
2273+
setup: prefix: (null)
2274+
EOF
2275+
test_repo 16/.git/wt
2276+
'
2277+
2278+
test_expect_success '#16.1: in .git/wt/sub' '
2279+
cat >16/.git/wt/sub/expected <<EOF &&
2280+
setup: git_dir: $TRASH_DIRECTORY/16/.git
2281+
setup: worktree: (null)
2282+
setup: cwd: $TRASH_DIRECTORY/16/.git/wt/sub
2283+
setup: prefix: (null)
2284+
EOF
2285+
test_repo 16/.git/wt/sub
2286+
'
2287+
2288+
#
2289+
# case #16.2
2290+
#
2291+
############################################################
2292+
#
2293+
# Input:
2294+
#
2295+
# - GIT_WORK_TREE is not set
2296+
# - GIT_DIR is not set
2297+
# - core.worktree is not set
2298+
# - .git is a directory
2299+
# - core.bare is set
2300+
#
2301+
# Output:
2302+
#
2303+
# - no worktree
2304+
# - cwd is unchanged
2305+
# - prefix is NULL
2306+
# - git_dir is set
2307+
# - cwd can't be outside worktree
2308+
2309+
test_expect_success '#16.2: setup' '
2310+
git config --file="$TRASH_DIRECTORY/16/.git/config" core.bare true
2311+
'
2312+
2313+
test_expect_success '#16.2: at .git' '
2314+
cat >16/.git/expected <<EOF &&
2315+
setup: git_dir: .
2316+
setup: worktree: (null)
2317+
setup: cwd: $TRASH_DIRECTORY/16/.git
2318+
setup: prefix: (null)
2319+
EOF
2320+
test_repo 16/.git
2321+
'
2322+
2323+
test_expect_success '#16.2: in .git/wt' '
2324+
cat >16/.git/wt/expected <<EOF &&
2325+
setup: git_dir: $TRASH_DIRECTORY/16/.git
2326+
setup: worktree: (null)
2327+
setup: cwd: $TRASH_DIRECTORY/16/.git/wt
2328+
setup: prefix: (null)
2329+
EOF
2330+
test_repo 16/.git/wt
2331+
'
2332+
2333+
test_expect_success '#16.2: in .git/wt/sub' '
2334+
cat >16/.git/wt/sub/expected <<EOF &&
2335+
setup: git_dir: $TRASH_DIRECTORY/16/.git
2336+
setup: worktree: (null)
2337+
setup: cwd: $TRASH_DIRECTORY/16/.git/wt/sub
2338+
setup: prefix: (null)
2339+
EOF
2340+
test_repo 16/.git/wt/sub
2341+
'
2342+
2343+
test_expect_success '#16.2: at root' '
2344+
cat >16/expected <<EOF &&
2345+
setup: git_dir: .git
2346+
setup: worktree: (null)
2347+
setup: cwd: $TRASH_DIRECTORY/16
2348+
setup: prefix: (null)
2349+
EOF
2350+
test_repo 16
2351+
'
2352+
2353+
test_expect_failure '#16.2: in subdir' '
2354+
cat >16/sub/expected <<EOF &&
2355+
setup: git_dir: $TRASH_DIRECTORY/16/.git
2356+
setup: worktree: (null)
2357+
setup: cwd: $TRASH_DIRECTORY/16/sub
2358+
setup: prefix: (null)
2359+
EOF
2360+
test_repo 16/sub
2361+
'
2362+
22282363
test_done

0 commit comments

Comments
 (0)