@matheusbsbs / matheus-bagliano / commits / b1a6c0a96f
Fork 0

add tests of commit --fixup

t7500: test expected behavior of commit --fixup t3415: test interaction of commit --fixup with rebase --autosquash t3900: test commit --fixup with i18n encodings Signed-off-by: Pat Notz <patnotz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Pat Notz committed Nov 2, 2010 at 13:59 UTC b1a6c0a96f70fe39958b3315a99667740497d703
3 files changed +83 -2
t/t3415-rebase-autosquash.sh
+23 -2
@@ -14,6 +14,7 @@ test_expect_success setup '
14 git add . &&
15 test_tick &&
16 git commit -m "first commit" &&
17 + git tag first-commit &&
18 echo 3 >file3 &&
19 git add . &&
20 test_tick &&
@@ -21,7 +22,7 @@ test_expect_success setup '
22 git tag base
23 '
24
24 -test_auto_fixup() {
25 +test_auto_fixup () {
26 git reset --hard base &&
27 echo 1 >file1 &&
28 git add -u &&
@@ -50,7 +51,7 @@ test_expect_success 'auto fixup (config)' '
51 test_must_fail test_auto_fixup final-fixup-config-false
52 '
53
53 -test_auto_squash() {
54 +test_auto_squash () {
55 git reset --hard base &&
56 echo 1 >file1 &&
57 git add -u &&
@@ -94,4 +95,24 @@ test_expect_success 'misspelled auto squash' '
95 test 0 = $(git rev-list final-missquash...HEAD | wc -l)
96 '
97
98 +test_auto_commit_flags () {
99 + git reset --hard base &&
100 + echo 1 >file1 &&
101 + git add -u &&
102 + test_tick &&
103 + git commit --$1 first-commit &&
104 + git tag final-commit-$1 &&
105 + test_tick &&
106 + git rebase --autosquash -i HEAD^^^ &&
107 + git log --oneline >actual &&
108 + test 3 = $(wc -l <actual) &&
109 + git diff --exit-code final-commit-$1 &&
110 + test 1 = "$(git cat-file blob HEAD^:file1)" &&
111 + test $2 = $(git cat-file commit HEAD^ | grep first | wc -l)
112 +}
113 +
114 +test_expect_success 'use commit --fixup' '
115 + test_auto_commit_flags fixup 1
116 +'
117 +
118 test_done
t/t3900-i18n-commit.sh
+27
@@ -133,4 +133,31 @@ do
133 '
134 done
135
136 +test_commit_autosquash_flags () {
137 + H=$1
138 + flag=$2
139 + test_expect_success "commit --$flag with $H encoding" '
140 + git config i18n.commitencoding $H &&
141 + git checkout -b $H-$flag C0 &&
142 + echo $H >>F &&
143 + git commit -a -F "$TEST_DIRECTORY"/t3900/$H.txt &&
144 + test_tick &&
145 + echo intermediate stuff >>G &&
146 + git add G &&
147 + git commit -a -m "intermediate commit" &&
148 + test_tick &&
149 + echo $H $flag >>F &&
150 + git commit -a --$flag HEAD~1 $3 &&
151 + E=$(git cat-file commit '$H-$flag' |
152 + sed -ne "s/^encoding //p") &&
153 + test "z$E" = "z$H" &&
154 + git config --unset-all i18n.commitencoding &&
155 + git rebase --autosquash -i HEAD^^^ &&
156 + git log --oneline >actual &&
157 + test 3 = $(wc -l <actual)
158 + '
159 +}
160 +
161 +test_commit_autosquash_flags eucJP fixup
162 +
163 test_done
t/t7500-commit.sh
+33
@@ -215,4 +215,37 @@ test_expect_success 'Commit a message with --allow-empty-message' '
215 commit_msg_is "hello there"
216 '
217
218 +commit_for_rebase_autosquash_setup () {
219 + echo "first content line" >>foo &&
220 + git add foo &&
221 + cat >log <<EOF &&
222 +target message subject line
223 +
224 +target message body line 1
225 +target message body line 2
226 +EOF
227 + git commit -F log &&
228 + echo "second content line" >>foo &&
229 + git add foo &&
230 + git commit -m "intermediate commit" &&
231 + echo "third content line" >>foo &&
232 + git add foo
233 +}
234 +
235 +test_expect_success 'commit --fixup provides correct one-line commit message' '
236 + commit_for_rebase_autosquash_setup &&
237 + git commit --fixup HEAD~1 &&
238 + commit_msg_is "fixup! target message subject line"
239 +'
240 +
241 +test_expect_success 'invalid message options when using --fixup' '
242 + echo changes >>foo &&
243 + echo "message" >log &&
244 + git add foo &&
245 + test_must_fail git commit --fixup HEAD~1 -C HEAD~2 &&
246 + test_must_fail git commit --fixup HEAD~1 -c HEAD~2 &&
247 + test_must_fail git commit --fixup HEAD~1 -m "cmdline message" &&
248 + test_must_fail git commit --fixup HEAD~1 -F log
249 +'
250 +
251 test_done