[PATCH 2/2] The core GIT tests: recent additions and fixes.
[git/gitweb.git] / t / t1000-checkout-cache.sh
blobc10b6be0f9da4a706fbe05a31e9a494173699e60
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='git-checkout-cache test.
8 This test registers the following filesystem structure in the
9 cache:
11 path0 - a file
12 path1/file1 - a file in a directory
14 And then tries to checkout in a work tree that has the following:
16 path0/file0 - a file in a directory
17 path1 - a file
19 The git-checkout-cache command should fail when attempting to checkout
20 path0, finding it is occupied by a directory, and path1/file1, finding
21 path1 is occupied by a non-directory. With "-f" flag, it should remove
22 the conflicting paths and succeed.
24 . ./test-lib.sh
26 date >path0
27 mkdir path1
28 date >path1/file1
30 test_expect_success \
31 'git-update-cache --add various paths.' \
32 'git-update-cache --add path0 path1/file1'
34 rm -fr path0 path1
35 mkdir path0
36 date >path0/file0
37 date >path1
39 test_expect_failure \
40 'git-checkout-cache without -f should fail on conflicting work tree.' \
41 'git-checkout-cache -a'
43 test_expect_success \
44 'git-checkout-cache with -f should succeed.' \
45 'git-checkout-cache -f -a'
47 if test -f path0 && test -d path1 && test -f path1/file1
48 then
49 test_ok "checkout successful"
50 else
51 test_failure "checkout failed"
54 test_done