submodule sync: do not auto-vivify uninteresting submodule
[git/git.git] / t / t7403-submodule-sync.sh
CommitLineData
52e8370b
DA
1#!/bin/sh
2#
3# Copyright (c) 2008 David Aguilar
4#
5
6test_description='git submodule sync
7
8These tests exercise the "git submodule sync" subcommand.
9'
10
11. ./test-lib.sh
12
13test_expect_success setup '
14 echo file > file &&
15 git add file &&
16 test_tick &&
0eb032d8 17 git commit -m upstream &&
52e8370b
DA
18 git clone . super &&
19 git clone super submodule &&
20 (cd super &&
21 git submodule add ../submodule submodule &&
22 test_tick &&
23 git commit -m "submodule"
24 ) &&
25 git clone super super-clone &&
33f072f8
AK
26 (cd super-clone && git submodule update --init) &&
27 git clone super empty-clone &&
ccee6086
JH
28 (cd empty-clone && git submodule init) &&
29 git clone super top-only-clone
52e8370b
DA
30'
31
32test_expect_success 'change submodule' '
33 (cd submodule &&
34 echo second line >> file &&
35 test_tick &&
36 git commit -a -m "change submodule"
37 )
38'
39
40test_expect_success 'change submodule url' '
41 (cd super &&
42 cd submodule &&
43 git checkout master &&
44 git pull
45 ) &&
46 mv submodule moved-submodule &&
47 (cd super &&
0eb032d8 48 git config -f .gitmodules submodule.submodule.url ../moved-submodule &&
52e8370b
DA
49 test_tick &&
50 git commit -a -m moved-submodule
51 )
52'
53
54test_expect_success '"git submodule sync" should update submodule URLs' '
55 (cd super-clone &&
56 git pull &&
57 git submodule sync
58 ) &&
59 test -d "$(git config -f super-clone/submodule/.git/config \
60 remote.origin.url)" &&
61 (cd super-clone/submodule &&
62 git checkout master &&
63 git pull
0b9dca43
DA
64 ) &&
65 (cd super-clone &&
66 test -d "$(git config submodule.submodule.url)"
52e8370b
DA
67 )
68'
69
ccee6086 70test_expect_success '"git submodule sync" should update known submodule URLs' '
33f072f8
AK
71 (cd empty-clone &&
72 git pull &&
73 git submodule sync &&
74 test -d "$(git config submodule.submodule.url)"
75 )
76'
77
ccee6086
JH
78test_expect_success '"git submodule sync" should not vivify uninteresting submodule' '
79 (cd top-only-clone &&
80 git pull &&
81 git submodule sync &&
82 test -z "$(git config submodule.submodule.url)" &&
83 git submodule sync submodule &&
84 test -z "$(git config submodule.submodule.url)"
85 )
86'
87
52e8370b 88test_done