Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t7401-submodule-summary.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t7401-submodule-summary.sh` 319 lines ยท 6536 bytes Raw Blame History 1 #!/bin/sh 2 # 3 # Copyright (c) 2008 Ping Yin 4 # 5 6 test_description='Summary support for submodules 7 8 This test script tries to verify the sanity of summary subcommand of git submodule. 9 ' 10 11 # NOTE: This test script uses 'git add' instead of 'git submodule add' to add 12 # submodules to the superproject. Some submodule subcommands such as init and 13 # deinit might not work as expected in this script. t7421 does not have this 14 # caveat. 15 # 16 # NEEDSWORK: This test script is old fashioned and may need a big cleanup due to 17 # various reasons, one of them being that there are lots of commands taking place 18 # outside of 'test_expect_success' block, which is no longer in good-style. 19 20 . ./test-lib.sh 21 22 add_file () { 23 sm=$1 24 shift 25 owd=$(pwd) 26 cd "$sm" 27 for name; do 28 echo "$name" >"$name" && 29 git add "$name" && 30 test_tick && 31 git commit -m "Add $name" 32 done >/dev/null 33 git rev-parse --short HEAD 34 cd "$owd" 35 } 36 commit_file () { 37 test_tick && 38 git commit "$@" -m "Commit $*" >/dev/null 39 } 40 41 test_expect_success 'setup submodule' ' 42 git init sm1 && 43 add_file . foo && 44 head1=$(add_file sm1 foo1 foo2) 45 ' 46 47 test_expect_success 'added submodule' " 48 git add sm1 && 49 git submodule summary >actual && 50 cat >expected <<-EOF && 51 * sm1 `0000000`...$head1 (2): 52 > Add foo2 53 54 EOF 55 test_cmp expected actual 56 " 57 58 test_expect_success 'added submodule (subdirectory)' " 59 mkdir sub && 60 ( 61 cd sub && 62 git submodule summary >../actual 63 ) && 64 cat >expected <<-EOF && 65 * ../sm1 `0000000`...$head1 (2): 66 > Add foo2 67 68 EOF 69 test_cmp expected actual 70 " 71 72 test_expect_success 'added submodule (subdirectory only)' " 73 ( 74 cd sub && 75 git submodule summary . >../actual 76 ) && 77 test_must_be_empty actual 78 " 79 80 test_expect_success 'added submodule (subdirectory with explicit path)' " 81 ( 82 cd sub && 83 git submodule summary ../sm1 >../actual 84 ) && 85 cat >expected <<-EOF && 86 * ../sm1 `0000000`...$head1 (2): 87 > Add foo2 88 89 EOF 90 test_cmp expected actual 91 " 92 93 commit_file sm1 && 94 head2=$(add_file sm1 foo3) 95 96 test_expect_success 'modified submodule(forward)' " 97 git submodule summary >actual && 98 cat >expected <<-EOF && 99 * sm1 $head1...$head2 (1): 100 > Add foo3 101 102 EOF 103 test_cmp expected actual 104 " 105 106 test_expect_success 'modified submodule(forward), --files' " 107 git submodule summary --files >actual && 108 cat >expected <<-EOF && 109 * sm1 $head1...$head2 (1): 110 > Add foo3 111 112 EOF 113 test_cmp expected actual 114 " 115 116 test_expect_success 'no ignore=all setting has any effect' " 117 git config -f .gitmodules submodule.sm1.path sm1 && 118 git config -f .gitmodules submodule.sm1.ignore all && 119 git config submodule.sm1.ignore all && 120 git config diff.ignoreSubmodules all && 121 git submodule summary >actual && 122 cat >expected <<-EOF && 123 * sm1 $head1...$head2 (1): 124 > Add foo3 125 126 EOF 127 test_cmp expected actual && 128 git config --unset diff.ignoreSubmodules && 129 git config --remove-section submodule.sm1 && 130 git config -f .gitmodules --remove-section submodule.sm1 131 " 132 133 134 commit_file sm1 && 135 head3=$( 136 cd sm1 && 137 git reset --hard HEAD~2 >/dev/null && 138 git rev-parse --short HEAD 139 ) 140 141 test_expect_success 'modified submodule(backward)' " 142 git submodule summary >actual && 143 cat >expected <<-EOF && 144 * sm1 $head2...$head3 (2): 145 < Add foo3 146 < Add foo2 147 148 EOF 149 test_cmp expected actual 150 " 151 152 head4=$(add_file sm1 foo4 foo5) && 153 head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD) 154 test_expect_success 'modified submodule(backward and forward)' " 155 git submodule summary >actual && 156 cat >expected <<-EOF && 157 * sm1 $head2...$head4 (4): 158 > Add foo5 159 > Add foo4 160 < Add foo3 161 < Add foo2 162 163 EOF 164 test_cmp expected actual 165 " 166 167 test_expect_success '--summary-limit' " 168 git submodule summary -n 3 >actual && 169 cat >expected <<-EOF && 170 * sm1 $head2...$head4 (4): 171 > Add foo5 172 > Add foo4 173 < Add foo3 174 175 EOF 176 test_cmp expected actual 177 " 178 179 commit_file sm1 && 180 mv sm1 sm1-bak && 181 echo sm1 >sm1 && 182 head5=$(git hash-object sm1 | cut -c1-7) && 183 git add sm1 && 184 rm -f sm1 && 185 mv sm1-bak sm1 186 187 test_expect_success 'typechanged submodule(submodule->blob), --cached' " 188 git submodule summary --cached >actual && 189 cat >expected <<-EOF && 190 * sm1 $head4(submodule)->$head5(blob) (3): 191 < Add foo5 192 193 EOF 194 test_cmp expected actual 195 " 196 197 test_expect_success 'typechanged submodule(submodule->blob), --files' " 198 git submodule summary --files >actual && 199 cat >expected <<-EOF && 200 * sm1 $head5(blob)->$head4(submodule) (3): 201 > Add foo5 202 203 EOF 204 test_cmp expected actual 205 " 206 207 rm -rf sm1 && 208 git checkout-index sm1 209 test_expect_success 'typechanged submodule(submodule->blob)' " 210 git submodule summary >actual && 211 cat >expected <<-EOF && 212 * sm1 $head4(submodule)->$head5(blob): 213 214 EOF 215 test_cmp expected actual 216 " 217 218 test_expect_success 'setup submodule' ' 219 rm -f sm1 && 220 git init sm1 && 221 head6=$(add_file sm1 foo6 foo7) 222 ' 223 224 test_expect_success 'nonexistent commit' " 225 git submodule summary >actual && 226 cat >expected <<-EOF && 227 * sm1 $head4...$head6: 228 Warn: sm1 doesn't contain commit $head4_full 229 230 EOF 231 test_cmp expected actual 232 " 233 234 commit_file 235 test_expect_success 'typechanged submodule(blob->submodule)' " 236 git submodule summary >actual && 237 cat >expected <<-EOF && 238 * sm1 $head5(blob)->$head6(submodule) (2): 239 > Add foo7 240 241 EOF 242 test_cmp expected actual 243 " 244 245 commit_file sm1 && 246 rm -rf sm1 247 test_expect_success 'deleted submodule' " 248 git submodule summary >actual && 249 cat >expected <<-EOF && 250 * sm1 $head6...`0000000`: 251 252 EOF 253 test_cmp expected actual 254 " 255 256 test_expect_success 'create second submodule' ' 257 test_create_repo sm2 && 258 head7=$(add_file sm2 foo8 foo9) && 259 git add sm2 260 ' 261 262 test_expect_success 'multiple submodules' " 263 git submodule summary >actual && 264 cat >expected <<-EOF && 265 * sm1 $head6...`0000000`: 266 267 * sm2 `0000000`...$head7 (2): 268 > Add foo9 269 270 EOF 271 test_cmp expected actual 272 " 273 274 test_expect_success 'path filter' " 275 git submodule summary sm2 >actual && 276 cat >expected <<-EOF && 277 * sm2 `0000000`...$head7 (2): 278 > Add foo9 279 280 EOF 281 test_cmp expected actual 282 " 283 284 commit_file sm2 285 test_expect_success 'given commit' " 286 git submodule summary HEAD^ >actual && 287 cat >expected <<-EOF && 288 * sm1 $head6...`0000000`: 289 290 * sm2 `0000000`...$head7 (2): 291 > Add foo9 292 293 EOF 294 test_cmp expected actual 295 " 296 297 test_expect_success '--for-status' " 298 git submodule summary --for-status HEAD^ >actual && 299 test_cmp - actual <<-EOF 300 * sm1 $head6...`0000000`: 301 302 * sm2 `0000000`...$head7 (2): 303 > Add foo9 304 305 EOF 306 " 307 308 test_expect_success 'fail when using --files together with --cached' " 309 test_must_fail git submodule summary --files --cached 310 " 311 312 test_expect_success 'should not fail in an empty repo' " 313 git init xyzzy && 314 cd xyzzy && 315 git submodule summary >output 2>&1 && 316 test_must_be_empty output 317 " 318 319 test_done