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 "$(cd super-clone/submodule &&
60git config remote.origin.url
61)" &&
62(cd super-clone/submodule &&
63git checkout master &&
64git pull
65) &&
66(cd super-clone &&
67test -d "$(git config submodule.submodule.url)"
68)
69'
7071
test_expect_success '"git submodule sync" should update known submodule URLs' '
72(cd empty-clone &&
73git pull &&
74git submodule sync &&
75test -d "$(git config submodule.submodule.url)"
76)
77'
7879
test_expect_success '"git submodule sync" should not vivify uninteresting submodule' '
80(cd top-only-clone &&
81git pull &&
82git submodule sync &&
83test -z "$(git config submodule.submodule.url)" &&
84git submodule sync submodule &&
85test -z "$(git config submodule.submodule.url)"
86)
87'
8889
test_done