Use the available vsnprintf replacement instead of rolling our own.
[git/platforms/storm.git] / t / t2001-checkout-cache-clash.sh
blobc1e236e932b8a22c11b731c99b9cbfbdba237239
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='git checkout-index test.
8 This test registers the following filesystem structure in the cache:
10 path0/file0 - a file in a directory
11 path1/file1 - a file in a directory
13 and attempts to check it out when the work tree has:
15 path0/file0 - a file in a directory
16 path1 - a symlink pointing at "path0"
18 Checkout cache should fail to extract path1/file1 because the leading
19 path path1 is occupied by a non-directory. With "-f" it should remove
20 the symlink path1 and create directory path1 and file path1/file1.
22 . ./test-lib.sh
24 show_files() {
25 # show filesystem files, just [-dl] for type and name
26 find path? -ls |
27 sed -e 's/^[0-9]* * [0-9]* * \([-bcdl]\)[^ ]* *[0-9]* *[^ ]* *[^ ]* *[0-9]* [A-Z][a-z][a-z] [0-9][0-9] [^ ]* /fs: \1 /'
28 # what's in the cache, just mode and name
29 git ls-files --stage |
30 sed -e 's/^\([0-9]*\) [0-9a-f]* [0-3] /ca: \1 /'
31 # what's in the tree, just mode and name.
32 git ls-tree -r "$1" |
33 sed -e 's/^\([0-9]*\) [^ ]* [0-9a-f]* /tr: \1 /'
36 mkdir path0
37 date >path0/file0
38 test_expect_success \
39 'git update-index --add path0/file0' \
40 'git update-index --add path0/file0'
41 test_expect_success \
42 'writing tree out with git write-tree' \
43 'tree1=$(git write-tree)'
44 test_debug 'show_files $tree1'
46 mkdir path1
47 date >path1/file1
48 test_expect_success \
49 'git update-index --add path1/file1' \
50 'git update-index --add path1/file1'
51 test_expect_success \
52 'writing tree out with git write-tree' \
53 'tree2=$(git write-tree)'
54 test_debug 'show_files $tree2'
56 rm -fr path1
57 test_expect_success \
58 'read previously written tree and checkout.' \
59 'git read-tree -m $tree1 && git checkout-index -f -a'
60 test_debug 'show_files $tree1'
62 test "$no_symlinks" || {
63 ln -s path0 path1
64 test_expect_success \
65 'git update-index --add a symlink.' \
66 'git update-index --add path1'
68 test_expect_success \
69 'writing tree out with git write-tree' \
70 'tree3=$(git write-tree)'
71 test_debug 'show_files $tree3'
73 # Morten says "Got that?" here.
74 # Test begins.
76 test_expect_success \
77 'read previously written tree and checkout.' \
78 'git read-tree $tree2 && git checkout-index -f -a'
79 test_debug 'show_files $tree2'
81 test_expect_success \
82 'checking out conflicting path with -f' \
83 'test ! -h path0 && test -d path0 &&
84 test ! -h path1 && test -d path1 &&
85 test ! -h path0/file0 && test -f path0/file0 &&
86 test ! -h path1/file1 && test -f path1/file1'
88 test_done