Ping Yin | 27bfd95 | 2008-05-02 21:35:34 +0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Nanako Shiraishi | 47a528a | 2008-09-03 17:59:33 +0900 | [diff] [blame] | 3 | test_description='git status for submodule' |
Ping Yin | 27bfd95 | 2008-05-02 21:35:34 +0800 | [diff] [blame] | 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
Heiko Voigt | 44ca0c8 | 2011-05-14 18:26:30 +0200 | [diff] [blame] | 7 | test_create_repo_with_commit () { |
| 8 | test_create_repo "$1" && |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 9 | ( |
Heiko Voigt | 44ca0c8 | 2011-05-14 18:26:30 +0200 | [diff] [blame] | 10 | cd "$1" && |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 11 | : >bar && |
| 12 | git add bar && |
| 13 | git commit -m " Add bar" && |
| 14 | : >foo && |
| 15 | git add foo && |
| 16 | git commit -m " Add foo" |
Heiko Voigt | 44ca0c8 | 2011-05-14 18:26:30 +0200 | [diff] [blame] | 17 | ) |
| 18 | } |
| 19 | |
Stefan Beller | dd6962d | 2017-03-29 15:26:15 -0700 | [diff] [blame] | 20 | sanitize_output () { |
brian m. carlson | 2ece6ad | 2018-05-13 02:24:15 +0000 | [diff] [blame] | 21 | sed -e "s/$OID_REGEX/HASH/" -e "s/$OID_REGEX/HASH/" output >output2 && |
Stefan Beller | dd6962d | 2017-03-29 15:26:15 -0700 | [diff] [blame] | 22 | mv output2 output |
| 23 | } |
| 24 | |
| 25 | |
Heiko Voigt | 44ca0c8 | 2011-05-14 18:26:30 +0200 | [diff] [blame] | 26 | test_expect_success 'setup' ' |
| 27 | test_create_repo_with_commit sub && |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 28 | echo output > .gitignore && |
| 29 | git add sub .gitignore && |
Ping Yin | 27bfd95 | 2008-05-02 21:35:34 +0800 | [diff] [blame] | 30 | git commit -m "Add submodule sub" |
| 31 | ' |
| 32 | |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 33 | test_expect_success 'status clean' ' |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 34 | git status >output && |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 35 | test_i18ngrep "nothing to commit" output |
Ping Yin | 27bfd95 | 2008-05-02 21:35:34 +0800 | [diff] [blame] | 36 | ' |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 37 | |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 38 | test_expect_success 'commit --dry-run -a clean' ' |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 39 | test_must_fail git commit --dry-run -a >output && |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 40 | test_i18ngrep "nothing to commit" output |
Ping Yin | 27bfd95 | 2008-05-02 21:35:34 +0800 | [diff] [blame] | 41 | ' |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 42 | |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 43 | test_expect_success 'status with modified file in submodule' ' |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 44 | (cd sub && git reset --hard) && |
| 45 | echo "changed" >sub/foo && |
| 46 | git status >output && |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 47 | test_i18ngrep "modified: sub (modified content)" output |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 48 | ' |
| 49 | |
| 50 | test_expect_success 'status with modified file in submodule (porcelain)' ' |
| 51 | (cd sub && git reset --hard) && |
| 52 | echo "changed" >sub/foo && |
| 53 | git status --porcelain >output && |
| 54 | diff output - <<-\EOF |
| 55 | M sub |
| 56 | EOF |
| 57 | ' |
| 58 | |
Stefan Beller | dd6962d | 2017-03-29 15:26:15 -0700 | [diff] [blame] | 59 | test_expect_success 'status with modified file in submodule (short)' ' |
| 60 | (cd sub && git reset --hard) && |
| 61 | echo "changed" >sub/foo && |
| 62 | git status --short >output && |
| 63 | diff output - <<-\EOF |
| 64 | m sub |
| 65 | EOF |
| 66 | ' |
| 67 | |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 68 | test_expect_success 'status with added file in submodule' ' |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 69 | (cd sub && git reset --hard && echo >foo && git add foo) && |
| 70 | git status >output && |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 71 | test_i18ngrep "modified: sub (modified content)" output |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 72 | ' |
| 73 | |
| 74 | test_expect_success 'status with added file in submodule (porcelain)' ' |
| 75 | (cd sub && git reset --hard && echo >foo && git add foo) && |
| 76 | git status --porcelain >output && |
| 77 | diff output - <<-\EOF |
| 78 | M sub |
| 79 | EOF |
| 80 | ' |
| 81 | |
Stefan Beller | dd6962d | 2017-03-29 15:26:15 -0700 | [diff] [blame] | 82 | test_expect_success 'status with added file in submodule (short)' ' |
| 83 | (cd sub && git reset --hard && echo >foo && git add foo) && |
| 84 | git status --short >output && |
| 85 | diff output - <<-\EOF |
| 86 | m sub |
| 87 | EOF |
| 88 | ' |
| 89 | |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 90 | test_expect_success 'status with untracked file in submodule' ' |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 91 | (cd sub && git reset --hard) && |
| 92 | echo "content" >sub/new-file && |
| 93 | git status >output && |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 94 | test_i18ngrep "modified: sub (untracked content)" output |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 95 | ' |
| 96 | |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 97 | test_expect_success 'status -uno with untracked file in submodule' ' |
Jens Lehmann | 3bfc450 | 2010-03-13 23:00:27 +0100 | [diff] [blame] | 98 | git status -uno >output && |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 99 | test_i18ngrep "^nothing to commit" output |
Jens Lehmann | 3bfc450 | 2010-03-13 23:00:27 +0100 | [diff] [blame] | 100 | ' |
| 101 | |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 102 | test_expect_success 'status with untracked file in submodule (porcelain)' ' |
| 103 | git status --porcelain >output && |
| 104 | diff output - <<-\EOF |
| 105 | M sub |
| 106 | EOF |
| 107 | ' |
| 108 | |
Stefan Beller | dd6962d | 2017-03-29 15:26:15 -0700 | [diff] [blame] | 109 | test_expect_success 'status with untracked file in submodule (short)' ' |
| 110 | git status --short >output && |
| 111 | diff output - <<-\EOF |
| 112 | ? sub |
| 113 | EOF |
| 114 | ' |
| 115 | |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 116 | test_expect_success 'status with added and untracked file in submodule' ' |
Jens Lehmann | 85adbf2 | 2010-03-12 22:23:52 +0100 | [diff] [blame] | 117 | (cd sub && git reset --hard && echo >foo && git add foo) && |
| 118 | echo "content" >sub/new-file && |
| 119 | git status >output && |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 120 | test_i18ngrep "modified: sub (modified content, untracked content)" output |
Jens Lehmann | 85adbf2 | 2010-03-12 22:23:52 +0100 | [diff] [blame] | 121 | ' |
| 122 | |
| 123 | test_expect_success 'status with added and untracked file in submodule (porcelain)' ' |
| 124 | (cd sub && git reset --hard && echo >foo && git add foo) && |
| 125 | echo "content" >sub/new-file && |
| 126 | git status --porcelain >output && |
| 127 | diff output - <<-\EOF |
| 128 | M sub |
| 129 | EOF |
| 130 | ' |
| 131 | |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 132 | test_expect_success 'status with modified file in modified submodule' ' |
Jens Lehmann | 85adbf2 | 2010-03-12 22:23:52 +0100 | [diff] [blame] | 133 | (cd sub && git reset --hard) && |
| 134 | rm sub/new-file && |
| 135 | (cd sub && echo "next change" >foo && git commit -m "next change" foo) && |
| 136 | echo "changed" >sub/foo && |
| 137 | git status >output && |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 138 | test_i18ngrep "modified: sub (new commits, modified content)" output |
Jens Lehmann | 85adbf2 | 2010-03-12 22:23:52 +0100 | [diff] [blame] | 139 | ' |
| 140 | |
| 141 | test_expect_success 'status with modified file in modified submodule (porcelain)' ' |
| 142 | (cd sub && git reset --hard) && |
| 143 | echo "changed" >sub/foo && |
| 144 | git status --porcelain >output && |
| 145 | diff output - <<-\EOF |
| 146 | M sub |
| 147 | EOF |
| 148 | ' |
| 149 | |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 150 | test_expect_success 'status with added file in modified submodule' ' |
Jens Lehmann | 85adbf2 | 2010-03-12 22:23:52 +0100 | [diff] [blame] | 151 | (cd sub && git reset --hard && echo >foo && git add foo) && |
| 152 | git status >output && |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 153 | test_i18ngrep "modified: sub (new commits, modified content)" output |
Jens Lehmann | 85adbf2 | 2010-03-12 22:23:52 +0100 | [diff] [blame] | 154 | ' |
| 155 | |
| 156 | test_expect_success 'status with added file in modified submodule (porcelain)' ' |
| 157 | (cd sub && git reset --hard && echo >foo && git add foo) && |
| 158 | git status --porcelain >output && |
| 159 | diff output - <<-\EOF |
| 160 | M sub |
| 161 | EOF |
| 162 | ' |
| 163 | |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 164 | test_expect_success 'status with untracked file in modified submodule' ' |
Jens Lehmann | 85adbf2 | 2010-03-12 22:23:52 +0100 | [diff] [blame] | 165 | (cd sub && git reset --hard) && |
| 166 | echo "content" >sub/new-file && |
| 167 | git status >output && |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 168 | test_i18ngrep "modified: sub (new commits, untracked content)" output |
Jens Lehmann | 85adbf2 | 2010-03-12 22:23:52 +0100 | [diff] [blame] | 169 | ' |
| 170 | |
| 171 | test_expect_success 'status with untracked file in modified submodule (porcelain)' ' |
| 172 | git status --porcelain >output && |
| 173 | diff output - <<-\EOF |
| 174 | M sub |
| 175 | EOF |
| 176 | ' |
| 177 | |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 178 | test_expect_success 'status with added and untracked file in modified submodule' ' |
Jens Lehmann | 85adbf2 | 2010-03-12 22:23:52 +0100 | [diff] [blame] | 179 | (cd sub && git reset --hard && echo >foo && git add foo) && |
| 180 | echo "content" >sub/new-file && |
| 181 | git status >output && |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 182 | test_i18ngrep "modified: sub (new commits, modified content, untracked content)" output |
Jens Lehmann | 85adbf2 | 2010-03-12 22:23:52 +0100 | [diff] [blame] | 183 | ' |
| 184 | |
| 185 | test_expect_success 'status with added and untracked file in modified submodule (porcelain)' ' |
| 186 | (cd sub && git reset --hard && echo >foo && git add foo) && |
| 187 | echo "content" >sub/new-file && |
| 188 | git status --porcelain >output && |
| 189 | diff output - <<-\EOF |
| 190 | M sub |
| 191 | EOF |
| 192 | ' |
| 193 | |
Jens Lehmann | eee49b6 | 2010-04-10 19:01:12 +0200 | [diff] [blame] | 194 | test_expect_success 'setup .git file for sub' ' |
| 195 | (cd sub && |
Eric Sunshine | e974e06 | 2018-07-01 20:24:03 -0400 | [diff] [blame] | 196 | rm -f new-file && |
Jens Lehmann | eee49b6 | 2010-04-10 19:01:12 +0200 | [diff] [blame] | 197 | REAL="$(pwd)/../.real" && |
Eric Sunshine | e974e06 | 2018-07-01 20:24:03 -0400 | [diff] [blame] | 198 | mv .git "$REAL" && |
Jens Lehmann | eee49b6 | 2010-04-10 19:01:12 +0200 | [diff] [blame] | 199 | echo "gitdir: $REAL" >.git) && |
| 200 | echo .real >>.gitignore && |
| 201 | git commit -m "added .real to .gitignore" .gitignore |
| 202 | ' |
| 203 | |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 204 | test_expect_success 'status with added file in modified submodule with .git file' ' |
Jens Lehmann | eee49b6 | 2010-04-10 19:01:12 +0200 | [diff] [blame] | 205 | (cd sub && git reset --hard && echo >foo && git add foo) && |
| 206 | git status >output && |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 207 | test_i18ngrep "modified: sub (new commits, modified content)" output |
Jens Lehmann | eee49b6 | 2010-04-10 19:01:12 +0200 | [diff] [blame] | 208 | ' |
| 209 | |
Stefan Beller | af6865a | 2017-03-24 17:36:06 -0700 | [diff] [blame] | 210 | test_expect_success 'status with a lot of untracked files in the submodule' ' |
| 211 | ( |
Eric Sunshine | e974e06 | 2018-07-01 20:24:03 -0400 | [diff] [blame] | 212 | cd sub && |
Stefan Beller | af6865a | 2017-03-24 17:36:06 -0700 | [diff] [blame] | 213 | i=0 && |
| 214 | while test $i -lt 1024 |
| 215 | do |
Eric Sunshine | e974e06 | 2018-07-01 20:24:03 -0400 | [diff] [blame] | 216 | >some-file-$i && |
| 217 | i=$(( $i + 1 )) || exit 1 |
Stefan Beller | af6865a | 2017-03-24 17:36:06 -0700 | [diff] [blame] | 218 | done |
| 219 | ) && |
| 220 | git status --porcelain sub 2>err.actual && |
| 221 | test_must_be_empty err.actual && |
| 222 | rm err.actual |
| 223 | ' |
| 224 | |
Ping Yin | 27bfd95 | 2008-05-02 21:35:34 +0800 | [diff] [blame] | 225 | test_expect_success 'rm submodule contents' ' |
Stefan Beller | af6865a | 2017-03-24 17:36:06 -0700 | [diff] [blame] | 226 | rm -rf sub && |
| 227 | mkdir sub |
Ping Yin | 27bfd95 | 2008-05-02 21:35:34 +0800 | [diff] [blame] | 228 | ' |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 229 | |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 230 | test_expect_success 'status clean (empty submodule dir)' ' |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 231 | git status >output && |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 232 | test_i18ngrep "nothing to commit" output |
Ping Yin | 27bfd95 | 2008-05-02 21:35:34 +0800 | [diff] [blame] | 233 | ' |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 234 | |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 235 | test_expect_success 'status -a clean (empty submodule dir)' ' |
Jens Lehmann | ee6fc51 | 2010-01-16 18:42:24 +0100 | [diff] [blame] | 236 | test_must_fail git commit --dry-run -a >output && |
Junio C Hamano | 7a23d2d | 2011-04-14 13:37:54 -0700 | [diff] [blame] | 237 | test_i18ngrep "nothing to commit" output |
Ping Yin | 27bfd95 | 2008-05-02 21:35:34 +0800 | [diff] [blame] | 238 | ' |
| 239 | |
Heiko Voigt | 44ca0c8 | 2011-05-14 18:26:30 +0200 | [diff] [blame] | 240 | cat >status_expect <<\EOF |
| 241 | AA .gitmodules |
| 242 | A sub1 |
| 243 | EOF |
| 244 | |
Jens Lehmann | d4e98b5 | 2011-05-14 18:26:58 +0200 | [diff] [blame] | 245 | test_expect_success 'status with merge conflict in .gitmodules' ' |
Heiko Voigt | 44ca0c8 | 2011-05-14 18:26:30 +0200 | [diff] [blame] | 246 | git clone . super && |
| 247 | test_create_repo_with_commit sub1 && |
| 248 | test_tick && |
| 249 | test_create_repo_with_commit sub2 && |
| 250 | ( |
| 251 | cd super && |
| 252 | prev=$(git rev-parse HEAD) && |
| 253 | git checkout -b add_sub1 && |
| 254 | git submodule add ../sub1 && |
| 255 | git commit -m "add sub1" && |
| 256 | git checkout -b add_sub2 $prev && |
| 257 | git submodule add ../sub2 && |
| 258 | git commit -m "add sub2" && |
| 259 | git checkout -b merge_conflict_gitmodules && |
| 260 | test_must_fail git merge add_sub1 && |
| 261 | git status -s >../status_actual 2>&1 |
| 262 | ) && |
| 263 | test_cmp status_actual status_expect |
| 264 | ' |
| 265 | |
| 266 | sha1_merge_sub1=$(cd sub1 && git rev-parse HEAD) |
| 267 | sha1_merge_sub2=$(cd sub2 && git rev-parse HEAD) |
| 268 | short_sha1_merge_sub1=$(cd sub1 && git rev-parse --short HEAD) |
| 269 | short_sha1_merge_sub2=$(cd sub2 && git rev-parse --short HEAD) |
| 270 | cat >diff_expect <<\EOF |
| 271 | diff --cc .gitmodules |
| 272 | index badaa4c,44f999a..0000000 |
| 273 | --- a/.gitmodules |
| 274 | +++ b/.gitmodules |
| 275 | @@@ -1,3 -1,3 +1,9 @@@ |
| 276 | ++<<<<<<< HEAD |
| 277 | +[submodule "sub2"] |
| 278 | + path = sub2 |
| 279 | + url = ../sub2 |
| 280 | ++======= |
| 281 | + [submodule "sub1"] |
| 282 | + path = sub1 |
| 283 | + url = ../sub1 |
| 284 | ++>>>>>>> add_sub1 |
| 285 | EOF |
| 286 | |
| 287 | cat >diff_submodule_expect <<\EOF |
| 288 | diff --cc .gitmodules |
| 289 | index badaa4c,44f999a..0000000 |
| 290 | --- a/.gitmodules |
| 291 | +++ b/.gitmodules |
| 292 | @@@ -1,3 -1,3 +1,9 @@@ |
| 293 | ++<<<<<<< HEAD |
| 294 | +[submodule "sub2"] |
| 295 | + path = sub2 |
| 296 | + url = ../sub2 |
| 297 | ++======= |
| 298 | + [submodule "sub1"] |
| 299 | + path = sub1 |
| 300 | + url = ../sub1 |
| 301 | ++>>>>>>> add_sub1 |
| 302 | EOF |
| 303 | |
Jens Lehmann | d4e98b5 | 2011-05-14 18:26:58 +0200 | [diff] [blame] | 304 | test_expect_success 'diff with merge conflict in .gitmodules' ' |
Heiko Voigt | 44ca0c8 | 2011-05-14 18:26:30 +0200 | [diff] [blame] | 305 | ( |
| 306 | cd super && |
| 307 | git diff >../diff_actual 2>&1 |
| 308 | ) && |
Stefan Beller | 9c5b2fa | 2017-10-06 12:00:06 -0700 | [diff] [blame] | 309 | test_cmp diff_expect diff_actual |
Heiko Voigt | 44ca0c8 | 2011-05-14 18:26:30 +0200 | [diff] [blame] | 310 | ' |
| 311 | |
Jens Lehmann | d4e98b5 | 2011-05-14 18:26:58 +0200 | [diff] [blame] | 312 | test_expect_success 'diff --submodule with merge conflict in .gitmodules' ' |
Heiko Voigt | 44ca0c8 | 2011-05-14 18:26:30 +0200 | [diff] [blame] | 313 | ( |
| 314 | cd super && |
| 315 | git diff --submodule >../diff_submodule_actual 2>&1 |
| 316 | ) && |
Stefan Beller | 9c5b2fa | 2017-10-06 12:00:06 -0700 | [diff] [blame] | 317 | test_cmp diff_submodule_expect diff_submodule_actual |
Heiko Voigt | 44ca0c8 | 2011-05-14 18:26:30 +0200 | [diff] [blame] | 318 | ' |
| 319 | |
Stefan Beller | dd6962d | 2017-03-29 15:26:15 -0700 | [diff] [blame] | 320 | # We'll setup different cases for further testing: |
| 321 | # sub1 will contain a nested submodule, |
| 322 | # sub2 will have an untracked file |
| 323 | # sub3 will have an untracked repository |
| 324 | test_expect_success 'setup superproject with untracked file in nested submodule' ' |
| 325 | ( |
| 326 | cd super && |
| 327 | git clean -dfx && |
Antonio Ospite | 23dd8f5 | 2018-10-05 15:05:58 +0200 | [diff] [blame] | 328 | git rm .gitmodules && |
| 329 | git commit -m "remove .gitmodules" && |
Stefan Beller | dd6962d | 2017-03-29 15:26:15 -0700 | [diff] [blame] | 330 | git submodule add -f ./sub1 && |
| 331 | git submodule add -f ./sub2 && |
| 332 | git submodule add -f ./sub1 sub3 && |
| 333 | git commit -a -m "messy merge in superproject" && |
| 334 | ( |
| 335 | cd sub1 && |
| 336 | git submodule add ../sub2 && |
| 337 | git commit -a -m "add sub2 to sub1" |
| 338 | ) && |
| 339 | git add sub1 && |
| 340 | git commit -a -m "update sub1 to contain nested sub" |
| 341 | ) && |
| 342 | echo content >super/sub1/sub2/file && |
| 343 | echo content >super/sub2/file && |
| 344 | git -C super/sub3 clone ../../sub2 untracked_repository |
| 345 | ' |
| 346 | |
| 347 | test_expect_success 'status with untracked file in nested submodule (porcelain)' ' |
| 348 | git -C super status --porcelain >output && |
| 349 | diff output - <<-\EOF |
| 350 | M sub1 |
| 351 | M sub2 |
| 352 | M sub3 |
| 353 | EOF |
| 354 | ' |
| 355 | |
| 356 | test_expect_success 'status with untracked file in nested submodule (porcelain=2)' ' |
| 357 | git -C super status --porcelain=2 >output && |
| 358 | sanitize_output output && |
| 359 | diff output - <<-\EOF |
Stefan Beller | 40069d6 | 2017-03-29 15:26:16 -0700 | [diff] [blame] | 360 | 1 .M S..U 160000 160000 160000 HASH HASH sub1 |
Stefan Beller | dd6962d | 2017-03-29 15:26:15 -0700 | [diff] [blame] | 361 | 1 .M S..U 160000 160000 160000 HASH HASH sub2 |
| 362 | 1 .M S..U 160000 160000 160000 HASH HASH sub3 |
| 363 | EOF |
| 364 | ' |
| 365 | |
| 366 | test_expect_success 'status with untracked file in nested submodule (short)' ' |
| 367 | git -C super status --short >output && |
| 368 | diff output - <<-\EOF |
Stefan Beller | 40069d6 | 2017-03-29 15:26:16 -0700 | [diff] [blame] | 369 | ? sub1 |
Stefan Beller | dd6962d | 2017-03-29 15:26:15 -0700 | [diff] [blame] | 370 | ? sub2 |
| 371 | ? sub3 |
| 372 | EOF |
| 373 | ' |
| 374 | |
| 375 | test_expect_success 'setup superproject with modified file in nested submodule' ' |
| 376 | git -C super/sub1/sub2 add file && |
| 377 | git -C super/sub2 add file |
| 378 | ' |
| 379 | |
| 380 | test_expect_success 'status with added file in nested submodule (porcelain)' ' |
| 381 | git -C super status --porcelain >output && |
| 382 | diff output - <<-\EOF |
| 383 | M sub1 |
| 384 | M sub2 |
| 385 | M sub3 |
| 386 | EOF |
| 387 | ' |
| 388 | |
| 389 | test_expect_success 'status with added file in nested submodule (porcelain=2)' ' |
| 390 | git -C super status --porcelain=2 >output && |
| 391 | sanitize_output output && |
| 392 | diff output - <<-\EOF |
| 393 | 1 .M S.M. 160000 160000 160000 HASH HASH sub1 |
| 394 | 1 .M S.M. 160000 160000 160000 HASH HASH sub2 |
| 395 | 1 .M S..U 160000 160000 160000 HASH HASH sub3 |
| 396 | EOF |
| 397 | ' |
| 398 | |
| 399 | test_expect_success 'status with added file in nested submodule (short)' ' |
| 400 | git -C super status --short >output && |
| 401 | diff output - <<-\EOF |
| 402 | m sub1 |
| 403 | m sub2 |
| 404 | ? sub3 |
| 405 | EOF |
| 406 | ' |
| 407 | |
Ping Yin | 27bfd95 | 2008-05-02 21:35:34 +0800 | [diff] [blame] | 408 | test_done |