Johannes Sixt | 2fe26b7 | 2011-02-05 19:18:44 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='checkout must not overwrite an untracked objects' |
| 4 | . ./test-lib.sh |
| 5 | |
| 6 | test_expect_success 'setup' ' |
| 7 | |
| 8 | mkdir -p a/b/c && |
| 9 | >a/b/c/d && |
| 10 | git add -A && |
| 11 | git commit -m base && |
| 12 | git tag start |
| 13 | ' |
| 14 | |
| 15 | test_expect_success 'create a commit where dir a/b changed to file' ' |
| 16 | |
| 17 | git checkout -b file && |
| 18 | rm -rf a/b && |
| 19 | >a/b && |
| 20 | git add -A && |
| 21 | git commit -m "dir to file" |
| 22 | ' |
| 23 | |
| 24 | test_expect_success 'checkout commit with dir must not remove untracked a/b' ' |
| 25 | |
| 26 | git rm --cached a/b && |
| 27 | git commit -m "un-track the file" && |
| 28 | test_must_fail git checkout start && |
| 29 | test -f a/b |
| 30 | ' |
| 31 | |
Johannes Sixt | 889c6f0 | 2013-06-07 22:53:28 +0200 | [diff] [blame] | 32 | test_expect_success 'create a commit where dir a/b changed to symlink' ' |
Johannes Sixt | 2fe26b7 | 2011-02-05 19:18:44 +0100 | [diff] [blame] | 33 | |
| 34 | rm -rf a/b && # cleanup if previous test failed |
| 35 | git checkout -f -b symlink start && |
| 36 | rm -rf a/b && |
Johannes Sixt | 2fe26b7 | 2011-02-05 19:18:44 +0100 | [diff] [blame] | 37 | git add -A && |
Johannes Sixt | 889c6f0 | 2013-06-07 22:53:28 +0200 | [diff] [blame] | 38 | test_ln_s_add foo a/b && |
Johannes Sixt | 2fe26b7 | 2011-02-05 19:18:44 +0100 | [diff] [blame] | 39 | git commit -m "dir to symlink" |
| 40 | ' |
| 41 | |
Johannes Sixt | 889c6f0 | 2013-06-07 22:53:28 +0200 | [diff] [blame] | 42 | test_expect_success 'checkout commit with dir must not remove untracked a/b' ' |
Johannes Sixt | 2fe26b7 | 2011-02-05 19:18:44 +0100 | [diff] [blame] | 43 | |
| 44 | git rm --cached a/b && |
| 45 | git commit -m "un-track the symlink" && |
Johannes Sixt | 889c6f0 | 2013-06-07 22:53:28 +0200 | [diff] [blame] | 46 | test_must_fail git checkout start |
| 47 | ' |
| 48 | |
| 49 | test_expect_success SYMLINKS 'the symlink remained' ' |
| 50 | |
Johannes Sixt | 2fe26b7 | 2011-02-05 19:18:44 +0100 | [diff] [blame] | 51 | test -h a/b |
| 52 | ' |
| 53 | |
| 54 | test_done |