stash: teach quiet option
[git/mjg.git] / t / t7406-submodule-update.sh
blob0773fe405bb792e82b658c7cea2d8815163ccd19
1 #!/bin/sh
3 # Copyright (c) 2009 Red Hat, Inc.
6 test_description='Test updating submodules
8 This test verifies that "git submodule update" detaches the HEAD of the
9 submodule and "git submodule update --rebase" does not detach the HEAD.
12 . ./test-lib.sh
15 compare_head()
17 sha_master=`git-rev-list --max-count=1 master`
18 sha_head=`git-rev-list --max-count=1 HEAD`
20 test "$sha_master" = "$sha_head"
24 test_expect_success 'setup a submodule tree' '
25 echo file > file &&
26 git add file &&
27 test_tick &&
28 git commit -m upstream
29 git clone . super &&
30 git clone super submodule &&
31 (cd super &&
32 git submodule add ../submodule submodule &&
33 test_tick &&
34 git commit -m "submodule" &&
35 git submodule init submodule
36 ) &&
37 (cd submodule &&
38 echo "line2" > file &&
39 git add file &&
40 git commit -m "Commit 2"
41 ) &&
42 (cd super &&
43 (cd submodule &&
44 git pull --rebase origin
45 ) &&
46 git add submodule &&
47 git commit -m "submodule update"
51 test_expect_success 'submodule update detaching the HEAD ' '
52 (cd super/submodule &&
53 git reset --hard HEAD~1
54 ) &&
55 (cd super &&
56 (cd submodule &&
57 compare_head
58 ) &&
59 git submodule update submodule &&
60 cd submodule &&
61 ! compare_head
65 test_expect_success 'submodule update --rebase staying on master' '
66 (cd super/submodule &&
67 git checkout master
68 ) &&
69 (cd super &&
70 (cd submodule &&
71 compare_head
72 ) &&
73 git submodule update --rebase submodule &&
74 cd submodule &&
75 compare_head
79 test_expect_success 'submodule update - rebase in .git/config' '
80 (cd super &&
81 git config submodule.submodule.update rebase
82 ) &&
83 (cd super/submodule &&
84 git reset --hard HEAD~1
85 ) &&
86 (cd super &&
87 (cd submodule &&
88 compare_head
89 ) &&
90 git submodule update submodule &&
91 cd submodule &&
92 compare_head
96 test_expect_success 'submodule update - checkout in .git/config but --rebase given' '
97 (cd super &&
98 git config submodule.submodule.update checkout
99 ) &&
100 (cd super/submodule &&
101 git reset --hard HEAD~1
102 ) &&
103 (cd super &&
104 (cd submodule &&
105 compare_head
106 ) &&
107 git submodule update --rebase submodule &&
108 cd submodule &&
109 compare_head
113 test_expect_success 'submodule update - checkout in .git/config' '
114 (cd super &&
115 git config submodule.submodule.update checkout
116 ) &&
117 (cd super/submodule &&
118 git reset --hard HEAD^
119 ) &&
120 (cd super &&
121 (cd submodule &&
122 compare_head
123 ) &&
124 git submodule update submodule &&
125 cd submodule &&
126 ! compare_head
130 test_expect_success 'submodule init picks up rebase' '
131 (cd super &&
132 git config submodule.rebasing.url git://non-existing/git &&
133 git config submodule.rebasing.path does-not-matter &&
134 git config submodule.rebasing.update rebase &&
135 git submodule init rebasing &&
136 test "rebase" = $(git config submodule.rebasing.update)
140 test_done