Code

Sync with 1.7.9.5
[git.git] / t / t5531-deep-submodule-push.sh
1 #!/bin/sh
3 test_description='unpack-objects'
5 . ./test-lib.sh
7 test_expect_success setup '
8         mkdir pub.git &&
9         GIT_DIR=pub.git git init --bare &&
10         GIT_DIR=pub.git git config receive.fsckobjects true &&
11         mkdir work &&
12         (
13                 cd work &&
14                 git init &&
15                 mkdir -p gar/bage &&
16                 (
17                         cd gar/bage &&
18                         git init &&
19                         >junk &&
20                         git add junk &&
21                         git commit -m "Initial junk"
22                 ) &&
23                 git add gar/bage &&
24                 git commit -m "Initial superproject"
25         )
26 '
28 test_expect_success push '
29         (
30                 cd work &&
31                 git push ../pub.git master
32         )
33 '
35 test_expect_success 'push if submodule has no remote' '
36         (
37                 cd work/gar/bage &&
38                 >junk2 &&
39                 git add junk2 &&
40                 git commit -m "Second junk"
41         ) &&
42         (
43                 cd work &&
44                 git add gar/bage &&
45                 git commit -m "Second commit for gar/bage" &&
46                 git push --recurse-submodules=check ../pub.git master
47         )
48 '
50 test_expect_success 'push fails if submodule commit not on remote' '
51         (
52                 cd work/gar &&
53                 git clone --bare bage ../../submodule.git &&
54                 cd bage &&
55                 git remote add origin ../../../submodule.git &&
56                 git fetch &&
57                 >junk3 &&
58                 git add junk3 &&
59                 git commit -m "Third junk"
60         ) &&
61         (
62                 cd work &&
63                 git add gar/bage &&
64                 git commit -m "Third commit for gar/bage" &&
65                 test_must_fail git push --recurse-submodules=check ../pub.git master
66         )
67 '
69 test_expect_success 'push succeeds after commit was pushed to remote' '
70         (
71                 cd work/gar/bage &&
72                 git push origin master
73         ) &&
74         (
75                 cd work &&
76                 git push --recurse-submodules=check ../pub.git master
77         )
78 '
80 test_expect_success 'push fails when commit on multiple branches if one branch has no remote' '
81         (
82                 cd work/gar/bage &&
83                 >junk4 &&
84                 git add junk4 &&
85                 git commit -m "Fourth junk"
86         ) &&
87         (
88                 cd work &&
89                 git branch branch2 &&
90                 git add gar/bage &&
91                 git commit -m "Fourth commit for gar/bage" &&
92                 git checkout branch2 &&
93                 (
94                         cd gar/bage &&
95                         git checkout HEAD~1
96                 ) &&
97                 >junk1 &&
98                 git add junk1 &&
99                 git commit -m "First junk" &&
100                 test_must_fail git push --recurse-submodules=check ../pub.git
101         )
104 test_expect_success 'push succeeds if submodule has no remote and is on the first superproject commit' '
105         git init --bare a
106         git clone a a1 &&
107         (
108                 cd a1 &&
109                 git init b
110                 (
111                         cd b &&
112                         >junk &&
113                         git add junk &&
114                         git commit -m "initial"
115                 ) &&
116                 git add b &&
117                 git commit -m "added submodule" &&
118                 git push --recurse-submodule=check origin master
119         )
122 test_done