1#!/bin/sh
2#
3# Copyright (c) 2008 David Aguilar
4#
56
test_description='git submodule sync
78
These tests exercise the "git submodule sync" subcommand.
9'
1011
. ./test-lib.sh
1213
test_expect_success setup '
14echo file > file &&
15git add file &&
16test_tick &&
17git commit -m upstream &&
18git clone . super &&
19git clone super submodule &&
20(cd super &&
21git submodule add ../submodule submodule &&
22test_tick &&
23git commit -m "submodule"
24) &&
25git clone super super-clone &&
26(cd super-clone && git submodule update --init) &&
27git clone super empty-clone &&
28(cd empty-clone && git submodule init) &&
29git clone super top-only-clone
30'
3132
test_expect_success 'change submodule' '
33(cd submodule &&
34echo second line >> file &&
35test_tick &&
36git commit -a -m "change submodule"
37)
38'
3940
test_expect_success 'change submodule url' '
41(cd super &&
42cd submodule &&
43git checkout master &&
44git pull
45) &&
46mv submodule moved-submodule &&
47(cd super &&
48git config -f .gitmodules submodule.submodule.url ../moved-submodule &&
49test_tick &&
50git commit -a -m moved-submodule
51)
52'
5354
test_expect_success '"git submodule sync" should update submodule URLs' '
55(cd super-clone &&
56git pull --no-recurse-submodules &&
57git submodule sync
58) &&
59test -d "$(git config -f super-clone/submodule/.git/config \
60remote.origin.url)" &&
61(cd super-clone/submodule &&
62git checkout master &&
63git pull
64) &&
65(cd super-clone &&
66test -d "$(git config submodule.submodule.url)"
67)
68'
6970
test_expect_success '"git submodule sync" should update known submodule URLs' '
71(cd empty-clone &&
72git pull &&
73git submodule sync &&
74test -d "$(git config submodule.submodule.url)"
75)
76'
7778
test_expect_success '"git submodule sync" should not vivify uninteresting submodule' '
79(cd top-only-clone &&
80git pull &&
81git submodule sync &&
82test -z "$(git config submodule.submodule.url)" &&
83git submodule sync submodule &&
84test -z "$(git config submodule.submodule.url)"
85)
86'
8788
test_done