blob: de3edb5d571ea83263f5133e751704ab0ba580c8 [file] [log] [blame]
Junio C Hamano368f99d2005-05-13 22:52:42 -07001#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
Junio C Hamano5be60072007-07-02 22:52:14 -07006test_description='git checkout-index test.
Junio C Hamano368f99d2005-05-13 22:52:42 -07007
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
Junio C Hamano5be60072007-07-02 22:52:14 -070019The git checkout-index command should fail when attempting to checkout
Junio C Hamano368f99d2005-05-13 22:52:42 -070020path0, 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 \
Junio C Hamano5be60072007-07-02 22:52:14 -070031 'git update-index --add various paths.' \
32 'git update-index --add path0 path1/file1'
Junio C Hamano368f99d2005-05-13 22:52:42 -070033
34rm -fr path0 path1
35mkdir path0
36date >path0/file0
37date >path1
38
Junio C Hamano41ac4142008-02-01 01:50:53 -080039test_expect_success \
Junio C Hamano5be60072007-07-02 22:52:14 -070040 'git checkout-index without -f should fail on conflicting work tree.' \
Stephan Beyerd492b312008-07-12 17:47:52 +020041 'test_must_fail git checkout-index -a'
Junio C Hamano368f99d2005-05-13 22:52:42 -070042
43test_expect_success \
Junio C Hamano5be60072007-07-02 22:52:14 -070044 'git checkout-index with -f should succeed.' \
45 'git checkout-index -f -a'
Junio C Hamano368f99d2005-05-13 22:52:42 -070046
Junio C Hamano886856a2005-05-14 00:24:27 -070047test_expect_success \
Junio C Hamano5be60072007-07-02 22:52:14 -070048 'git checkout-index conflicting paths.' \
Junio C Hamano886856a2005-05-14 00:24:27 -070049 'test -f path0 && test -d path1 && test -f path1/file1'
Junio C Hamano368f99d2005-05-13 22:52:42 -070050
Junio C Hamanoda02ca52009-08-16 23:53:12 -070051test_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
Junio C Hamano368f99d2005-05-13 22:52:42 -070060test_done