Junio C Hamano | 368f99d | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2005 Junio C Hamano |
| 4 | # |
| 5 | |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 6 | test_description='git checkout-index test. |
Junio C Hamano | 368f99d | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 7 | |
| 8 | This test registers the following filesystem structure in the |
| 9 | cache: |
| 10 | |
| 11 | path0 - a file |
| 12 | path1/file1 - a file in a directory |
| 13 | |
| 14 | And 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 Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 19 | The git checkout-index command should fail when attempting to checkout |
Junio C Hamano | 368f99d | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 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. |
| 23 | ' |
| 24 | . ./test-lib.sh |
| 25 | |
| 26 | date >path0 |
| 27 | mkdir path1 |
| 28 | date >path1/file1 |
| 29 | |
| 30 | test_expect_success \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 31 | 'git update-index --add various paths.' \ |
| 32 | 'git update-index --add path0 path1/file1' |
Junio C Hamano | 368f99d | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 33 | |
| 34 | rm -fr path0 path1 |
| 35 | mkdir path0 |
| 36 | date >path0/file0 |
| 37 | date >path1 |
| 38 | |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 39 | test_expect_success \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 40 | 'git checkout-index without -f should fail on conflicting work tree.' \ |
Stephan Beyer | d492b31 | 2008-07-12 17:47:52 +0200 | [diff] [blame] | 41 | 'test_must_fail git checkout-index -a' |
Junio C Hamano | 368f99d | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 42 | |
| 43 | test_expect_success \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 44 | 'git checkout-index with -f should succeed.' \ |
| 45 | 'git checkout-index -f -a' |
Junio C Hamano | 368f99d | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 46 | |
Junio C Hamano | 886856a | 2005-05-14 00:24:27 -0700 | [diff] [blame] | 47 | test_expect_success \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 48 | 'git checkout-index conflicting paths.' \ |
Junio C Hamano | 886856a | 2005-05-14 00:24:27 -0700 | [diff] [blame] | 49 | 'test -f path0 && test -d path1 && test -f path1/file1' |
Junio C Hamano | 368f99d | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 50 | |
Junio C Hamano | da02ca5 | 2009-08-16 23:53:12 -0700 | [diff] [blame] | 51 | test_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 Hamano | 368f99d | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 60 | test_done |