Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2007 Johannes E. Schindelin |
| 4 | # |
| 5 | |
Nanako Shiraishi | 47a528a | 2008-09-03 17:59:33 +0900 | [diff] [blame] | 6 | test_description='git status' |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 7 | |
Rubén Justo | 80d32e8 | 2023-06-17 08:41:54 +0200 | [diff] [blame] | 8 | TEST_PASSES_SANITIZE_LEAK=true |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 9 | . ./test-lib.sh |
Jeff King | 01c94e9 | 2017-10-03 09:43:29 -0400 | [diff] [blame] | 10 | . "$TEST_DIRECTORY"/lib-terminal.sh |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 11 | |
Nguyễn Thái Ngọc Duy | 5d3dd91 | 2010-10-22 01:45:47 -0500 | [diff] [blame] | 12 | test_expect_success 'status -h in broken repository' ' |
Nguyễn Thái Ngọc Duy | 6a38ef2 | 2013-03-13 19:59:16 +0700 | [diff] [blame] | 13 | git config --global advice.statusuoption false && |
Nguyễn Thái Ngọc Duy | 5d3dd91 | 2010-10-22 01:45:47 -0500 | [diff] [blame] | 14 | mkdir broken && |
| 15 | test_when_finished "rm -fr broken" && |
| 16 | ( |
| 17 | cd broken && |
| 18 | git init && |
| 19 | echo "[status] showuntrackedfiles = CORRUPT" >>.git/config && |
| 20 | test_expect_code 129 git status -h >usage 2>&1 |
| 21 | ) && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 22 | test_grep "[Uu]sage" broken/usage |
Nguyễn Thái Ngọc Duy | 5d3dd91 | 2010-10-22 01:45:47 -0500 | [diff] [blame] | 23 | ' |
| 24 | |
| 25 | test_expect_success 'commit -h in broken repository' ' |
| 26 | mkdir broken && |
| 27 | test_when_finished "rm -fr broken" && |
| 28 | ( |
| 29 | cd broken && |
| 30 | git init && |
| 31 | echo "[status] showuntrackedfiles = CORRUPT" >>.git/config && |
| 32 | test_expect_code 129 git commit -h >usage 2>&1 |
| 33 | ) && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 34 | test_grep "[Uu]sage" broken/usage |
Nguyễn Thái Ngọc Duy | 5d3dd91 | 2010-10-22 01:45:47 -0500 | [diff] [blame] | 35 | ' |
| 36 | |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 37 | test_expect_success 'create upstream branch' ' |
| 38 | git checkout -b upstream && |
| 39 | test_commit upstream1 && |
| 40 | test_commit upstream2 && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 41 | # leave the first commit on main as root because several |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 42 | # tests depend on this case; for our upstream we only |
| 43 | # care about commit counts anyway, so a totally divergent |
| 44 | # history is OK |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 45 | git checkout --orphan main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 46 | ' |
| 47 | |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 48 | test_expect_success 'setup' ' |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 49 | : >tracked && |
| 50 | : >modified && |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 51 | mkdir dir1 && |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 52 | : >dir1/tracked && |
| 53 | : >dir1/modified && |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 54 | mkdir dir2 && |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 55 | : >dir1/tracked && |
| 56 | : >dir1/modified && |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 57 | git add . && |
Jeff King | ff58b9a | 2008-02-12 00:45:18 -0500 | [diff] [blame] | 58 | |
| 59 | git status >output && |
| 60 | |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 61 | test_tick && |
| 62 | git commit -m initial && |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 63 | : >untracked && |
| 64 | : >dir1/untracked && |
| 65 | : >dir2/untracked && |
| 66 | echo 1 >dir1/modified && |
| 67 | echo 2 >dir2/modified && |
| 68 | echo 3 >dir2/added && |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 69 | git add dir2/added && |
| 70 | |
| 71 | git branch --set-upstream-to=upstream |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 72 | ' |
| 73 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 74 | test_expect_success 'status (1)' ' |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 75 | test_grep "use \"git rm --cached <file>\.\.\.\" to unstage" output |
Jeff King | ff58b9a | 2008-02-12 00:45:18 -0500 | [diff] [blame] | 76 | ' |
| 77 | |
Matthieu Moy | 2556b99 | 2013-09-06 19:43:07 +0200 | [diff] [blame] | 78 | strip_comments () { |
Eric Sunshine | 2e582df | 2013-09-14 00:47:12 -0400 | [diff] [blame] | 79 | tab=' ' |
| 80 | sed "s/^\# //; s/^\#$//; s/^#$tab/$tab/" <"$1" >"$1".tmp && |
Matthieu Moy | 2556b99 | 2013-09-06 19:43:07 +0200 | [diff] [blame] | 81 | rm "$1" && mv "$1".tmp "$1" |
| 82 | } |
| 83 | |
Junio C Hamano | ec8a896 | 2015-03-06 10:43:33 +0100 | [diff] [blame] | 84 | cat >.gitignore <<\EOF |
| 85 | .gitignore |
| 86 | expect* |
| 87 | output* |
| 88 | EOF |
| 89 | |
Nguyễn Thái Ngọc Duy | 323d053 | 2012-04-13 17:54:39 +0700 | [diff] [blame] | 90 | test_expect_success 'status --column' ' |
Nguyễn Thái Ngọc Duy | 323d053 | 2012-04-13 17:54:39 +0700 | [diff] [blame] | 91 | cat >expect <<\EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 92 | # On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 93 | # Your branch and '\''upstream'\'' have diverged, |
| 94 | # and have 1 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 95 | # (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 96 | # |
Nguyễn Thái Ngọc Duy | 323d053 | 2012-04-13 17:54:39 +0700 | [diff] [blame] | 97 | # Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 98 | # (use "git restore --staged <file>..." to unstage) |
Nguyễn Thái Ngọc Duy | 323d053 | 2012-04-13 17:54:39 +0700 | [diff] [blame] | 99 | # new file: dir2/added |
| 100 | # |
| 101 | # Changes not staged for commit: |
| 102 | # (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 103 | # (use "git restore <file>..." to discard changes in working directory) |
Nguyễn Thái Ngọc Duy | 323d053 | 2012-04-13 17:54:39 +0700 | [diff] [blame] | 104 | # modified: dir1/modified |
| 105 | # |
| 106 | # Untracked files: |
| 107 | # (use "git add <file>..." to include in what will be committed) |
Junio C Hamano | ec8a896 | 2015-03-06 10:43:33 +0100 | [diff] [blame] | 108 | # dir1/untracked dir2/untracked |
| 109 | # dir2/modified untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 110 | # |
Nguyễn Thái Ngọc Duy | 323d053 | 2012-04-13 17:54:39 +0700 | [diff] [blame] | 111 | EOF |
Matthieu Moy | 2556b99 | 2013-09-06 19:43:07 +0200 | [diff] [blame] | 112 | COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 113 | test_cmp expect output |
Matthieu Moy | 2556b99 | 2013-09-06 19:43:07 +0200 | [diff] [blame] | 114 | ' |
| 115 | |
| 116 | test_expect_success 'status --column status.displayCommentPrefix=false' ' |
| 117 | strip_comments expect && |
| 118 | COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 119 | test_cmp expect output |
Nguyễn Thái Ngọc Duy | 323d053 | 2012-04-13 17:54:39 +0700 | [diff] [blame] | 120 | ' |
| 121 | |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 122 | cat >expect <<\EOF |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 123 | # On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 124 | # Your branch and 'upstream' have diverged, |
| 125 | # and have 1 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 126 | # (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 127 | # |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 128 | # Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 129 | # (use "git restore --staged <file>..." to unstage) |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 130 | # new file: dir2/added |
| 131 | # |
Matthieu Moy | 8009d83 | 2010-11-02 16:31:19 +0100 | [diff] [blame] | 132 | # Changes not staged for commit: |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 133 | # (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 134 | # (use "git restore <file>..." to discard changes in working directory) |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 135 | # modified: dir1/modified |
| 136 | # |
| 137 | # Untracked files: |
| 138 | # (use "git add <file>..." to include in what will be committed) |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 139 | # dir1/untracked |
| 140 | # dir2/modified |
| 141 | # dir2/untracked |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 142 | # untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 143 | # |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 144 | EOF |
| 145 | |
Matthieu Moy | 2556b99 | 2013-09-06 19:43:07 +0200 | [diff] [blame] | 146 | test_expect_success 'status with status.displayCommentPrefix=true' ' |
| 147 | git -c status.displayCommentPrefix=true status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 148 | test_cmp expect output |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 149 | ' |
| 150 | |
Matthieu Moy | 2556b99 | 2013-09-06 19:43:07 +0200 | [diff] [blame] | 151 | test_expect_success 'status with status.displayCommentPrefix=false' ' |
| 152 | strip_comments expect && |
| 153 | git -c status.displayCommentPrefix=false status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 154 | test_cmp expect output |
Matthieu Moy | 2556b99 | 2013-09-06 19:43:07 +0200 | [diff] [blame] | 155 | ' |
| 156 | |
Michael J Gruber | f8c65c1 | 2015-03-06 10:43:34 +0100 | [diff] [blame] | 157 | test_expect_success 'status -v' ' |
| 158 | (cat expect && git diff --cached) >expect-with-v && |
| 159 | git status -v >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 160 | test_cmp expect-with-v output |
Michael J Gruber | f8c65c1 | 2015-03-06 10:43:34 +0100 | [diff] [blame] | 161 | ' |
| 162 | |
Michael J Gruber | 4055500 | 2015-03-06 10:43:35 +0100 | [diff] [blame] | 163 | test_expect_success 'status -v -v' ' |
| 164 | (cat expect && |
| 165 | echo "Changes to be committed:" && |
| 166 | git -c diff.mnemonicprefix=true diff --cached && |
| 167 | echo "--------------------------------------------------" && |
| 168 | echo "Changes not staged for commit:" && |
| 169 | git -c diff.mnemonicprefix=true diff) >expect-with-v && |
| 170 | git status -v -v >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 171 | test_cmp expect-with-v output |
Michael J Gruber | 4055500 | 2015-03-06 10:43:35 +0100 | [diff] [blame] | 172 | ' |
| 173 | |
Matthieu Moy | 2556b99 | 2013-09-06 19:43:07 +0200 | [diff] [blame] | 174 | test_expect_success 'setup fake editor' ' |
| 175 | cat >.git/editor <<-\EOF && |
| 176 | #! /bin/sh |
| 177 | cp "$1" output |
| 178 | EOF |
| 179 | chmod 755 .git/editor |
| 180 | ' |
| 181 | |
| 182 | commit_template_commented () { |
| 183 | ( |
| 184 | EDITOR=.git/editor && |
| 185 | export EDITOR && |
| 186 | # Fails due to empty message |
| 187 | test_must_fail git commit |
| 188 | ) && |
| 189 | ! grep '^[^#]' output |
| 190 | } |
| 191 | |
| 192 | test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' ' |
| 193 | commit_template_commented |
| 194 | ' |
| 195 | |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 196 | cat >expect <<\EOF |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 197 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 198 | Your branch and 'upstream' have diverged, |
| 199 | and have 1 and 2 different commits each, respectively. |
| 200 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 201 | Changes to be committed: |
| 202 | new file: dir2/added |
| 203 | |
| 204 | Changes not staged for commit: |
| 205 | modified: dir1/modified |
| 206 | |
| 207 | Untracked files: |
| 208 | dir1/untracked |
| 209 | dir2/modified |
| 210 | dir2/untracked |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 211 | untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 212 | |
Michael J Gruber | 18f3b5a | 2010-04-22 22:30:19 +0200 | [diff] [blame] | 213 | EOF |
| 214 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 215 | test_expect_success 'status (advice.statusHints false)' ' |
Yann Droneaud | c63659d | 2013-03-24 22:06:11 +0100 | [diff] [blame] | 216 | test_config advice.statusHints false && |
Michael J Gruber | 18f3b5a | 2010-04-22 22:30:19 +0200 | [diff] [blame] | 217 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 218 | test_cmp expect output |
Michael J Gruber | 18f3b5a | 2010-04-22 22:30:19 +0200 | [diff] [blame] | 219 | |
| 220 | ' |
| 221 | |
Michael J Gruber | 18f3b5a | 2010-04-22 22:30:19 +0200 | [diff] [blame] | 222 | cat >expect <<\EOF |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 223 | M dir1/modified |
| 224 | A dir2/added |
| 225 | ?? dir1/untracked |
| 226 | ?? dir2/modified |
| 227 | ?? dir2/untracked |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 228 | ?? untracked |
| 229 | EOF |
| 230 | |
Michael J Gruber | 46077fa | 2010-05-25 16:52:03 +0200 | [diff] [blame] | 231 | test_expect_success 'status -s' ' |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 232 | |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 233 | git status -s >output && |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 234 | test_cmp expect output |
| 235 | |
| 236 | ' |
| 237 | |
Junio C Hamano | 150b493 | 2011-06-02 09:07:11 -0700 | [diff] [blame] | 238 | test_expect_success 'status with gitignore' ' |
| 239 | { |
| 240 | echo ".gitignore" && |
Michael J Gruber | f8c65c1 | 2015-03-06 10:43:34 +0100 | [diff] [blame] | 241 | echo "expect*" && |
Junio C Hamano | 150b493 | 2011-06-02 09:07:11 -0700 | [diff] [blame] | 242 | echo "output" && |
| 243 | echo "untracked" |
| 244 | } >.gitignore && |
| 245 | |
| 246 | cat >expect <<-\EOF && |
| 247 | M dir1/modified |
| 248 | A dir2/added |
| 249 | ?? dir2/modified |
| 250 | EOF |
| 251 | git status -s >output && |
| 252 | test_cmp expect output && |
| 253 | |
| 254 | cat >expect <<-\EOF && |
| 255 | M dir1/modified |
| 256 | A dir2/added |
| 257 | ?? dir2/modified |
| 258 | !! .gitignore |
| 259 | !! dir1/untracked |
| 260 | !! dir2/untracked |
| 261 | !! expect |
Michael J Gruber | f8c65c1 | 2015-03-06 10:43:34 +0100 | [diff] [blame] | 262 | !! expect-with-v |
Junio C Hamano | 150b493 | 2011-06-02 09:07:11 -0700 | [diff] [blame] | 263 | !! output |
| 264 | !! untracked |
| 265 | EOF |
| 266 | git status -s --ignored >output && |
| 267 | test_cmp expect output && |
| 268 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 269 | cat >expect <<\EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 270 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 271 | Your branch and '\''upstream'\'' have diverged, |
| 272 | and have 1 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 273 | (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 274 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 275 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 276 | (use "git restore --staged <file>..." to unstage) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 277 | new file: dir2/added |
| 278 | |
| 279 | Changes not staged for commit: |
| 280 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 281 | (use "git restore <file>..." to discard changes in working directory) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 282 | modified: dir1/modified |
| 283 | |
| 284 | Untracked files: |
| 285 | (use "git add <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 286 | dir2/modified |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 287 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 288 | Ignored files: |
| 289 | (use "git add -f <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 290 | .gitignore |
| 291 | dir1/untracked |
| 292 | dir2/untracked |
| 293 | expect |
Michael J Gruber | f8c65c1 | 2015-03-06 10:43:34 +0100 | [diff] [blame] | 294 | expect-with-v |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 295 | output |
| 296 | untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 297 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 298 | EOF |
Junio C Hamano | 150b493 | 2011-06-02 09:07:11 -0700 | [diff] [blame] | 299 | git status --ignored >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 300 | test_cmp expect output |
Junio C Hamano | 150b493 | 2011-06-02 09:07:11 -0700 | [diff] [blame] | 301 | ' |
| 302 | |
| 303 | test_expect_success 'status with gitignore (nothing untracked)' ' |
| 304 | { |
| 305 | echo ".gitignore" && |
Michael J Gruber | f8c65c1 | 2015-03-06 10:43:34 +0100 | [diff] [blame] | 306 | echo "expect*" && |
Junio C Hamano | 150b493 | 2011-06-02 09:07:11 -0700 | [diff] [blame] | 307 | echo "dir2/modified" && |
| 308 | echo "output" && |
| 309 | echo "untracked" |
| 310 | } >.gitignore && |
| 311 | |
| 312 | cat >expect <<-\EOF && |
| 313 | M dir1/modified |
| 314 | A dir2/added |
| 315 | EOF |
| 316 | git status -s >output && |
| 317 | test_cmp expect output && |
| 318 | |
| 319 | cat >expect <<-\EOF && |
| 320 | M dir1/modified |
| 321 | A dir2/added |
| 322 | !! .gitignore |
| 323 | !! dir1/untracked |
| 324 | !! dir2/modified |
| 325 | !! dir2/untracked |
| 326 | !! expect |
Michael J Gruber | f8c65c1 | 2015-03-06 10:43:34 +0100 | [diff] [blame] | 327 | !! expect-with-v |
Junio C Hamano | 150b493 | 2011-06-02 09:07:11 -0700 | [diff] [blame] | 328 | !! output |
| 329 | !! untracked |
| 330 | EOF |
| 331 | git status -s --ignored >output && |
| 332 | test_cmp expect output && |
| 333 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 334 | cat >expect <<\EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 335 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 336 | Your branch and '\''upstream'\'' have diverged, |
| 337 | and have 1 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 338 | (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 339 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 340 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 341 | (use "git restore --staged <file>..." to unstage) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 342 | new file: dir2/added |
| 343 | |
| 344 | Changes not staged for commit: |
| 345 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 346 | (use "git restore <file>..." to discard changes in working directory) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 347 | modified: dir1/modified |
| 348 | |
| 349 | Ignored files: |
| 350 | (use "git add -f <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 351 | .gitignore |
| 352 | dir1/untracked |
| 353 | dir2/modified |
| 354 | dir2/untracked |
| 355 | expect |
Michael J Gruber | f8c65c1 | 2015-03-06 10:43:34 +0100 | [diff] [blame] | 356 | expect-with-v |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 357 | output |
| 358 | untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 359 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 360 | EOF |
Junio C Hamano | 150b493 | 2011-06-02 09:07:11 -0700 | [diff] [blame] | 361 | git status --ignored >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 362 | test_cmp expect output |
Junio C Hamano | 150b493 | 2011-06-02 09:07:11 -0700 | [diff] [blame] | 363 | ' |
| 364 | |
Junio C Hamano | ec8a896 | 2015-03-06 10:43:33 +0100 | [diff] [blame] | 365 | cat >.gitignore <<\EOF |
| 366 | .gitignore |
| 367 | expect* |
| 368 | output* |
| 369 | EOF |
Junio C Hamano | 150b493 | 2011-06-02 09:07:11 -0700 | [diff] [blame] | 370 | |
Michael J Gruber | 46077fa | 2010-05-25 16:52:03 +0200 | [diff] [blame] | 371 | cat >expect <<\EOF |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 372 | ## main...upstream [ahead 1, behind 2] |
Michael J Gruber | 46077fa | 2010-05-25 16:52:03 +0200 | [diff] [blame] | 373 | M dir1/modified |
| 374 | A dir2/added |
| 375 | ?? dir1/untracked |
| 376 | ?? dir2/modified |
| 377 | ?? dir2/untracked |
Michael J Gruber | 46077fa | 2010-05-25 16:52:03 +0200 | [diff] [blame] | 378 | ?? untracked |
| 379 | EOF |
| 380 | |
| 381 | test_expect_success 'status -s -b' ' |
| 382 | |
| 383 | git status -s -b >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 384 | test_cmp expect output |
Michael J Gruber | 46077fa | 2010-05-25 16:52:03 +0200 | [diff] [blame] | 385 | |
| 386 | ' |
| 387 | |
Jeff King | a598523 | 2012-05-07 17:02:18 -0400 | [diff] [blame] | 388 | test_expect_success 'status -s -z -b' ' |
| 389 | tr "\\n" Q <expect >expect.q && |
| 390 | mv expect.q expect && |
| 391 | git status -s -z -b >output && |
| 392 | nul_to_q <output >output.q && |
| 393 | mv output.q output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 394 | test_cmp expect output |
Jeff King | a598523 | 2012-05-07 17:02:18 -0400 | [diff] [blame] | 395 | ' |
| 396 | |
Ævar Arnfjörð Bjarmason | 355ec7a | 2011-02-22 23:42:13 +0000 | [diff] [blame] | 397 | test_expect_success 'setup dir3' ' |
| 398 | mkdir dir3 && |
| 399 | : >dir3/untracked1 && |
| 400 | : >dir3/untracked2 |
| 401 | ' |
| 402 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 403 | test_expect_success 'status -uno' ' |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 404 | cat >expect <<EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 405 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 406 | Your branch and '\''upstream'\'' have diverged, |
| 407 | and have 1 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 408 | (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 409 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 410 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 411 | (use "git restore --staged <file>..." to unstage) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 412 | new file: dir2/added |
| 413 | |
| 414 | Changes not staged for commit: |
| 415 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 416 | (use "git restore <file>..." to discard changes in working directory) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 417 | modified: dir1/modified |
| 418 | |
| 419 | Untracked files not listed (use -u option to show untracked files) |
| 420 | EOF |
Marius Storm-Olsen | 6c2ce04 | 2008-06-05 14:22:56 +0200 | [diff] [blame] | 421 | git status -uno >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 422 | test_cmp expect output |
Marius Storm-Olsen | 6c2ce04 | 2008-06-05 14:22:56 +0200 | [diff] [blame] | 423 | ' |
| 424 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 425 | test_expect_success 'status (status.showUntrackedFiles no)' ' |
Yann Droneaud | c63659d | 2013-03-24 22:06:11 +0100 | [diff] [blame] | 426 | test_config status.showuntrackedfiles no && |
Marius Storm-Olsen | d6293d1 | 2008-06-05 14:47:50 +0200 | [diff] [blame] | 427 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 428 | test_cmp expect output |
Marius Storm-Olsen | d6293d1 | 2008-06-05 14:47:50 +0200 | [diff] [blame] | 429 | ' |
| 430 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 431 | test_expect_success 'status -uno (advice.statusHints false)' ' |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 432 | cat >expect <<EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 433 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 434 | Your branch and '\''upstream'\'' have diverged, |
| 435 | and have 1 and 2 different commits each, respectively. |
| 436 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 437 | Changes to be committed: |
| 438 | new file: dir2/added |
| 439 | |
| 440 | Changes not staged for commit: |
| 441 | modified: dir1/modified |
| 442 | |
| 443 | Untracked files not listed |
| 444 | EOF |
Yann Droneaud | c63659d | 2013-03-24 22:06:11 +0100 | [diff] [blame] | 445 | test_config advice.statusHints false && |
Michael J Gruber | 18f3b5a | 2010-04-22 22:30:19 +0200 | [diff] [blame] | 446 | git status -uno >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 447 | test_cmp expect output |
Michael J Gruber | 18f3b5a | 2010-04-22 22:30:19 +0200 | [diff] [blame] | 448 | ' |
Michael J Gruber | 18f3b5a | 2010-04-22 22:30:19 +0200 | [diff] [blame] | 449 | |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 450 | cat >expect << EOF |
| 451 | M dir1/modified |
| 452 | A dir2/added |
| 453 | EOF |
| 454 | test_expect_success 'status -s -uno' ' |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 455 | git status -s -uno >output && |
| 456 | test_cmp expect output |
| 457 | ' |
| 458 | |
| 459 | test_expect_success 'status -s (status.showUntrackedFiles no)' ' |
Jeff King | 99094a7 | 2015-03-20 06:07:15 -0400 | [diff] [blame] | 460 | git config status.showuntrackedfiles no && |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 461 | git status -s >output && |
| 462 | test_cmp expect output |
| 463 | ' |
| 464 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 465 | test_expect_success 'status -unormal' ' |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 466 | cat >expect <<EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 467 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 468 | Your branch and '\''upstream'\'' have diverged, |
| 469 | and have 1 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 470 | (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 471 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 472 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 473 | (use "git restore --staged <file>..." to unstage) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 474 | new file: dir2/added |
| 475 | |
| 476 | Changes not staged for commit: |
| 477 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 478 | (use "git restore <file>..." to discard changes in working directory) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 479 | modified: dir1/modified |
| 480 | |
| 481 | Untracked files: |
| 482 | (use "git add <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 483 | dir1/untracked |
| 484 | dir2/modified |
| 485 | dir2/untracked |
| 486 | dir3/ |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 487 | untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 488 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 489 | EOF |
Marius Storm-Olsen | 4bfee30 | 2008-06-05 10:31:19 +0200 | [diff] [blame] | 490 | git status -unormal >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 491 | test_cmp expect output |
Marius Storm-Olsen | 4bfee30 | 2008-06-05 10:31:19 +0200 | [diff] [blame] | 492 | ' |
| 493 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 494 | test_expect_success 'status (status.showUntrackedFiles normal)' ' |
Jeff King | 99094a7 | 2015-03-20 06:07:15 -0400 | [diff] [blame] | 495 | test_config status.showuntrackedfiles normal && |
Marius Storm-Olsen | d6293d1 | 2008-06-05 14:47:50 +0200 | [diff] [blame] | 496 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 497 | test_cmp expect output |
Marius Storm-Olsen | d6293d1 | 2008-06-05 14:47:50 +0200 | [diff] [blame] | 498 | ' |
| 499 | |
Marius Storm-Olsen | 4bfee30 | 2008-06-05 10:31:19 +0200 | [diff] [blame] | 500 | cat >expect <<EOF |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 501 | M dir1/modified |
| 502 | A dir2/added |
| 503 | ?? dir1/untracked |
| 504 | ?? dir2/modified |
| 505 | ?? dir2/untracked |
| 506 | ?? dir3/ |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 507 | ?? untracked |
| 508 | EOF |
| 509 | test_expect_success 'status -s -unormal' ' |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 510 | git status -s -unormal >output && |
| 511 | test_cmp expect output |
| 512 | ' |
| 513 | |
| 514 | test_expect_success 'status -s (status.showUntrackedFiles normal)' ' |
Jeff King | 99094a7 | 2015-03-20 06:07:15 -0400 | [diff] [blame] | 515 | git config status.showuntrackedfiles normal && |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 516 | git status -s >output && |
| 517 | test_cmp expect output |
| 518 | ' |
| 519 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 520 | test_expect_success 'status -uall' ' |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 521 | cat >expect <<EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 522 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 523 | Your branch and '\''upstream'\'' have diverged, |
| 524 | and have 1 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 525 | (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 526 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 527 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 528 | (use "git restore --staged <file>..." to unstage) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 529 | new file: dir2/added |
| 530 | |
| 531 | Changes not staged for commit: |
| 532 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 533 | (use "git restore <file>..." to discard changes in working directory) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 534 | modified: dir1/modified |
| 535 | |
| 536 | Untracked files: |
| 537 | (use "git add <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 538 | dir1/untracked |
| 539 | dir2/modified |
| 540 | dir2/untracked |
| 541 | dir3/untracked1 |
| 542 | dir3/untracked2 |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 543 | untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 544 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 545 | EOF |
Marius Storm-Olsen | 4bfee30 | 2008-06-05 10:31:19 +0200 | [diff] [blame] | 546 | git status -uall >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 547 | test_cmp expect output |
Marius Storm-Olsen | d6293d1 | 2008-06-05 14:47:50 +0200 | [diff] [blame] | 548 | ' |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 549 | |
| 550 | test_expect_success 'status (status.showUntrackedFiles all)' ' |
Jeff King | 99094a7 | 2015-03-20 06:07:15 -0400 | [diff] [blame] | 551 | test_config status.showuntrackedfiles all && |
Marius Storm-Olsen | d6293d1 | 2008-06-05 14:47:50 +0200 | [diff] [blame] | 552 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 553 | test_cmp expect output |
Marius Storm-Olsen | 4bfee30 | 2008-06-05 10:31:19 +0200 | [diff] [blame] | 554 | ' |
| 555 | |
Ævar Arnfjörð Bjarmason | 355ec7a | 2011-02-22 23:42:13 +0000 | [diff] [blame] | 556 | test_expect_success 'teardown dir3' ' |
| 557 | rm -rf dir3 |
| 558 | ' |
| 559 | |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 560 | cat >expect <<EOF |
| 561 | M dir1/modified |
| 562 | A dir2/added |
| 563 | ?? dir1/untracked |
| 564 | ?? dir2/modified |
| 565 | ?? dir2/untracked |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 566 | ?? untracked |
| 567 | EOF |
| 568 | test_expect_success 'status -s -uall' ' |
Jeff King | a6a4a88 | 2015-03-20 06:10:21 -0400 | [diff] [blame] | 569 | test_unconfig status.showuntrackedfiles && |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 570 | git status -s -uall >output && |
| 571 | test_cmp expect output |
| 572 | ' |
| 573 | test_expect_success 'status -s (status.showUntrackedFiles all)' ' |
Yann Droneaud | c63659d | 2013-03-24 22:06:11 +0100 | [diff] [blame] | 574 | test_config status.showuntrackedfiles all && |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 575 | git status -s >output && |
| 576 | rm -rf dir3 && |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 577 | test_cmp expect output |
| 578 | ' |
| 579 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 580 | test_expect_success 'status with relative paths' ' |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 581 | cat >expect <<\EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 582 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 583 | Your branch and '\''upstream'\'' have diverged, |
| 584 | and have 1 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 585 | (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 586 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 587 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 588 | (use "git restore --staged <file>..." to unstage) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 589 | new file: ../dir2/added |
| 590 | |
| 591 | Changes not staged for commit: |
| 592 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 593 | (use "git restore <file>..." to discard changes in working directory) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 594 | modified: modified |
| 595 | |
| 596 | Untracked files: |
| 597 | (use "git add <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 598 | untracked |
| 599 | ../dir2/modified |
| 600 | ../dir2/untracked |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 601 | ../untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 602 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 603 | EOF |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 604 | (cd dir1 && git status) >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 605 | test_cmp expect output |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 606 | ' |
| 607 | |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 608 | cat >expect <<\EOF |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 609 | M modified |
| 610 | A ../dir2/added |
| 611 | ?? untracked |
| 612 | ?? ../dir2/modified |
| 613 | ?? ../dir2/untracked |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 614 | ?? ../untracked |
| 615 | EOF |
| 616 | test_expect_success 'status -s with relative paths' ' |
| 617 | |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 618 | (cd dir1 && git status -s) >output && |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 619 | test_cmp expect output |
| 620 | |
| 621 | ' |
| 622 | |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 623 | cat >expect <<\EOF |
Michael J Gruber | c521bb7 | 2009-12-08 11:12:01 +0100 | [diff] [blame] | 624 | M dir1/modified |
| 625 | A dir2/added |
| 626 | ?? dir1/untracked |
| 627 | ?? dir2/modified |
| 628 | ?? dir2/untracked |
Michael J Gruber | c521bb7 | 2009-12-08 11:12:01 +0100 | [diff] [blame] | 629 | ?? untracked |
| 630 | EOF |
| 631 | |
| 632 | test_expect_success 'status --porcelain ignores relative paths setting' ' |
| 633 | |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 634 | (cd dir1 && git status --porcelain) >output && |
Michael J Gruber | c521bb7 | 2009-12-08 11:12:01 +0100 | [diff] [blame] | 635 | test_cmp expect output |
| 636 | |
| 637 | ' |
| 638 | |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 639 | test_expect_success 'setup unique colors' ' |
| 640 | |
Aleksi Aalto | 1d28232 | 2010-11-18 01:40:05 +0200 | [diff] [blame] | 641 | git config status.color.untracked blue && |
Stephen Kent | 93fdf30 | 2017-04-21 22:42:02 -0700 | [diff] [blame] | 642 | git config status.color.branch green && |
| 643 | git config status.color.localBranch yellow && |
| 644 | git config status.color.remoteBranch cyan |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 645 | |
| 646 | ' |
| 647 | |
Jeff King | 01c94e9 | 2017-10-03 09:43:29 -0400 | [diff] [blame] | 648 | test_expect_success TTY 'status with color.ui' ' |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 649 | cat >expect <<\EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 650 | On branch <GREEN>main<RESET> |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 651 | Your branch and '\''upstream'\'' have diverged, |
| 652 | and have 1 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 653 | (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 654 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 655 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 656 | (use "git restore --staged <file>..." to unstage) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 657 | <GREEN>new file: dir2/added<RESET> |
| 658 | |
| 659 | Changes not staged for commit: |
| 660 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 661 | (use "git restore <file>..." to discard changes in working directory) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 662 | <RED>modified: dir1/modified<RESET> |
| 663 | |
| 664 | Untracked files: |
| 665 | (use "git add <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 666 | <BLUE>dir1/untracked<RESET> |
| 667 | <BLUE>dir2/modified<RESET> |
| 668 | <BLUE>dir2/untracked<RESET> |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 669 | <BLUE>untracked<RESET> |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 670 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 671 | EOF |
Jeff King | 01c94e9 | 2017-10-03 09:43:29 -0400 | [diff] [blame] | 672 | test_config color.ui auto && |
| 673 | test_terminal git status | test_decode_color >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 674 | test_cmp expect output |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 675 | ' |
| 676 | |
Jeff King | 01c94e9 | 2017-10-03 09:43:29 -0400 | [diff] [blame] | 677 | test_expect_success TTY 'status with color.status' ' |
| 678 | test_config color.status auto && |
| 679 | test_terminal git status | test_decode_color >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 680 | test_cmp expect output |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 681 | ' |
| 682 | |
| 683 | cat >expect <<\EOF |
| 684 | <RED>M<RESET> dir1/modified |
| 685 | <GREEN>A<RESET> dir2/added |
| 686 | <BLUE>??<RESET> dir1/untracked |
| 687 | <BLUE>??<RESET> dir2/modified |
| 688 | <BLUE>??<RESET> dir2/untracked |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 689 | <BLUE>??<RESET> untracked |
| 690 | EOF |
| 691 | |
Jeff King | 01c94e9 | 2017-10-03 09:43:29 -0400 | [diff] [blame] | 692 | test_expect_success TTY 'status -s with color.ui' ' |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 693 | |
Jeff King | 01c94e9 | 2017-10-03 09:43:29 -0400 | [diff] [blame] | 694 | git config color.ui auto && |
| 695 | test_terminal git status -s | test_decode_color >output && |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 696 | test_cmp expect output |
| 697 | |
| 698 | ' |
| 699 | |
Jeff King | 01c94e9 | 2017-10-03 09:43:29 -0400 | [diff] [blame] | 700 | test_expect_success TTY 'status -s with color.status' ' |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 701 | |
| 702 | git config --unset color.ui && |
Jeff King | 01c94e9 | 2017-10-03 09:43:29 -0400 | [diff] [blame] | 703 | git config color.status auto && |
| 704 | test_terminal git status -s | test_decode_color >output && |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 705 | test_cmp expect output |
| 706 | |
| 707 | ' |
| 708 | |
| 709 | cat >expect <<\EOF |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 710 | ## <YELLOW>main<RESET>...<CYAN>upstream<RESET> [ahead <YELLOW>1<RESET>, behind <CYAN>2<RESET>] |
Michael J Gruber | 46077fa | 2010-05-25 16:52:03 +0200 | [diff] [blame] | 711 | <RED>M<RESET> dir1/modified |
| 712 | <GREEN>A<RESET> dir2/added |
| 713 | <BLUE>??<RESET> dir1/untracked |
| 714 | <BLUE>??<RESET> dir2/modified |
| 715 | <BLUE>??<RESET> dir2/untracked |
Michael J Gruber | 46077fa | 2010-05-25 16:52:03 +0200 | [diff] [blame] | 716 | <BLUE>??<RESET> untracked |
| 717 | EOF |
| 718 | |
Jeff King | 01c94e9 | 2017-10-03 09:43:29 -0400 | [diff] [blame] | 719 | test_expect_success TTY 'status -s -b with color.status' ' |
Michael J Gruber | 46077fa | 2010-05-25 16:52:03 +0200 | [diff] [blame] | 720 | |
Jeff King | 01c94e9 | 2017-10-03 09:43:29 -0400 | [diff] [blame] | 721 | test_terminal git status -s -b | test_decode_color >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 722 | test_cmp expect output |
Michael J Gruber | 46077fa | 2010-05-25 16:52:03 +0200 | [diff] [blame] | 723 | |
| 724 | ' |
| 725 | |
| 726 | cat >expect <<\EOF |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 727 | M dir1/modified |
| 728 | A dir2/added |
| 729 | ?? dir1/untracked |
| 730 | ?? dir2/modified |
| 731 | ?? dir2/untracked |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 732 | ?? untracked |
| 733 | EOF |
| 734 | |
Jeff King | 01c94e9 | 2017-10-03 09:43:29 -0400 | [diff] [blame] | 735 | test_expect_success TTY 'status --porcelain ignores color.ui' ' |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 736 | |
| 737 | git config --unset color.status && |
Jeff King | 01c94e9 | 2017-10-03 09:43:29 -0400 | [diff] [blame] | 738 | git config color.ui auto && |
| 739 | test_terminal git status --porcelain | test_decode_color >output && |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 740 | test_cmp expect output |
| 741 | |
| 742 | ' |
| 743 | |
Jeff King | 01c94e9 | 2017-10-03 09:43:29 -0400 | [diff] [blame] | 744 | test_expect_success TTY 'status --porcelain ignores color.status' ' |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 745 | |
| 746 | git config --unset color.ui && |
Jeff King | 01c94e9 | 2017-10-03 09:43:29 -0400 | [diff] [blame] | 747 | git config color.status auto && |
| 748 | test_terminal git status --porcelain | test_decode_color >output && |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 749 | test_cmp expect output |
| 750 | |
| 751 | ' |
| 752 | |
| 753 | # recover unconditionally from color tests |
| 754 | git config --unset color.status |
| 755 | git config --unset color.ui |
| 756 | |
Jeff King | d4a6bf1 | 2012-05-07 17:09:04 -0400 | [diff] [blame] | 757 | test_expect_success 'status --porcelain respects -b' ' |
Michael J Gruber | 46077fa | 2010-05-25 16:52:03 +0200 | [diff] [blame] | 758 | |
| 759 | git status --porcelain -b >output && |
Jeff King | d4a6bf1 | 2012-05-07 17:09:04 -0400 | [diff] [blame] | 760 | { |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 761 | echo "## main...upstream [ahead 1, behind 2]" && |
Jeff King | d4a6bf1 | 2012-05-07 17:09:04 -0400 | [diff] [blame] | 762 | cat expect |
| 763 | } >tmp && |
| 764 | mv tmp expect && |
Michael J Gruber | 46077fa | 2010-05-25 16:52:03 +0200 | [diff] [blame] | 765 | test_cmp expect output |
| 766 | |
| 767 | ' |
| 768 | |
Jeff King | 46f721c | 2007-12-07 16:26:07 -0500 | [diff] [blame] | 769 | |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 770 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 771 | test_expect_success 'status without relative paths' ' |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 772 | cat >expect <<\EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 773 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 774 | Your branch and '\''upstream'\'' have diverged, |
| 775 | and have 1 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 776 | (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 777 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 778 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 779 | (use "git restore --staged <file>..." to unstage) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 780 | new file: dir2/added |
| 781 | |
| 782 | Changes not staged for commit: |
| 783 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 784 | (use "git restore <file>..." to discard changes in working directory) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 785 | modified: dir1/modified |
| 786 | |
| 787 | Untracked files: |
| 788 | (use "git add <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 789 | dir1/untracked |
| 790 | dir2/modified |
| 791 | dir2/untracked |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 792 | untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 793 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 794 | EOF |
Yann Droneaud | c63659d | 2013-03-24 22:06:11 +0100 | [diff] [blame] | 795 | test_config status.relativePaths false && |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 796 | (cd dir1 && git status) >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 797 | test_cmp expect output |
Jeff King | 46f721c | 2007-12-07 16:26:07 -0500 | [diff] [blame] | 798 | |
| 799 | ' |
| 800 | |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 801 | cat >expect <<\EOF |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 802 | M dir1/modified |
| 803 | A dir2/added |
| 804 | ?? dir1/untracked |
| 805 | ?? dir2/modified |
| 806 | ?? dir2/untracked |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 807 | ?? untracked |
| 808 | EOF |
| 809 | |
| 810 | test_expect_success 'status -s without relative paths' ' |
| 811 | |
Yann Droneaud | c63659d | 2013-03-24 22:06:11 +0100 | [diff] [blame] | 812 | test_config status.relativePaths false && |
Michael J Gruber | 68cfc6f | 2009-12-08 11:12:02 +0100 | [diff] [blame] | 813 | (cd dir1 && git status -s) >output && |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 814 | test_cmp expect output |
| 815 | |
| 816 | ' |
| 817 | |
Junio C Hamano | a361dd3 | 2020-09-10 10:01:57 -0700 | [diff] [blame] | 818 | cat >expect <<\EOF |
| 819 | M dir1/modified |
| 820 | A dir2/added |
| 821 | A "file with spaces" |
| 822 | ?? dir1/untracked |
| 823 | ?? dir2/modified |
| 824 | ?? dir2/untracked |
| 825 | ?? "file with spaces 2" |
| 826 | ?? untracked |
| 827 | EOF |
| 828 | |
| 829 | test_expect_success 'status -s without relative paths' ' |
| 830 | test_when_finished "git rm --cached \"file with spaces\"; rm -f file*" && |
| 831 | >"file with spaces" && |
| 832 | >"file with spaces 2" && |
| 833 | >"expect with spaces" && |
| 834 | git add "file with spaces" && |
| 835 | |
| 836 | git status -s >output && |
| 837 | test_cmp expect output && |
| 838 | |
| 839 | git status -s --ignored >output && |
| 840 | grep "^!! \"expect with spaces\"$" output && |
| 841 | grep -v "^!! " output >output-wo-ignored && |
| 842 | test_cmp expect output-wo-ignored |
| 843 | ' |
| 844 | |
Junio C Hamano | 9e4b7ab | 2009-08-15 02:27:39 -0700 | [diff] [blame] | 845 | test_expect_success 'dry-run of partial commit excluding new file in index' ' |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 846 | cat >expect <<EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 847 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 848 | Your branch and '\''upstream'\'' have diverged, |
| 849 | and have 1 and 2 different commits each, respectively. |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 850 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 851 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 852 | (use "git restore --staged <file>..." to unstage) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 853 | modified: dir1/modified |
| 854 | |
| 855 | Untracked files: |
| 856 | (use "git add <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 857 | dir1/untracked |
| 858 | dir2/ |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 859 | untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 860 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 861 | EOF |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 862 | git commit --dry-run dir1/modified >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 863 | test_cmp expect output |
Jeff King | 959ba67 | 2008-02-14 12:18:23 -0500 | [diff] [blame] | 864 | ' |
| 865 | |
Markus Heidelberg | 4c926b3 | 2010-04-02 14:27:20 +0200 | [diff] [blame] | 866 | cat >expect <<EOF |
brian m. carlson | a5587b8 | 2020-07-29 23:14:06 +0000 | [diff] [blame] | 867 | :100644 100644 $EMPTY_BLOB $ZERO_OID M dir1/modified |
Markus Heidelberg | 4c926b3 | 2010-04-02 14:27:20 +0200 | [diff] [blame] | 868 | EOF |
Markus Heidelberg | 4bb6644 | 2010-04-02 23:44:21 +0200 | [diff] [blame] | 869 | test_expect_success 'status refreshes the index' ' |
Markus Heidelberg | 4c926b3 | 2010-04-02 14:27:20 +0200 | [diff] [blame] | 870 | touch dir2/added && |
| 871 | git status && |
| 872 | git diff-files >output && |
| 873 | test_cmp expect output |
| 874 | ' |
| 875 | |
Jonathan Tan | f24c30e | 2020-09-01 15:28:09 -0700 | [diff] [blame] | 876 | test_expect_success 'status shows detached HEAD properly after checking out non-local upstream branch' ' |
| 877 | test_when_finished rm -rf upstream downstream actual && |
| 878 | |
| 879 | test_create_repo upstream && |
| 880 | test_commit -C upstream foo && |
| 881 | |
| 882 | git clone upstream downstream && |
| 883 | git -C downstream checkout @{u} && |
| 884 | git -C downstream status >actual && |
Carlo Marcelo Arenas Belón | 4da8b2f | 2021-08-01 14:53:00 -0700 | [diff] [blame] | 885 | grep -E "HEAD detached at [0-9a-f]+" actual |
Jonathan Tan | f24c30e | 2020-09-01 15:28:09 -0700 | [diff] [blame] | 886 | ' |
| 887 | |
Ping Yin | e5e4a7f | 2008-04-12 23:05:33 +0800 | [diff] [blame] | 888 | test_expect_success 'setup status submodule summary' ' |
| 889 | test_create_repo sm && ( |
| 890 | cd sm && |
| 891 | >foo && |
| 892 | git add foo && |
| 893 | git commit -m "Add foo" |
| 894 | ) && |
| 895 | git add sm |
| 896 | ' |
| 897 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 898 | test_expect_success 'status submodule summary is disabled by default' ' |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 899 | cat >expect <<EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 900 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 901 | Your branch and '\''upstream'\'' have diverged, |
| 902 | and have 1 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 903 | (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 904 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 905 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 906 | (use "git restore --staged <file>..." to unstage) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 907 | new file: dir2/added |
| 908 | new file: sm |
| 909 | |
| 910 | Changes not staged for commit: |
| 911 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 912 | (use "git restore <file>..." to discard changes in working directory) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 913 | modified: dir1/modified |
| 914 | |
| 915 | Untracked files: |
| 916 | (use "git add <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 917 | dir1/untracked |
| 918 | dir2/modified |
| 919 | dir2/untracked |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 920 | untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 921 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 922 | EOF |
Ping Yin | e5e4a7f | 2008-04-12 23:05:33 +0800 | [diff] [blame] | 923 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 924 | test_cmp expect output |
Ping Yin | e5e4a7f | 2008-04-12 23:05:33 +0800 | [diff] [blame] | 925 | ' |
| 926 | |
Jeff King | 98fa473 | 2008-10-16 11:07:26 -0400 | [diff] [blame] | 927 | # we expect the same as the previous test |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 928 | test_expect_success 'status --untracked-files=all does not show submodule' ' |
Jeff King | 98fa473 | 2008-10-16 11:07:26 -0400 | [diff] [blame] | 929 | git status --untracked-files=all >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 930 | test_cmp expect output |
Jeff King | 98fa473 | 2008-10-16 11:07:26 -0400 | [diff] [blame] | 931 | ' |
| 932 | |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 933 | cat >expect <<EOF |
| 934 | M dir1/modified |
| 935 | A dir2/added |
| 936 | A sm |
| 937 | ?? dir1/untracked |
| 938 | ?? dir2/modified |
| 939 | ?? dir2/untracked |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 940 | ?? untracked |
| 941 | EOF |
| 942 | test_expect_success 'status -s submodule summary is disabled by default' ' |
| 943 | git status -s >output && |
| 944 | test_cmp expect output |
| 945 | ' |
| 946 | |
| 947 | # we expect the same as the previous test |
| 948 | test_expect_success 'status -s --untracked-files=all does not show submodule' ' |
| 949 | git status -s --untracked-files=all >output && |
| 950 | test_cmp expect output |
| 951 | ' |
| 952 | |
Ping Yin | e5e4a7f | 2008-04-12 23:05:33 +0800 | [diff] [blame] | 953 | head=$(cd sm && git rev-parse --short=7 --verify HEAD) |
| 954 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 955 | test_expect_success 'status submodule summary' ' |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 956 | cat >expect <<EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 957 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 958 | Your branch and '\''upstream'\'' have diverged, |
| 959 | and have 1 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 960 | (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 961 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 962 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 963 | (use "git restore --staged <file>..." to unstage) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 964 | new file: dir2/added |
| 965 | new file: sm |
| 966 | |
| 967 | Changes not staged for commit: |
| 968 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 969 | (use "git restore <file>..." to discard changes in working directory) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 970 | modified: dir1/modified |
| 971 | |
| 972 | Submodule changes to be committed: |
| 973 | |
| 974 | * sm 0000000...$head (1): |
| 975 | > Add foo |
| 976 | |
| 977 | Untracked files: |
| 978 | (use "git add <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 979 | dir1/untracked |
| 980 | dir2/modified |
| 981 | dir2/untracked |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 982 | untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 983 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 984 | EOF |
Ping Yin | e5e4a7f | 2008-04-12 23:05:33 +0800 | [diff] [blame] | 985 | git config status.submodulesummary 10 && |
| 986 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 987 | test_cmp expect output |
Ping Yin | e5e4a7f | 2008-04-12 23:05:33 +0800 | [diff] [blame] | 988 | ' |
| 989 | |
Matthieu Moy | 2556b99 | 2013-09-06 19:43:07 +0200 | [diff] [blame] | 990 | test_expect_success 'status submodule summary with status.displayCommentPrefix=false' ' |
| 991 | strip_comments expect && |
| 992 | git -c status.displayCommentPrefix=false status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 993 | test_cmp expect output |
Matthieu Moy | 2556b99 | 2013-09-06 19:43:07 +0200 | [diff] [blame] | 994 | ' |
| 995 | |
| 996 | test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' ' |
| 997 | commit_template_commented |
| 998 | ' |
| 999 | |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 1000 | cat >expect <<EOF |
| 1001 | M dir1/modified |
| 1002 | A dir2/added |
| 1003 | A sm |
| 1004 | ?? dir1/untracked |
| 1005 | ?? dir2/modified |
| 1006 | ?? dir2/untracked |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 1007 | ?? untracked |
| 1008 | EOF |
| 1009 | test_expect_success 'status -s submodule summary' ' |
| 1010 | git status -s >output && |
| 1011 | test_cmp expect output |
| 1012 | ' |
Ping Yin | e5e4a7f | 2008-04-12 23:05:33 +0800 | [diff] [blame] | 1013 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1014 | test_expect_success 'status submodule summary (clean submodule): commit' ' |
Alex Henrie | b6f3da5 | 2023-07-12 22:41:13 -0600 | [diff] [blame] | 1015 | cat >expect-status <<EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 1016 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1017 | Your branch and '\''upstream'\'' have diverged, |
| 1018 | and have 2 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 1019 | (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1020 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1021 | Changes not staged for commit: |
| 1022 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 1023 | (use "git restore <file>..." to discard changes in working directory) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1024 | modified: dir1/modified |
| 1025 | |
| 1026 | Untracked files: |
| 1027 | (use "git add <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1028 | dir1/untracked |
| 1029 | dir2/modified |
| 1030 | dir2/untracked |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1031 | untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 1032 | |
Ping Yin | e5e4a7f | 2008-04-12 23:05:33 +0800 | [diff] [blame] | 1033 | no changes added to commit (use "git add" and/or "git commit -a") |
| 1034 | EOF |
Alex Henrie | b6f3da5 | 2023-07-12 22:41:13 -0600 | [diff] [blame] | 1035 | sed "/git pull/d" expect-status > expect-commit && |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1036 | git commit -m "commit submodule" && |
Ping Yin | e5e4a7f | 2008-04-12 23:05:33 +0800 | [diff] [blame] | 1037 | git config status.submodulesummary 10 && |
Junio C Hamano | 9e4b7ab | 2009-08-15 02:27:39 -0700 | [diff] [blame] | 1038 | test_must_fail git commit --dry-run >output && |
Alex Henrie | b6f3da5 | 2023-07-12 22:41:13 -0600 | [diff] [blame] | 1039 | test_cmp expect-commit output && |
Junio C Hamano | 9e4b7ab | 2009-08-15 02:27:39 -0700 | [diff] [blame] | 1040 | git status >output && |
Alex Henrie | b6f3da5 | 2023-07-12 22:41:13 -0600 | [diff] [blame] | 1041 | test_cmp expect-status output |
Ping Yin | e5e4a7f | 2008-04-12 23:05:33 +0800 | [diff] [blame] | 1042 | ' |
| 1043 | |
| 1044 | cat >expect <<EOF |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 1045 | M dir1/modified |
| 1046 | ?? dir1/untracked |
| 1047 | ?? dir2/modified |
| 1048 | ?? dir2/untracked |
Michael J Gruber | 14ed05d | 2009-11-27 22:29:30 +0100 | [diff] [blame] | 1049 | ?? untracked |
| 1050 | EOF |
| 1051 | test_expect_success 'status -s submodule summary (clean submodule)' ' |
| 1052 | git status -s >output && |
| 1053 | test_cmp expect output |
| 1054 | ' |
| 1055 | |
Brandon Casey | 000f97b | 2011-05-26 13:43:21 -0700 | [diff] [blame] | 1056 | test_expect_success 'status -z implies porcelain' ' |
Brandon Casey | 95b9f9f | 2011-05-26 13:43:20 -0700 | [diff] [blame] | 1057 | git status --porcelain | |
Jeff King | 94221d2 | 2013-10-28 21:23:03 -0400 | [diff] [blame] | 1058 | perl -pe "s/\012/\000/g" >expect && |
Brandon Casey | 95b9f9f | 2011-05-26 13:43:20 -0700 | [diff] [blame] | 1059 | git status -z >output && |
| 1060 | test_cmp expect output |
| 1061 | ' |
| 1062 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1063 | test_expect_success 'commit --dry-run submodule summary (--amend)' ' |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1064 | cat >expect <<EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 1065 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1066 | Your branch and '\''upstream'\'' have diverged, |
| 1067 | and have 2 and 2 different commits each, respectively. |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1068 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1069 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 1070 | (use "git restore --source=HEAD^1 --staged <file>..." to unstage) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1071 | new file: dir2/added |
| 1072 | new file: sm |
| 1073 | |
| 1074 | Changes not staged for commit: |
| 1075 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 1076 | (use "git restore <file>..." to discard changes in working directory) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1077 | modified: dir1/modified |
| 1078 | |
| 1079 | Submodule changes to be committed: |
| 1080 | |
| 1081 | * sm 0000000...$head (1): |
| 1082 | > Add foo |
| 1083 | |
| 1084 | Untracked files: |
| 1085 | (use "git add <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1086 | dir1/untracked |
| 1087 | dir2/modified |
| 1088 | dir2/untracked |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1089 | untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 1090 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1091 | EOF |
Ping Yin | e5e4a7f | 2008-04-12 23:05:33 +0800 | [diff] [blame] | 1092 | git config status.submodulesummary 10 && |
Junio C Hamano | 9e4b7ab | 2009-08-15 02:27:39 -0700 | [diff] [blame] | 1093 | git commit --dry-run --amend >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1094 | test_cmp expect output |
Ping Yin | e5e4a7f | 2008-04-12 23:05:33 +0800 | [diff] [blame] | 1095 | ' |
| 1096 | |
Ævar Arnfjörð Bjarmason | c91cfd1 | 2010-08-06 22:09:09 +0000 | [diff] [blame] | 1097 | test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' ' |
Junio C Hamano | 0377142 | 2018-06-15 11:13:39 -0700 | [diff] [blame] | 1098 | test_when_finished "chmod 775 .git" && |
Markus Heidelberg | b2f6fd9 | 2010-04-03 12:11:57 +0200 | [diff] [blame] | 1099 | ( |
| 1100 | chmod a-w .git && |
| 1101 | # make dir1/tracked stat-dirty |
| 1102 | >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked && |
| 1103 | git status -s >output && |
| 1104 | ! grep dir1/tracked output && |
| 1105 | # make sure "status" succeeded without writing index out |
| 1106 | git diff-files | grep dir1/tracked |
| 1107 | ) |
Markus Heidelberg | b2f6fd9 | 2010-04-03 12:11:57 +0200 | [diff] [blame] | 1108 | ' |
| 1109 | |
Jens Lehmann | c2e0940 | 2010-09-06 20:41:06 +0200 | [diff] [blame] | 1110 | (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm |
Jens Lehmann | aee9c7d | 2010-08-06 00:39:25 +0200 | [diff] [blame] | 1111 | new_head=$(cd sm && git rev-parse --short=7 --verify HEAD) |
| 1112 | touch .gitmodules |
| 1113 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1114 | test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' ' |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1115 | cat > expect << EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 1116 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1117 | Your branch and '\''upstream'\'' have diverged, |
| 1118 | and have 2 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 1119 | (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1120 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1121 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 1122 | (use "git restore --staged <file>..." to unstage) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1123 | modified: sm |
| 1124 | |
| 1125 | Changes not staged for commit: |
| 1126 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 1127 | (use "git restore <file>..." to discard changes in working directory) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1128 | modified: dir1/modified |
| 1129 | |
| 1130 | Submodule changes to be committed: |
| 1131 | |
| 1132 | * sm $head...$new_head (1): |
| 1133 | > Add bar |
| 1134 | |
| 1135 | Untracked files: |
| 1136 | (use "git add <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1137 | .gitmodules |
| 1138 | dir1/untracked |
| 1139 | dir2/modified |
| 1140 | dir2/untracked |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1141 | untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 1142 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1143 | EOF |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1144 | echo modified sm/untracked && |
| 1145 | git status --ignore-submodules=untracked >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1146 | test_cmp expect output |
Jens Lehmann | 46a958b | 2010-06-25 16:56:47 +0200 | [diff] [blame] | 1147 | ' |
| 1148 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1149 | test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' ' |
Yann Droneaud | c63659d | 2013-03-24 22:06:11 +0100 | [diff] [blame] | 1150 | test_config diff.ignoreSubmodules dirty && |
Jens Lehmann | 90e1452 | 2010-08-06 01:27:15 +0200 | [diff] [blame] | 1151 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1152 | test_cmp expect output && |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1153 | git config --add -f .gitmodules submodule.subname.ignore untracked && |
| 1154 | git config --add -f .gitmodules submodule.subname.path sm && |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1155 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1156 | test_cmp expect output && |
Yann Droneaud | c63659d | 2013-03-24 22:06:11 +0100 | [diff] [blame] | 1157 | git config -f .gitmodules --remove-section submodule.subname |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1158 | ' |
| 1159 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1160 | test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' ' |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1161 | git config --add -f .gitmodules submodule.subname.ignore none && |
| 1162 | git config --add -f .gitmodules submodule.subname.path sm && |
Jens Lehmann | aee9c7d | 2010-08-06 00:39:25 +0200 | [diff] [blame] | 1163 | git config --add submodule.subname.ignore untracked && |
| 1164 | git config --add submodule.subname.path sm && |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1165 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1166 | test_cmp expect output && |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1167 | git config --remove-section submodule.subname && |
| 1168 | git config --remove-section -f .gitmodules submodule.subname |
Jens Lehmann | aee9c7d | 2010-08-06 00:39:25 +0200 | [diff] [blame] | 1169 | ' |
| 1170 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1171 | test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' ' |
| 1172 | git status --ignore-submodules=dirty >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1173 | test_cmp expect output |
Jens Lehmann | 46a958b | 2010-06-25 16:56:47 +0200 | [diff] [blame] | 1174 | ' |
| 1175 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1176 | test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' ' |
Yann Droneaud | c63659d | 2013-03-24 22:06:11 +0100 | [diff] [blame] | 1177 | test_config diff.ignoreSubmodules dirty && |
Jens Lehmann | 90e1452 | 2010-08-06 01:27:15 +0200 | [diff] [blame] | 1178 | git status >output && |
| 1179 | ! test -s actual && |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1180 | git config --add -f .gitmodules submodule.subname.ignore dirty && |
| 1181 | git config --add -f .gitmodules submodule.subname.path sm && |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1182 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1183 | test_cmp expect output && |
Yann Droneaud | c63659d | 2013-03-24 22:06:11 +0100 | [diff] [blame] | 1184 | git config -f .gitmodules --remove-section submodule.subname |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1185 | ' |
| 1186 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1187 | test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' ' |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1188 | git config --add -f .gitmodules submodule.subname.ignore none && |
| 1189 | git config --add -f .gitmodules submodule.subname.path sm && |
Jens Lehmann | aee9c7d | 2010-08-06 00:39:25 +0200 | [diff] [blame] | 1190 | git config --add submodule.subname.ignore dirty && |
| 1191 | git config --add submodule.subname.path sm && |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1192 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1193 | test_cmp expect output && |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1194 | git config --remove-section submodule.subname && |
| 1195 | git config -f .gitmodules --remove-section submodule.subname |
Jens Lehmann | aee9c7d | 2010-08-06 00:39:25 +0200 | [diff] [blame] | 1196 | ' |
| 1197 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1198 | test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' ' |
| 1199 | echo modified >sm/foo && |
| 1200 | git status --ignore-submodules=dirty >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1201 | test_cmp expect output |
Jens Lehmann | 46a958b | 2010-06-25 16:56:47 +0200 | [diff] [blame] | 1202 | ' |
| 1203 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1204 | test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' ' |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1205 | git config --add -f .gitmodules submodule.subname.ignore dirty && |
| 1206 | git config --add -f .gitmodules submodule.subname.path sm && |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1207 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1208 | test_cmp expect output && |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1209 | git config -f .gitmodules --remove-section submodule.subname |
| 1210 | ' |
| 1211 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1212 | test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' ' |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1213 | git config --add -f .gitmodules submodule.subname.ignore none && |
| 1214 | git config --add -f .gitmodules submodule.subname.path sm && |
Jens Lehmann | aee9c7d | 2010-08-06 00:39:25 +0200 | [diff] [blame] | 1215 | git config --add submodule.subname.ignore dirty && |
| 1216 | git config --add submodule.subname.path sm && |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1217 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1218 | test_cmp expect output && |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1219 | git config --remove-section submodule.subname && |
| 1220 | git config -f .gitmodules --remove-section submodule.subname |
Jens Lehmann | aee9c7d | 2010-08-06 00:39:25 +0200 | [diff] [blame] | 1221 | ' |
| 1222 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1223 | test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" ' |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1224 | cat > expect << EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 1225 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1226 | Your branch and '\''upstream'\'' have diverged, |
| 1227 | and have 2 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 1228 | (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1229 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1230 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 1231 | (use "git restore --staged <file>..." to unstage) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1232 | modified: sm |
| 1233 | |
| 1234 | Changes not staged for commit: |
| 1235 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 1236 | (use "git restore <file>..." to discard changes in working directory) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1237 | (commit or discard the untracked or modified content in submodules) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1238 | modified: dir1/modified |
| 1239 | modified: sm (modified content) |
| 1240 | |
| 1241 | Submodule changes to be committed: |
| 1242 | |
| 1243 | * sm $head...$new_head (1): |
| 1244 | > Add bar |
| 1245 | |
| 1246 | Untracked files: |
| 1247 | (use "git add <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1248 | .gitmodules |
| 1249 | dir1/untracked |
| 1250 | dir2/modified |
| 1251 | dir2/untracked |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1252 | untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 1253 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1254 | EOF |
Jens Lehmann | 46a958b | 2010-06-25 16:56:47 +0200 | [diff] [blame] | 1255 | git status --ignore-submodules=untracked > output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1256 | test_cmp expect output |
Jens Lehmann | 46a958b | 2010-06-25 16:56:47 +0200 | [diff] [blame] | 1257 | ' |
| 1258 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1259 | test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" ' |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1260 | git config --add -f .gitmodules submodule.subname.ignore untracked && |
| 1261 | git config --add -f .gitmodules submodule.subname.path sm && |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1262 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1263 | test_cmp expect output && |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1264 | git config -f .gitmodules --remove-section submodule.subname |
| 1265 | ' |
| 1266 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1267 | test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" ' |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1268 | git config --add -f .gitmodules submodule.subname.ignore none && |
| 1269 | git config --add -f .gitmodules submodule.subname.path sm && |
Jens Lehmann | aee9c7d | 2010-08-06 00:39:25 +0200 | [diff] [blame] | 1270 | git config --add submodule.subname.ignore untracked && |
| 1271 | git config --add submodule.subname.path sm && |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1272 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1273 | test_cmp expect output && |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1274 | git config --remove-section submodule.subname && |
| 1275 | git config -f .gitmodules --remove-section submodule.subname |
Jens Lehmann | aee9c7d | 2010-08-06 00:39:25 +0200 | [diff] [blame] | 1276 | ' |
| 1277 | |
Jens Lehmann | 46a958b | 2010-06-25 16:56:47 +0200 | [diff] [blame] | 1278 | head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD) |
| 1279 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1280 | test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" ' |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1281 | cat > expect << EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 1282 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1283 | Your branch and '\''upstream'\'' have diverged, |
| 1284 | and have 2 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 1285 | (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1286 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1287 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 1288 | (use "git restore --staged <file>..." to unstage) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1289 | modified: sm |
| 1290 | |
| 1291 | Changes not staged for commit: |
| 1292 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 1293 | (use "git restore <file>..." to discard changes in working directory) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1294 | modified: dir1/modified |
| 1295 | modified: sm (new commits) |
| 1296 | |
| 1297 | Submodule changes to be committed: |
| 1298 | |
| 1299 | * sm $head...$new_head (1): |
| 1300 | > Add bar |
| 1301 | |
| 1302 | Submodules changed but not updated: |
| 1303 | |
| 1304 | * sm $new_head...$head2 (1): |
| 1305 | > 2nd commit |
| 1306 | |
| 1307 | Untracked files: |
| 1308 | (use "git add <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1309 | .gitmodules |
| 1310 | dir1/untracked |
| 1311 | dir2/modified |
| 1312 | dir2/untracked |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1313 | untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 1314 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1315 | EOF |
Jens Lehmann | 46a958b | 2010-06-25 16:56:47 +0200 | [diff] [blame] | 1316 | git status --ignore-submodules=untracked > output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1317 | test_cmp expect output |
Jens Lehmann | 46a958b | 2010-06-25 16:56:47 +0200 | [diff] [blame] | 1318 | ' |
| 1319 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1320 | test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" ' |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1321 | git config --add -f .gitmodules submodule.subname.ignore untracked && |
| 1322 | git config --add -f .gitmodules submodule.subname.path sm && |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1323 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1324 | test_cmp expect output && |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1325 | git config -f .gitmodules --remove-section submodule.subname |
| 1326 | ' |
| 1327 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1328 | test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" ' |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1329 | git config --add -f .gitmodules submodule.subname.ignore none && |
| 1330 | git config --add -f .gitmodules submodule.subname.path sm && |
Jens Lehmann | aee9c7d | 2010-08-06 00:39:25 +0200 | [diff] [blame] | 1331 | git config --add submodule.subname.ignore untracked && |
| 1332 | git config --add submodule.subname.path sm && |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1333 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1334 | test_cmp expect output && |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1335 | git config --remove-section submodule.subname && |
| 1336 | git config -f .gitmodules --remove-section submodule.subname |
Jens Lehmann | aee9c7d | 2010-08-06 00:39:25 +0200 | [diff] [blame] | 1337 | ' |
| 1338 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1339 | test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" ' |
Jens Lehmann | 46a958b | 2010-06-25 16:56:47 +0200 | [diff] [blame] | 1340 | git status --ignore-submodules=dirty > output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1341 | test_cmp expect output |
Jens Lehmann | 46a958b | 2010-06-25 16:56:47 +0200 | [diff] [blame] | 1342 | ' |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1343 | test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" ' |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1344 | git config --add -f .gitmodules submodule.subname.ignore dirty && |
| 1345 | git config --add -f .gitmodules submodule.subname.path sm && |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1346 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1347 | test_cmp expect output && |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1348 | git config -f .gitmodules --remove-section submodule.subname |
| 1349 | ' |
Jens Lehmann | 46a958b | 2010-06-25 16:56:47 +0200 | [diff] [blame] | 1350 | |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1351 | test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" ' |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1352 | git config --add -f .gitmodules submodule.subname.ignore none && |
| 1353 | git config --add -f .gitmodules submodule.subname.path sm && |
Jens Lehmann | aee9c7d | 2010-08-06 00:39:25 +0200 | [diff] [blame] | 1354 | git config --add submodule.subname.ignore dirty && |
| 1355 | git config --add submodule.subname.path sm && |
Junio C Hamano | cc6658e | 2011-04-14 13:56:14 -0700 | [diff] [blame] | 1356 | git status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1357 | test_cmp expect output && |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1358 | git config --remove-section submodule.subname && |
| 1359 | git config -f .gitmodules --remove-section submodule.subname |
Jens Lehmann | aee9c7d | 2010-08-06 00:39:25 +0200 | [diff] [blame] | 1360 | ' |
| 1361 | |
Jens Lehmann | 46a958b | 2010-06-25 16:56:47 +0200 | [diff] [blame] | 1362 | cat > expect << EOF |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 1363 | ; On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1364 | ; Your branch and 'upstream' have diverged, |
| 1365 | ; and have 2 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 1366 | ; (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1367 | ; |
Junio C Hamano | eff80a9 | 2013-01-16 20:18:48 +0100 | [diff] [blame] | 1368 | ; Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 1369 | ; (use "git restore --staged <file>..." to unstage) |
Junio C Hamano | eff80a9 | 2013-01-16 20:18:48 +0100 | [diff] [blame] | 1370 | ; modified: sm |
| 1371 | ; |
| 1372 | ; Changes not staged for commit: |
| 1373 | ; (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 1374 | ; (use "git restore <file>..." to discard changes in working directory) |
Junio C Hamano | eff80a9 | 2013-01-16 20:18:48 +0100 | [diff] [blame] | 1375 | ; modified: dir1/modified |
| 1376 | ; modified: sm (new commits) |
| 1377 | ; |
| 1378 | ; Submodule changes to be committed: |
| 1379 | ; |
| 1380 | ; * sm $head...$new_head (1): |
| 1381 | ; > Add bar |
| 1382 | ; |
| 1383 | ; Submodules changed but not updated: |
| 1384 | ; |
| 1385 | ; * sm $new_head...$head2 (1): |
| 1386 | ; > 2nd commit |
| 1387 | ; |
| 1388 | ; Untracked files: |
| 1389 | ; (use "git add <file>..." to include in what will be committed) |
Junio C Hamano | eff80a9 | 2013-01-16 20:18:48 +0100 | [diff] [blame] | 1390 | ; .gitmodules |
| 1391 | ; dir1/untracked |
| 1392 | ; dir2/modified |
| 1393 | ; dir2/untracked |
Junio C Hamano | eff80a9 | 2013-01-16 20:18:48 +0100 | [diff] [blame] | 1394 | ; untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 1395 | ; |
Junio C Hamano | eff80a9 | 2013-01-16 20:18:48 +0100 | [diff] [blame] | 1396 | EOF |
| 1397 | |
| 1398 | test_expect_success "status (core.commentchar with submodule summary)" ' |
Yann Droneaud | c63659d | 2013-03-24 22:06:11 +0100 | [diff] [blame] | 1399 | test_config core.commentchar ";" && |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1400 | git -c status.displayCommentPrefix=true status >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1401 | test_cmp expect output |
Junio C Hamano | eff80a9 | 2013-01-16 20:18:48 +0100 | [diff] [blame] | 1402 | ' |
| 1403 | |
| 1404 | test_expect_success "status (core.commentchar with two chars with submodule summary)" ' |
Yann Droneaud | c63659d | 2013-03-24 22:06:11 +0100 | [diff] [blame] | 1405 | test_config core.commentchar ";;" && |
Nguyễn Thái Ngọc Duy | 50b54fd | 2014-05-17 08:52:22 +0700 | [diff] [blame] | 1406 | test_must_fail git -c status.displayCommentPrefix=true status |
Junio C Hamano | eff80a9 | 2013-01-16 20:18:48 +0100 | [diff] [blame] | 1407 | ' |
| 1408 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1409 | test_expect_success "--ignore-submodules=all suppresses submodule summary" ' |
| 1410 | cat > expect << EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 1411 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1412 | Your branch and '\''upstream'\'' have diverged, |
| 1413 | and have 2 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 1414 | (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1415 | |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1416 | Changes not staged for commit: |
| 1417 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 1418 | (use "git restore <file>..." to discard changes in working directory) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1419 | modified: dir1/modified |
| 1420 | |
| 1421 | Untracked files: |
| 1422 | (use "git add <file>..." to include in what will be committed) |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1423 | .gitmodules |
| 1424 | dir1/untracked |
| 1425 | dir2/modified |
| 1426 | dir2/untracked |
Matthieu Moy | 1c7969c | 2013-09-06 19:43:08 +0200 | [diff] [blame] | 1427 | untracked |
Matthieu Moy | 2f0f7f1 | 2013-09-06 19:43:09 +0200 | [diff] [blame] | 1428 | |
Jens Lehmann | 46a958b | 2010-06-25 16:56:47 +0200 | [diff] [blame] | 1429 | no changes added to commit (use "git add" and/or "git commit -a") |
| 1430 | EOF |
Jens Lehmann | 46a958b | 2010-06-25 16:56:47 +0200 | [diff] [blame] | 1431 | git status --ignore-submodules=all > output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1432 | test_cmp expect output |
Jens Lehmann | 46a958b | 2010-06-25 16:56:47 +0200 | [diff] [blame] | 1433 | ' |
| 1434 | |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1435 | test_expect_success '.gitmodules ignore=all suppresses unstaged submodule summary' ' |
| 1436 | cat > expect << EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 1437 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1438 | Your branch and '\''upstream'\'' have diverged, |
| 1439 | and have 2 and 2 different commits each, respectively. |
Alex Henrie | d92304f | 2023-07-12 22:41:14 -0600 | [diff] [blame] | 1440 | (use "git pull" if you want to integrate the remote branch with yours) |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1441 | |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1442 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 1443 | (use "git restore --staged <file>..." to unstage) |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1444 | modified: sm |
| 1445 | |
| 1446 | Changes not staged for commit: |
| 1447 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 1448 | (use "git restore <file>..." to discard changes in working directory) |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1449 | modified: dir1/modified |
| 1450 | |
| 1451 | Untracked files: |
| 1452 | (use "git add <file>..." to include in what will be committed) |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1453 | .gitmodules |
| 1454 | dir1/untracked |
| 1455 | dir2/modified |
| 1456 | dir2/untracked |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1457 | untracked |
| 1458 | |
| 1459 | EOF |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1460 | git config --add -f .gitmodules submodule.subname.ignore all && |
| 1461 | git config --add -f .gitmodules submodule.subname.path sm && |
| 1462 | git status > output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1463 | test_cmp expect output && |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1464 | git config -f .gitmodules --remove-section submodule.subname |
| 1465 | ' |
| 1466 | |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1467 | test_expect_success '.git/config ignore=all suppresses unstaged submodule summary' ' |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1468 | git config --add -f .gitmodules submodule.subname.ignore none && |
| 1469 | git config --add -f .gitmodules submodule.subname.path sm && |
Jens Lehmann | aee9c7d | 2010-08-06 00:39:25 +0200 | [diff] [blame] | 1470 | git config --add submodule.subname.ignore all && |
| 1471 | git config --add submodule.subname.path sm && |
| 1472 | git status > output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1473 | test_cmp expect output && |
Jens Lehmann | 302ad7a | 2010-08-06 00:40:48 +0200 | [diff] [blame] | 1474 | git config --remove-section submodule.subname && |
| 1475 | git config -f .gitmodules --remove-section submodule.subname |
Jens Lehmann | aee9c7d | 2010-08-06 00:39:25 +0200 | [diff] [blame] | 1476 | ' |
| 1477 | |
Jorge Juan Garcia Garcia | 4fb5166 | 2013-06-11 15:34:04 +0200 | [diff] [blame] | 1478 | test_expect_success 'setup of test environment' ' |
| 1479 | git config status.showUntrackedFiles no && |
| 1480 | git status -s >expected_short && |
| 1481 | git status --no-short >expected_noshort |
| 1482 | ' |
| 1483 | |
| 1484 | test_expect_success '"status.short=true" same as "-s"' ' |
| 1485 | git -c status.short=true status >actual && |
| 1486 | test_cmp expected_short actual |
| 1487 | ' |
| 1488 | |
| 1489 | test_expect_success '"status.short=true" weaker than "--no-short"' ' |
| 1490 | git -c status.short=true status --no-short >actual && |
| 1491 | test_cmp expected_noshort actual |
| 1492 | ' |
| 1493 | |
| 1494 | test_expect_success '"status.short=false" same as "--no-short"' ' |
| 1495 | git -c status.short=false status >actual && |
| 1496 | test_cmp expected_noshort actual |
| 1497 | ' |
| 1498 | |
| 1499 | test_expect_success '"status.short=false" weaker than "-s"' ' |
| 1500 | git -c status.short=false status -s >actual && |
| 1501 | test_cmp expected_short actual |
| 1502 | ' |
| 1503 | |
Jorge Juan Garcia Garcia | ec85d07 | 2013-06-11 15:34:05 +0200 | [diff] [blame] | 1504 | test_expect_success '"status.branch=true" same as "-b"' ' |
| 1505 | git status -sb >expected_branch && |
| 1506 | git -c status.branch=true status -s >actual && |
| 1507 | test_cmp expected_branch actual |
| 1508 | ' |
| 1509 | |
| 1510 | test_expect_success '"status.branch=true" different from "--no-branch"' ' |
| 1511 | git status -s --no-branch >expected_nobranch && |
| 1512 | git -c status.branch=true status -s >actual && |
Denton Liu | e8a5f07 | 2020-04-20 04:54:41 -0400 | [diff] [blame] | 1513 | ! test_cmp expected_nobranch actual |
Jorge Juan Garcia Garcia | ec85d07 | 2013-06-11 15:34:05 +0200 | [diff] [blame] | 1514 | ' |
| 1515 | |
| 1516 | test_expect_success '"status.branch=true" weaker than "--no-branch"' ' |
| 1517 | git -c status.branch=true status -s --no-branch >actual && |
| 1518 | test_cmp expected_nobranch actual |
| 1519 | ' |
| 1520 | |
Junio C Hamano | 84b4202 | 2013-06-24 11:41:40 -0700 | [diff] [blame] | 1521 | test_expect_success '"status.branch=true" weaker than "--porcelain"' ' |
John Cai | a6171e1 | 2023-05-20 16:13:52 +0000 | [diff] [blame] | 1522 | git -c status.branch=true status --porcelain >actual && |
| 1523 | test_cmp expected_nobranch actual |
Junio C Hamano | 84b4202 | 2013-06-24 11:41:40 -0700 | [diff] [blame] | 1524 | ' |
| 1525 | |
Jorge Juan Garcia Garcia | ec85d07 | 2013-06-11 15:34:05 +0200 | [diff] [blame] | 1526 | test_expect_success '"status.branch=false" same as "--no-branch"' ' |
| 1527 | git -c status.branch=false status -s >actual && |
| 1528 | test_cmp expected_nobranch actual |
| 1529 | ' |
| 1530 | |
| 1531 | test_expect_success '"status.branch=false" weaker than "-b"' ' |
| 1532 | git -c status.branch=false status -sb >actual && |
| 1533 | test_cmp expected_branch actual |
| 1534 | ' |
| 1535 | |
Jorge Juan Garcia Garcia | 4fb5166 | 2013-06-11 15:34:04 +0200 | [diff] [blame] | 1536 | test_expect_success 'Restore default test environment' ' |
| 1537 | git config --unset status.showUntrackedFiles |
| 1538 | ' |
| 1539 | |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1540 | test_expect_success 'git commit will commit a staged but ignored submodule' ' |
| 1541 | git config --add -f .gitmodules submodule.subname.ignore all && |
| 1542 | git config --add -f .gitmodules submodule.subname.path sm && |
| 1543 | git config --add submodule.subname.ignore all && |
| 1544 | git status -s --ignore-submodules=dirty >output && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 1545 | test_grep "^M. sm" output && |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1546 | GIT_EDITOR="echo hello >>\"\$1\"" && |
| 1547 | export GIT_EDITOR && |
| 1548 | git commit -uno && |
| 1549 | git status -s --ignore-submodules=dirty >output && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 1550 | test_grep ! "^M. sm" output |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1551 | ' |
| 1552 | |
| 1553 | test_expect_success 'git commit --dry-run will show a staged but ignored submodule' ' |
| 1554 | git reset HEAD^ && |
| 1555 | git add sm && |
| 1556 | cat >expect << EOF && |
Johannes Schindelin | 1e2ae14 | 2020-11-18 23:44:40 +0000 | [diff] [blame] | 1557 | On branch main |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1558 | Your branch and '\''upstream'\'' have diverged, |
| 1559 | and have 2 and 2 different commits each, respectively. |
Jeff King | 75177c8 | 2017-04-27 05:01:05 -0400 | [diff] [blame] | 1560 | |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1561 | Changes to be committed: |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 1562 | (use "git restore --staged <file>..." to unstage) |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1563 | modified: sm |
| 1564 | |
| 1565 | Changes not staged for commit: |
| 1566 | (use "git add <file>..." to update what will be committed) |
Nguyễn Thái Ngọc Duy | 80f537f | 2019-04-25 16:45:58 +0700 | [diff] [blame] | 1567 | (use "git restore <file>..." to discard changes in working directory) |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1568 | modified: dir1/modified |
| 1569 | |
| 1570 | Untracked files not listed (use -u option to show untracked files) |
| 1571 | EOF |
| 1572 | git commit -uno --dry-run >output && |
Ævar Arnfjörð Bjarmason | 1108cea | 2021-02-11 02:53:53 +0100 | [diff] [blame] | 1573 | test_cmp expect output && |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1574 | git status -s --ignore-submodules=dirty >output && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 1575 | test_grep "^M. sm" output |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1576 | ' |
| 1577 | |
Jens Lehmann | c215d3d | 2014-04-05 18:59:36 +0200 | [diff] [blame] | 1578 | test_expect_success 'git commit -m will commit a staged but ignored submodule' ' |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1579 | git commit -uno -m message && |
| 1580 | git status -s --ignore-submodules=dirty >output && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 1581 | test_grep ! "^M. sm" output && |
Jens Lehmann | 1d2f393 | 2014-04-05 18:59:03 +0200 | [diff] [blame] | 1582 | git config --remove-section submodule.subname && |
| 1583 | git config -f .gitmodules --remove-section submodule.subname |
| 1584 | ' |
| 1585 | |
Liam Beguin | c1b5d01 | 2017-06-17 18:30:51 -0400 | [diff] [blame] | 1586 | test_expect_success 'show stash info with "--show-stash"' ' |
| 1587 | git reset --hard && |
| 1588 | git stash clear && |
| 1589 | echo 1 >file && |
| 1590 | git add file && |
| 1591 | git stash && |
| 1592 | git status >expected_default && |
| 1593 | git status --show-stash >expected_with_stash && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 1594 | test_grep "^Your stash currently has 1 entry$" expected_with_stash |
Liam Beguin | c1b5d01 | 2017-06-17 18:30:51 -0400 | [diff] [blame] | 1595 | ' |
| 1596 | |
| 1597 | test_expect_success 'no stash info with "--show-stash --no-show-stash"' ' |
| 1598 | git status --show-stash --no-show-stash >expected_without_stash && |
| 1599 | test_cmp expected_default expected_without_stash |
| 1600 | ' |
| 1601 | |
| 1602 | test_expect_success '"status.showStash=false" weaker than "--show-stash"' ' |
| 1603 | git -c status.showStash=false status --show-stash >actual && |
| 1604 | test_cmp expected_with_stash actual |
| 1605 | ' |
| 1606 | |
| 1607 | test_expect_success '"status.showStash=true" weaker than "--no-show-stash"' ' |
| 1608 | git -c status.showStash=true status --no-show-stash >actual && |
| 1609 | test_cmp expected_without_stash actual |
| 1610 | ' |
| 1611 | |
Elijah Newren | 4dc8b1c | 2019-11-05 17:07:25 +0000 | [diff] [blame] | 1612 | test_expect_success 'no additional info if no stash entries' ' |
Liam Beguin | c1b5d01 | 2017-06-17 18:30:51 -0400 | [diff] [blame] | 1613 | git stash clear && |
| 1614 | git -c status.showStash=true status >actual && |
| 1615 | test_cmp expected_without_stash actual |
| 1616 | ' |
| 1617 | |
Kaartic Sivaraam | 4ddb135 | 2017-06-21 23:46:14 +0530 | [diff] [blame] | 1618 | test_expect_success '"No commits yet" should be noted in status output' ' |
| 1619 | git checkout --orphan empty-branch-1 && |
| 1620 | git status >output && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 1621 | test_grep "No commits yet" output |
Kaartic Sivaraam | 4ddb135 | 2017-06-21 23:46:14 +0530 | [diff] [blame] | 1622 | ' |
| 1623 | |
| 1624 | test_expect_success '"No commits yet" should not be noted in status output' ' |
| 1625 | git checkout --orphan empty-branch-2 && |
| 1626 | test_commit test-commit-1 && |
| 1627 | git status >output && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 1628 | test_grep ! "No commits yet" output |
Kaartic Sivaraam | 4ddb135 | 2017-06-21 23:46:14 +0530 | [diff] [blame] | 1629 | ' |
| 1630 | |
| 1631 | test_expect_success '"Initial commit" should be noted in commit template' ' |
| 1632 | git checkout --orphan empty-branch-3 && |
| 1633 | touch to_be_committed_1 && |
| 1634 | git add to_be_committed_1 && |
| 1635 | git commit --dry-run >output && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 1636 | test_grep "Initial commit" output |
Kaartic Sivaraam | 4ddb135 | 2017-06-21 23:46:14 +0530 | [diff] [blame] | 1637 | ' |
| 1638 | |
| 1639 | test_expect_success '"Initial commit" should not be noted in commit template' ' |
| 1640 | git checkout --orphan empty-branch-4 && |
| 1641 | test_commit test-commit-2 && |
| 1642 | touch to_be_committed_2 && |
| 1643 | git add to_be_committed_2 && |
| 1644 | git commit --dry-run >output && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 1645 | test_grep ! "Initial commit" output |
Kaartic Sivaraam | 4ddb135 | 2017-06-21 23:46:14 +0530 | [diff] [blame] | 1646 | ' |
| 1647 | |
Jeff King | 27344d6 | 2017-09-27 02:54:30 -0400 | [diff] [blame] | 1648 | test_expect_success '--no-optional-locks prevents index update' ' |
Marc Strapetz | 0275e4d | 2022-01-07 11:17:29 +0000 | [diff] [blame] | 1649 | test_set_magic_mtime .git/index && |
Jeff King | 27344d6 | 2017-09-27 02:54:30 -0400 | [diff] [blame] | 1650 | git --no-optional-locks status && |
Marc Strapetz | 0275e4d | 2022-01-07 11:17:29 +0000 | [diff] [blame] | 1651 | test_is_magic_mtime .git/index && |
Jeff King | 27344d6 | 2017-09-27 02:54:30 -0400 | [diff] [blame] | 1652 | git status && |
Marc Strapetz | 0275e4d | 2022-01-07 11:17:29 +0000 | [diff] [blame] | 1653 | ! test_is_magic_mtime .git/index |
Jeff King | 27344d6 | 2017-09-27 02:54:30 -0400 | [diff] [blame] | 1654 | ' |
| 1655 | |
Marc Strapetz | 9b71efd | 2022-01-07 11:17:30 +0000 | [diff] [blame] | 1656 | test_expect_success 'racy timestamps will be fixed for clean worktree' ' |
| 1657 | echo content >racy-dirty && |
| 1658 | echo content >racy-racy && |
| 1659 | git add racy* && |
| 1660 | git commit -m "racy test files" && |
| 1661 | # let status rewrite the index, if necessary; after that we expect |
| 1662 | # no more index writes unless caused by racy timestamps; note that |
| 1663 | # timestamps may already be racy now (depending on previous tests) |
| 1664 | git status && |
| 1665 | test_set_magic_mtime .git/index && |
| 1666 | git status && |
| 1667 | ! test_is_magic_mtime .git/index |
| 1668 | ' |
| 1669 | |
| 1670 | test_expect_success 'racy timestamps will be fixed for dirty worktree' ' |
| 1671 | echo content2 >racy-dirty && |
| 1672 | git status && |
| 1673 | test_set_magic_mtime .git/index && |
| 1674 | git status && |
| 1675 | ! test_is_magic_mtime .git/index |
| 1676 | ' |
| 1677 | |
Rudy Rigot | ecbc23e | 2022-11-30 00:52:16 +0000 | [diff] [blame] | 1678 | test_expect_success 'setup slow status advice' ' |
| 1679 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main git init slowstatus && |
| 1680 | ( |
| 1681 | cd slowstatus && |
| 1682 | cat >.gitignore <<-\EOF && |
| 1683 | /actual |
| 1684 | /expected |
| 1685 | /out |
| 1686 | EOF |
| 1687 | git add .gitignore && |
| 1688 | git commit -m "Add .gitignore" && |
| 1689 | git config advice.statusuoption true |
| 1690 | ) |
| 1691 | ' |
| 1692 | |
| 1693 | test_expect_success 'slow status advice when core.untrackedCache and fsmonitor are unset' ' |
| 1694 | ( |
| 1695 | cd slowstatus && |
| 1696 | git config core.untrackedCache false && |
| 1697 | git config core.fsmonitor false && |
| 1698 | GIT_TEST_UF_DELAY_WARNING=1 git status >actual && |
| 1699 | cat >expected <<-\EOF && |
| 1700 | On branch main |
| 1701 | |
| 1702 | It took 3.25 seconds to enumerate untracked files. |
| 1703 | See '\''git help status'\'' for information on how to improve this. |
| 1704 | |
| 1705 | nothing to commit, working tree clean |
| 1706 | EOF |
| 1707 | test_cmp expected actual |
| 1708 | ) |
| 1709 | ' |
| 1710 | |
| 1711 | test_expect_success 'slow status advice when core.untrackedCache true, but not fsmonitor' ' |
| 1712 | ( |
| 1713 | cd slowstatus && |
| 1714 | git config core.untrackedCache true && |
| 1715 | git config core.fsmonitor false && |
| 1716 | GIT_TEST_UF_DELAY_WARNING=1 git status >actual && |
| 1717 | cat >expected <<-\EOF && |
| 1718 | On branch main |
| 1719 | |
| 1720 | It took 3.25 seconds to enumerate untracked files. |
| 1721 | See '\''git help status'\'' for information on how to improve this. |
| 1722 | |
| 1723 | nothing to commit, working tree clean |
| 1724 | EOF |
| 1725 | test_cmp expected actual |
| 1726 | ) |
| 1727 | ' |
| 1728 | |
| 1729 | test_expect_success 'slow status advice when core.untrackedCache true, and fsmonitor' ' |
| 1730 | ( |
| 1731 | cd slowstatus && |
| 1732 | git config core.untrackedCache true && |
| 1733 | git config core.fsmonitor true && |
| 1734 | GIT_TEST_UF_DELAY_WARNING=1 git status >actual && |
| 1735 | cat >expected <<-\EOF && |
| 1736 | On branch main |
| 1737 | |
| 1738 | It took 3.25 seconds to enumerate untracked files, |
| 1739 | but the results were cached, and subsequent runs may be faster. |
| 1740 | See '\''git help status'\'' for information on how to improve this. |
| 1741 | |
| 1742 | nothing to commit, working tree clean |
| 1743 | EOF |
| 1744 | test_cmp expected actual |
| 1745 | ) |
| 1746 | ' |
| 1747 | |
Jason Hatton | 5143ac0 | 2023-10-12 16:09:30 +0000 | [diff] [blame] | 1748 | test_expect_success EXPENSIVE 'status does not re-read unchanged 4 or 8 GiB file' ' |
| 1749 | ( |
| 1750 | mkdir large-file && |
| 1751 | cd large-file && |
| 1752 | # Files are 2 GiB, 4 GiB, and 8 GiB sparse files. |
| 1753 | test-tool truncate file-a 0x080000000 && |
| 1754 | test-tool truncate file-b 0x100000000 && |
| 1755 | test-tool truncate file-c 0x200000000 && |
| 1756 | # This will be slow. |
| 1757 | git add file-a file-b file-c && |
| 1758 | git commit -m "add large files" && |
| 1759 | git diff-index HEAD file-a file-b file-c >actual && |
| 1760 | test_must_be_empty actual |
| 1761 | ) |
| 1762 | ' |
| 1763 | |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 1764 | test_done |