t1510: setup case #17
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Nov 26, 2010 at 22:32 UTC
cf83243b0b8a8c444c03b37286b4498ec78f5666
1 file changed
+129
t/t1510-repo-setup.sh
+129
@@ -2360,4 +2360,133 @@ EOF
2360
test_repo 16/sub
2361
'
2362
2363
+#
2364
+# case #17.1
2365
+#
2366
+############################################################
2367
+#
2368
+# Input:
2369
+#
2370
+# - GIT_WORK_TREE is set
2371
+# - GIT_DIR is not set
2372
+# - core.worktree is not set
2373
+# - .git is a directory
2374
+# - cwd is inside .git
2375
+#
2376
+# Output:
2377
+#
2378
+# GIT_WORK_TREE is ignored -> #16.1 (with warnings perhaps)
2379
+
2380
+test_expect_success '#17.1: setup' '
2381
+ unset GIT_DIR GIT_WORK_TREE &&
2382
+ mkdir 17 17/sub &&
2383
+ cd 17 &&
2384
+ git init &&
2385
+ mkdir .git/wt .git/wt/sub &&
2386
+ GIT_WORK_TREE=non-existent &&
2387
+ export GIT_WORK_TREE &&
2388
+ cd ..
2389
+'
2390
+
2391
+test_expect_failure '#17.1: at .git' '
2392
+ cat >17/.git/expected <<EOF &&
2393
+setup: git_dir: .
2394
+setup: worktree: (null)
2395
+setup: cwd: $TRASH_DIRECTORY/17/.git
2396
+setup: prefix: (null)
2397
+EOF
2398
+ test_repo 17/.git
2399
+'
2400
+
2401
+test_expect_failure '#17.1: in .git/wt' '
2402
+ cat >17/.git/wt/expected <<EOF &&
2403
+setup: git_dir: $TRASH_DIRECTORY/17/.git
2404
+setup: worktree: (null)
2405
+setup: cwd: $TRASH_DIRECTORY/17/.git/wt
2406
+setup: prefix: (null)
2407
+EOF
2408
+ test_repo 17/.git/wt
2409
+'
2410
+
2411
+test_expect_failure '#17.1: in .git/wt/sub' '
2412
+ cat >17/.git/wt/sub/expected <<EOF &&
2413
+setup: git_dir: $TRASH_DIRECTORY/17/.git
2414
+setup: worktree: (null)
2415
+setup: cwd: $TRASH_DIRECTORY/17/.git/wt/sub
2416
+setup: prefix: (null)
2417
+EOF
2418
+ test_repo 17/.git/wt/sub
2419
+'
2420
+
2421
+#
2422
+# case #17.2
2423
+#
2424
+############################################################
2425
+#
2426
+# Input:
2427
+#
2428
+# - GIT_WORK_TREE is set
2429
+# - GIT_DIR is not set
2430
+# - core.worktree is not set
2431
+# - .git is a directory
2432
+# - core.bare is set
2433
+#
2434
+# Output:
2435
+#
2436
+# GIT_WORK_TREE is ignored -> #16.2 (with warnings perhaps)
2437
+
2438
+test_expect_success '#17.2: setup' '
2439
+ git config --file="$TRASH_DIRECTORY/17/.git/config" core.bare true
2440
+'
2441
+
2442
+test_expect_failure '#17.2: at .git' '
2443
+ cat >17/.git/expected <<EOF &&
2444
+setup: git_dir: .
2445
+setup: worktree: (null)
2446
+setup: cwd: $TRASH_DIRECTORY/17/.git
2447
+setup: prefix: (null)
2448
+EOF
2449
+ test_repo 17/.git
2450
+'
2451
+
2452
+test_expect_failure '#17.2: in .git/wt' '
2453
+ cat >17/.git/wt/expected <<EOF &&
2454
+setup: git_dir: $TRASH_DIRECTORY/17/.git
2455
+setup: worktree: (null)
2456
+setup: cwd: $TRASH_DIRECTORY/17/.git/wt
2457
+setup: prefix: (null)
2458
+EOF
2459
+ test_repo 17/.git/wt
2460
+'
2461
+
2462
+test_expect_failure '#17.2: in .git/wt/sub' '
2463
+ cat >17/.git/wt/sub/expected <<EOF &&
2464
+setup: git_dir: $TRASH_DIRECTORY/17/.git
2465
+setup: worktree: (null)
2466
+setup: cwd: $TRASH_DIRECTORY/17/.git/wt/sub
2467
+setup: prefix: (null)
2468
+EOF
2469
+ test_repo 17/.git/wt/sub
2470
+'
2471
+
2472
+test_expect_failure '#17.2: at root' '
2473
+ cat >17/expected <<EOF &&
2474
+setup: git_dir: .git
2475
+setup: worktree: (null)
2476
+setup: cwd: $TRASH_DIRECTORY/17
2477
+setup: prefix: (null)
2478
+EOF
2479
+ test_repo 17
2480
+'
2481
+
2482
+test_expect_failure '#17.2: in subdir' '
2483
+ cat >17/sub/expected <<EOF &&
2484
+setup: git_dir: $TRASH_DIRECTORY/17/.git
2485
+setup: worktree: (null)
2486
+setup: cwd: $TRASH_DIRECTORY/17/sub
2487
+setup: prefix: (null)
2488
+EOF
2489
+ test_repo 17/sub
2490
+'
2491
+
2492
test_done