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 update-index nonsense-path test. |
Junio C Hamano | 368f99d | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 7 | |
| 8 | This test creates the following structure in the cache: |
| 9 | |
| 10 | path0 - a file |
| 11 | path1 - a symlink |
| 12 | path2/file2 - a file in a directory |
| 13 | path3/file3 - a file in a directory |
| 14 | |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 15 | and tries to git update-index --add the following: |
Junio C Hamano | 368f99d | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 16 | |
| 17 | path0/file0 - a file in a directory |
| 18 | path1/file1 - a file in a directory |
| 19 | path2 - a file |
| 20 | path3 - a symlink |
| 21 | |
| 22 | All of the attempts should fail. |
| 23 | ' |
| 24 | |
| 25 | . ./test-lib.sh |
| 26 | |
| 27 | mkdir path2 path3 |
| 28 | date >path0 |
Johannes Sixt | 704a314 | 2009-03-04 22:38:24 +0100 | [diff] [blame] | 29 | if test_have_prereq SYMLINKS |
| 30 | then |
| 31 | ln -s xyzzy path1 |
| 32 | else |
| 33 | date > path1 |
| 34 | fi |
Junio C Hamano | 368f99d | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 35 | date >path2/file2 |
| 36 | date >path3/file3 |
| 37 | |
| 38 | test_expect_success \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 39 | 'git update-index --add to add various paths.' \ |
| 40 | 'git update-index --add -- path0 path1 path2/file2 path3/file3' |
Junio C Hamano | 368f99d | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 41 | |
| 42 | rm -fr path? |
| 43 | |
| 44 | mkdir path0 path1 |
| 45 | date >path2 |
Johannes Sixt | 704a314 | 2009-03-04 22:38:24 +0100 | [diff] [blame] | 46 | if test_have_prereq SYMLINKS |
| 47 | then |
| 48 | ln -s frotz path3 |
| 49 | else |
| 50 | date > path3 |
| 51 | fi |
Junio C Hamano | 368f99d | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 52 | date >path0/file0 |
| 53 | date >path1/file1 |
| 54 | |
| 55 | for p in path0/file0 path1/file1 path2 path3 |
| 56 | do |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 57 | test_expect_success \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 58 | "git update-index to add conflicting path $p should fail." \ |
Stephan Beyer | d492b31 | 2008-07-12 17:47:52 +0200 | [diff] [blame] | 59 | "test_must_fail git update-index --add -- $p" |
Junio C Hamano | 368f99d | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 60 | done |
| 61 | test_done |