]> git.ipfire.org Git - thirdparty/git.git/blame - t/t2000-checkout-cache-clash.sh
userdiff/perl: catch BEGIN/END/... and POD as headers
[thirdparty/git.git] / t / t2000-checkout-cache-clash.sh
CommitLineData
368f99d5
JH
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
5be60078 6test_description='git checkout-index test.
368f99d5
JH
7
8This test registers the following filesystem structure in the
9cache:
10
11 path0 - a file
12 path1/file1 - a file in a directory
13
14And then tries to checkout in a work tree that has the following:
15
16 path0/file0 - a file in a directory
17 path1 - a file
18
5be60078 19The git checkout-index command should fail when attempting to checkout
368f99d5
JH
20path0, finding it is occupied by a directory, and path1/file1, finding
21path1 is occupied by a non-directory. With "-f" flag, it should remove
22the conflicting paths and succeed.
23'
24. ./test-lib.sh
25
26date >path0
27mkdir path1
28date >path1/file1
29
30test_expect_success \
5be60078
JH
31 'git update-index --add various paths.' \
32 'git update-index --add path0 path1/file1'
368f99d5
JH
33
34rm -fr path0 path1
35mkdir path0
36date >path0/file0
37date >path1
38
41ac414e 39test_expect_success \
5be60078 40 'git checkout-index without -f should fail on conflicting work tree.' \
d492b31c 41 'test_must_fail git checkout-index -a'
368f99d5
JH
42
43test_expect_success \
5be60078
JH
44 'git checkout-index with -f should succeed.' \
45 'git checkout-index -f -a'
368f99d5 46
886856ab 47test_expect_success \
5be60078 48 'git checkout-index conflicting paths.' \
886856ab 49 'test -f path0 && test -d path1 && test -f path1/file1'
368f99d5 50
da02ca50
JH
51test_expect_success SYMLINKS 'checkout-index -f twice with --prefix' '
52 mkdir -p tar/get &&
53 ln -s tar/get there &&
54 echo first &&
55 git checkout-index -a -f --prefix=there/ &&
56 echo second &&
57 git checkout-index -a -f --prefix=there/
58'
59
368f99d5 60test_done