@@ -63,6 +63,10 @@ test_expect_success 'setup a submodule tree' '
63
63
git submodule add ../none none &&
64
64
test_tick &&
65
65
git commit -m "none"
66
+ ) &&
67
+ git clone . recursivesuper &&
68
+ ( cd recursivesuper
69
+ git submodule add ../super super
66
70
)
67
71
'
68
72
@@ -95,6 +99,35 @@ test_expect_success 'submodule update from subdirectory' '
95
99
)
96
100
'
97
101
102
+ supersha1=$( git -C super rev-parse HEAD)
103
+ mergingsha1=$( git -C super/merging rev-parse HEAD)
104
+ nonesha1=$( git -C super/none rev-parse HEAD)
105
+ rebasingsha1=$( git -C super/rebasing rev-parse HEAD)
106
+ submodulesha1=$( git -C super/submodule rev-parse HEAD)
107
+ pwd=$( pwd)
108
+
109
+ cat << EOF >expect
110
+ Submodule path '../super': checked out '$supersha1 '
111
+ Submodule 'merging' ($pwd /merging) registered for path '../super/merging'
112
+ Submodule 'none' ($pwd /none) registered for path '../super/none'
113
+ Submodule 'rebasing' ($pwd /rebasing) registered for path '../super/rebasing'
114
+ Submodule 'submodule' ($pwd /submodule) registered for path '../super/submodule'
115
+ Submodule path '../super/merging': checked out '$mergingsha1 '
116
+ Submodule path '../super/none': checked out '$nonesha1 '
117
+ Submodule path '../super/rebasing': checked out '$rebasingsha1 '
118
+ Submodule path '../super/submodule': checked out '$submodulesha1 '
119
+ EOF
120
+
121
+ test_expect_success ' submodule update --init --recursive from subdirectory' '
122
+ git -C recursivesuper/super reset --hard HEAD^ &&
123
+ (cd recursivesuper &&
124
+ mkdir tmp &&
125
+ cd tmp &&
126
+ git submodule update --init --recursive ../super >../../actual
127
+ ) &&
128
+ test_cmp expect actual
129
+ '
130
+
98
131
apos=" '" ;
99
132
test_expect_success ' submodule update does not fetch already present commits' '
100
133
(cd submodule &&
@@ -311,16 +344,59 @@ test_expect_success 'submodule update - command in .git/config' '
311
344
)
312
345
'
313
346
347
+ cat << EOF >expect
348
+ Execution of 'false $submodulesha1 ' failed in submodule path 'submodule'
349
+ EOF
350
+
314
351
test_expect_success ' submodule update - command in .git/config catches failure' '
315
352
(cd super &&
316
353
git config submodule.submodule.update "!false"
317
354
) &&
318
355
(cd super/submodule &&
319
- git reset --hard HEAD ^
356
+ git reset --hard $submodulesha1 ^
320
357
) &&
321
358
(cd super &&
322
- test_must_fail git submodule update submodule
323
- )
359
+ test_must_fail git submodule update submodule 2>../actual
360
+ ) &&
361
+ test_cmp actual expect
362
+ '
363
+
364
+ cat << EOF >expect
365
+ Execution of 'false $submodulesha1 ' failed in submodule path '../submodule'
366
+ EOF
367
+
368
+ test_expect_success ' submodule update - command in .git/config catches failure -- subdirectory' '
369
+ (cd super &&
370
+ git config submodule.submodule.update "!false"
371
+ ) &&
372
+ (cd super/submodule &&
373
+ git reset --hard $submodulesha1^
374
+ ) &&
375
+ (cd super &&
376
+ mkdir tmp && cd tmp &&
377
+ test_must_fail git submodule update ../submodule 2>../../actual
378
+ ) &&
379
+ test_cmp actual expect
380
+ '
381
+
382
+ cat << EOF >expect
383
+ Execution of 'false $submodulesha1 ' failed in submodule path '../super/submodule'
384
+ Failed to recurse into submodule path '../super'
385
+ EOF
386
+
387
+ test_expect_success ' recursive submodule update - command in .git/config catches failure -- subdirectory' '
388
+ (cd recursivesuper &&
389
+ git submodule update --remote super &&
390
+ git add super &&
391
+ git commit -m "update to latest to have more than one commit in submodules"
392
+ ) &&
393
+ git -C recursivesuper/super config submodule.submodule.update "!false" &&
394
+ git -C recursivesuper/super/submodule reset --hard $submodulesha1^ &&
395
+ (cd recursivesuper &&
396
+ mkdir -p tmp && cd tmp &&
397
+ test_must_fail git submodule update --recursive ../super 2>../../actual
398
+ ) &&
399
+ test_cmp actual expect
324
400
'
325
401
326
402
test_expect_success ' submodule init does not copy command into .git/config' '
0 commit comments