Thomas Gummerer | 091e04b | 2019-01-08 21:52:24 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='checkout --no-overlay <tree-ish> -- <pathspec>' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success 'setup' ' |
| 8 | git commit --allow-empty -m "initial" |
| 9 | ' |
| 10 | |
| 11 | test_expect_success 'checkout --no-overlay deletes files not in <tree-ish>' ' |
| 12 | >file && |
| 13 | mkdir dir && |
| 14 | >dir/file1 && |
| 15 | git add file dir/file1 && |
| 16 | git checkout --no-overlay HEAD -- file && |
| 17 | test_path_is_missing file && |
| 18 | test_path_is_file dir/file1 |
| 19 | ' |
| 20 | |
| 21 | test_expect_success 'checkout --no-overlay removing last file from directory' ' |
| 22 | git checkout --no-overlay HEAD -- dir/file1 && |
| 23 | test_path_is_missing dir |
| 24 | ' |
| 25 | |
| 26 | test_expect_success 'checkout -p --overlay is disallowed' ' |
| 27 | test_must_fail git checkout -p --overlay HEAD 2>actual && |
| 28 | test_i18ngrep "fatal: -p and --overlay are mutually exclusive" actual |
| 29 | ' |
| 30 | |
| 31 | test_expect_success '--no-overlay --theirs with D/F conflict deletes file' ' |
| 32 | test_commit file1 file1 && |
| 33 | test_commit file2 file2 && |
| 34 | git rm --cached file1 && |
| 35 | echo 1234 >file1 && |
| 36 | F1=$(git rev-parse HEAD:file1) && |
| 37 | F2=$(git rev-parse HEAD:file2) && |
| 38 | { |
| 39 | echo "100644 $F1 1 file1" && |
| 40 | echo "100644 $F2 2 file1" |
| 41 | } | git update-index --index-info && |
| 42 | test_path_is_file file1 && |
| 43 | git checkout --theirs --no-overlay -- file1 && |
| 44 | test_path_is_missing file1 |
| 45 | ' |
| 46 | |
René Scharfe | bfda204 | 2020-08-22 10:57:59 +0200 | [diff] [blame] | 47 | test_expect_success 'wildcard pathspec matches file in subdirectory' ' |
| 48 | git reset --hard && |
| 49 | mkdir subdir && |
| 50 | test_commit file3-1 subdir/file3 && |
| 51 | test_commit file3-2 subdir/file3 && |
| 52 | |
| 53 | git checkout --no-overlay file3-1 "*file3" && |
| 54 | echo file3-1 >expect && |
| 55 | test_path_is_file subdir/file3 && |
| 56 | test_cmp expect subdir/file3 |
| 57 | ' |
| 58 | |
Thomas Gummerer | 091e04b | 2019-01-08 21:52:24 +0000 | [diff] [blame] | 59 | test_done |