Junio C Hamano | b039189 | 2005-09-19 15:11:15 -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 ls-files -k and -m flags test. |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 7 | |
| 8 | This test prepares the following 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 |
Junio C Hamano | 3c56875 | 2013-08-15 13:51:09 -0700 | [diff] [blame] | 14 | pathx/ju - a file in a directory |
Junio C Hamano | 26c986e | 2013-07-01 14:00:32 -0700 | [diff] [blame] | 15 | submod1/ - a submodule |
| 16 | submod2/ - another submodule |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 17 | |
| 18 | and the following on the filesystem: |
| 19 | |
| 20 | path0/file0 - a file in a directory |
| 21 | path1/file1 - a file in a directory |
| 22 | path2 - a file |
| 23 | path3 - a symlink |
| 24 | path4 - a file |
| 25 | path5 - a symlink |
| 26 | path6/file6 - a file in a directory |
Junio C Hamano | 3c56875 | 2013-08-15 13:51:09 -0700 | [diff] [blame] | 27 | pathx/ju/nk - a file in a directory to be killed |
Junio C Hamano | 26c986e | 2013-07-01 14:00:32 -0700 | [diff] [blame] | 28 | submod1/ - a submodule (modified from the cache) |
| 29 | submod2/ - a submodule (matches the cache) |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 30 | |
Junio C Hamano | 26c986e | 2013-07-01 14:00:32 -0700 | [diff] [blame] | 31 | git ls-files -k should report that existing filesystem objects |
| 32 | path0/*, path1/*, path2 and path3 to be killed. |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 33 | |
| 34 | Also for modification test, the cache and working tree have: |
| 35 | |
| 36 | path7 - an empty file, modified to a non-empty file. |
| 37 | path8 - a non-empty file, modified to an empty file. |
| 38 | path9 - an empty file, cache dirtied. |
| 39 | path10 - a non-empty file, cache dirtied. |
| 40 | |
| 41 | We should report path0, path1, path2/file2, path3/file3, path7 and path8 |
Junio C Hamano | 26c986e | 2013-07-01 14:00:32 -0700 | [diff] [blame] | 42 | modified without reporting path9 and path10. submod1 is also modified. |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 43 | ' |
Ævar Arnfjörð Bjarmason | 03267e8 | 2022-11-08 19:17:39 +0100 | [diff] [blame] | 44 | |
| 45 | TEST_PASSES_SANITIZE_LEAK=true |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 46 | . ./test-lib.sh |
| 47 | |
Johannes Sixt | cb64868 | 2013-06-07 22:53:26 +0200 | [diff] [blame] | 48 | test_expect_success 'git update-index --add to add various paths.' ' |
| 49 | date >path0 && |
Johannes Sixt | 889c6f0 | 2013-06-07 22:53:28 +0200 | [diff] [blame] | 50 | test_ln_s_add xyzzy path1 && |
Junio C Hamano | 4c4d9d9 | 2013-09-11 15:03:28 -0700 | [diff] [blame] | 51 | mkdir path2 path3 pathx && |
Johannes Sixt | cb64868 | 2013-06-07 22:53:26 +0200 | [diff] [blame] | 52 | date >path2/file2 && |
| 53 | date >path3/file3 && |
Junio C Hamano | 4c4d9d9 | 2013-09-11 15:03:28 -0700 | [diff] [blame] | 54 | >pathx/ju && |
Johannes Sixt | cb64868 | 2013-06-07 22:53:26 +0200 | [diff] [blame] | 55 | : >path7 && |
| 56 | date >path8 && |
| 57 | : >path9 && |
| 58 | date >path10 && |
Junio C Hamano | 4c4d9d9 | 2013-09-11 15:03:28 -0700 | [diff] [blame] | 59 | git update-index --add -- path0 path?/file? pathx/ju path7 path8 path9 path10 && |
Jeff King | e6821d0 | 2015-03-25 01:29:52 -0400 | [diff] [blame] | 60 | git init submod1 && |
| 61 | git -C submod1 commit --allow-empty -m "empty 1" && |
| 62 | git init submod2 && |
| 63 | git -C submod2 commit --allow-empty -m "empty 2" && |
Jeff King | 99094a7 | 2015-03-20 06:07:15 -0400 | [diff] [blame] | 64 | git update-index --add submod[12] && |
Junio C Hamano | 26c986e | 2013-07-01 14:00:32 -0700 | [diff] [blame] | 65 | ( |
| 66 | cd submod1 && |
| 67 | git commit --allow-empty -m "empty 1 (updated)" |
| 68 | ) && |
Johannes Sixt | cb64868 | 2013-06-07 22:53:26 +0200 | [diff] [blame] | 69 | rm -fr path? # leave path10 alone |
| 70 | ' |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 71 | |
Johannes Sixt | cb64868 | 2013-06-07 22:53:26 +0200 | [diff] [blame] | 72 | test_expect_success 'git ls-files -k to show killed files.' ' |
| 73 | date >path2 && |
| 74 | if test_have_prereq SYMLINKS |
| 75 | then |
| 76 | ln -s frotz path3 && |
| 77 | ln -s nitfol path5 |
| 78 | else |
| 79 | date >path3 && |
| 80 | date >path5 |
| 81 | fi && |
Junio C Hamano | 4c4d9d9 | 2013-09-11 15:03:28 -0700 | [diff] [blame] | 82 | mkdir -p path0 path1 path6 pathx/ju && |
Johannes Sixt | cb64868 | 2013-06-07 22:53:26 +0200 | [diff] [blame] | 83 | date >path0/file0 && |
| 84 | date >path1/file1 && |
| 85 | date >path6/file6 && |
| 86 | date >path7 && |
| 87 | : >path8 && |
| 88 | : >path9 && |
| 89 | touch path10 && |
Junio C Hamano | 4c4d9d9 | 2013-09-11 15:03:28 -0700 | [diff] [blame] | 90 | >pathx/ju/nk && |
| 91 | cat >.expected <<-\EOF |
Johannes Sixt | cb64868 | 2013-06-07 22:53:26 +0200 | [diff] [blame] | 92 | path0/file0 |
| 93 | path1/file1 |
| 94 | path2 |
| 95 | path3 |
Junio C Hamano | 4c4d9d9 | 2013-09-11 15:03:28 -0700 | [diff] [blame] | 96 | pathx/ju/nk |
Johannes Sixt | cb64868 | 2013-06-07 22:53:26 +0200 | [diff] [blame] | 97 | EOF |
Eric Sunshine | 680be04 | 2013-08-23 16:26:59 -0700 | [diff] [blame] | 98 | ' |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 99 | |
Junio C Hamano | 4c4d9d9 | 2013-09-11 15:03:28 -0700 | [diff] [blame] | 100 | test_expect_success 'git ls-files -k output (w/o icase)' ' |
Jeff King | 60687de | 2015-03-20 06:06:44 -0400 | [diff] [blame] | 101 | git ls-files -k >.output && |
Junio C Hamano | 4c4d9d9 | 2013-09-11 15:03:28 -0700 | [diff] [blame] | 102 | test_cmp .expected .output |
| 103 | ' |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 104 | |
Junio C Hamano | 4c4d9d9 | 2013-09-11 15:03:28 -0700 | [diff] [blame] | 105 | test_expect_success 'git ls-files -k output (w/ icase)' ' |
Jeff King | 60687de | 2015-03-20 06:06:44 -0400 | [diff] [blame] | 106 | git -c core.ignorecase=true ls-files -k >.output && |
Johannes Sixt | cb64868 | 2013-06-07 22:53:26 +0200 | [diff] [blame] | 107 | test_cmp .expected .output |
| 108 | ' |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 109 | |
Johannes Sixt | cb64868 | 2013-06-07 22:53:26 +0200 | [diff] [blame] | 110 | test_expect_success 'git ls-files -m to show modified files.' ' |
| 111 | git ls-files -m >.output |
| 112 | ' |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 113 | |
Johannes Sixt | cb64868 | 2013-06-07 22:53:26 +0200 | [diff] [blame] | 114 | test_expect_success 'validate git ls-files -m output.' ' |
| 115 | cat >.expected <<-\EOF && |
| 116 | path0 |
| 117 | path1 |
| 118 | path2/file2 |
| 119 | path3/file3 |
| 120 | path7 |
| 121 | path8 |
Junio C Hamano | 4c4d9d9 | 2013-09-11 15:03:28 -0700 | [diff] [blame] | 122 | pathx/ju |
Junio C Hamano | 26c986e | 2013-07-01 14:00:32 -0700 | [diff] [blame] | 123 | submod1 |
Johannes Sixt | cb64868 | 2013-06-07 22:53:26 +0200 | [diff] [blame] | 124 | EOF |
| 125 | test_cmp .expected .output |
| 126 | ' |
Junio C Hamano | b039189 | 2005-09-19 15:11:15 -0700 | [diff] [blame] | 127 | |
| 128 | test_done |