Let t0000 pass on Windows again
[git/dscho.git] / t / t7401-submodule-summary.sh
blobd2d6d5be2593e9b15e51b3bffb6830406663ea20
1 #!/bin/sh
3 # Copyright (c) 2008 Ping Yin
6 test_description='Summary support for submodules
8 This test tries to verify the sanity of summary subcommand of git submodule.
11 case $(uname -s) in
12 *MINGW*) GIT_TEST_CMP="diff -uw";;
13 esac
15 . ./test-lib.sh
17 add_file () {
18 sm=$1
19 shift
20 owd=$(pwd)
21 cd "$sm"
22 for name; do
23 echo "$name" > "$name" &&
24 git add "$name" &&
25 test_tick &&
26 git commit -m "Add $name"
27 done >/dev/null
28 git rev-parse --verify HEAD | cut -c1-7
29 cd "$owd"
31 commit_file () {
32 test_tick &&
33 git commit "$@" -m "Commit $*" >/dev/null
36 test_create_repo sm1 &&
37 add_file . foo >/dev/null
39 head1=$(add_file sm1 foo1 foo2)
41 test_expect_success 'added submodule' "
42 git add sm1 &&
43 git submodule summary >actual &&
44 test_cmp actual - <<-EOF
45 * sm1 0000000...$head1 (2):
46 > Add foo2
48 EOF
51 commit_file sm1 &&
52 head2=$(add_file sm1 foo3)
54 test_expect_success 'modified submodule(forward)' "
55 git submodule summary >actual &&
56 test_cmp actual - <<-EOF
57 * sm1 $head1...$head2 (1):
58 > Add foo3
60 EOF
63 commit_file sm1 &&
64 cd sm1 &&
65 git reset --hard HEAD~2 >/dev/null &&
66 head3=$(git rev-parse --verify HEAD | cut -c1-7) &&
67 cd ..
69 test_expect_success 'modified submodule(backward)' "
70 git submodule summary >actual &&
71 test_cmp actual - <<-EOF
72 * sm1 $head2...$head3 (2):
73 < Add foo3
74 < Add foo2
76 EOF
79 head4=$(add_file sm1 foo4 foo5) &&
80 head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD)
81 test_expect_success 'modified submodule(backward and forward)' "
82 git submodule summary >actual &&
83 test_cmp actual - <<-EOF
84 * sm1 $head2...$head4 (4):
85 > Add foo5
86 > Add foo4
87 < Add foo3
88 < Add foo2
90 EOF
93 test_expect_success '--summary-limit' "
94 git submodule summary -n 3 >actual &&
95 test_cmp actual - <<-EOF
96 * sm1 $head2...$head4 (4):
97 > Add foo5
98 > Add foo4
99 < Add foo3
104 commit_file sm1 &&
105 mv sm1 sm1-bak &&
106 echo sm1 >sm1 &&
107 head5=$(git hash-object sm1 | cut -c1-7) &&
108 git add sm1 &&
109 rm -f sm1 &&
110 mv sm1-bak sm1
112 test_expect_success 'typechanged submodule(submodule->blob), --cached' "
113 git submodule summary --cached >actual &&
114 test_cmp actual - <<-EOF
115 * sm1 $head4(submodule)->$head5(blob) (3):
116 < Add foo5
121 rm -rf sm1 &&
122 git checkout-index sm1
123 test_expect_success 'typechanged submodule(submodule->blob)' "
124 git submodule summary >actual &&
125 test_cmp actual - <<-EOF
126 * sm1 $head4(submodule)->$head5(blob):
131 rm -f sm1 &&
132 test_create_repo sm1 &&
133 head6=$(add_file sm1 foo6 foo7)
134 test_expect_success 'nonexistent commit' "
135 git submodule summary >actual &&
136 test_cmp actual - <<-EOF
137 * sm1 $head4...$head6:
138 Warn: sm1 doesn't contain commit $head4_full
143 commit_file
144 test_expect_success 'typechanged submodule(blob->submodule)' "
145 git submodule summary >actual &&
146 test_cmp actual - <<-EOF
147 * sm1 $head5(blob)->$head6(submodule) (2):
148 > Add foo7
153 commit_file sm1 &&
154 rm -rf sm1
155 test_expect_success 'deleted submodule' "
156 git submodule summary >actual &&
157 test_cmp actual - <<-EOF
158 * sm1 $head6...0000000:
163 test_create_repo sm2 &&
164 head7=$(add_file sm2 foo8 foo9) &&
165 git add sm2
167 test_expect_success 'multiple submodules' "
168 git submodule summary >actual &&
169 test_cmp actual - <<-EOF
170 * sm1 $head6...0000000:
172 * sm2 0000000...$head7 (2):
173 > Add foo9
178 test_expect_success 'path filter' "
179 git submodule summary sm2 >actual &&
180 test_cmp actual - <<-EOF
181 * sm2 0000000...$head7 (2):
182 > Add foo9
187 commit_file sm2
188 test_expect_success 'given commit' "
189 git submodule summary HEAD^ >actual &&
190 test_cmp actual - <<-EOF
191 * sm1 $head6...0000000:
193 * sm2 0000000...$head7 (2):
194 > Add foo9
199 test_expect_success '--for-status' "
200 git submodule summary --for-status HEAD^ >actual &&
201 test_cmp actual - <<EOF
202 # Modified submodules:
204 # * sm1 $head6...0000000:
206 # * sm2 0000000...$head7 (2):
207 # > Add foo9
212 test_done