summaryrefslogtreecommitdiff
path: root/t/t2000-checkout-cache-clash.sh
blob: 5141fab7cf567fc5d16a8e9a296d2aff5f6c67e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
#
# Copyright (c) 2005 Junio C Hamano
#

test_description='git checkout-index test.

This test registers the following filesystem structure in the
cache:

    path0       - a file
    path1/file1 - a file in a directory

And then tries to checkout in a work tree that has the following:

    path0/file0 - a file in a directory
    path1       - a file

The git checkout-index command should fail when attempting to checkout
path0, finding it is occupied by a directory, and path1/file1, finding
path1 is occupied by a non-directory.  With "-f" flag, it should remove
the conflicting paths and succeed.
'
. ./test-lib.sh

date >path0
mkdir path1
date >path1/file1

test_expect_success \
    'git update-index --add various paths.' \
    'git update-index --add path0 path1/file1'

rm -fr path0 path1
mkdir path0
date >path0/file0
date >path1

test_expect_success \
    'git checkout-index without -f should fail on conflicting work tree.' \
    '! git checkout-index -a'

test_expect_success \
    'git checkout-index with -f should succeed.' \
    'git checkout-index -f -a'

test_expect_success \
    'git checkout-index conflicting paths.' \
    'test -f path0 && test -d path1 && test -f path1/file1'

test_done