]>
Commit | Line | Data |
---|---|---|
f59baa50 NS |
1 | #!/bin/sh |
2 | ||
3 | test_description='auto squash' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | test_expect_success setup ' | |
8 | echo 0 >file0 && | |
9 | git add . && | |
10 | test_tick && | |
11 | git commit -m "initial commit" && | |
12 | echo 0 >file1 && | |
13 | echo 2 >file2 && | |
14 | git add . && | |
15 | test_tick && | |
16 | git commit -m "first commit" && | |
17 | echo 3 >file3 && | |
18 | git add . && | |
19 | test_tick && | |
20 | git commit -m "second commit" && | |
21 | git tag base | |
22 | ' | |
23 | ||
dd1e5b31 | 24 | test_auto_fixup() { |
f59baa50 NS |
25 | git reset --hard base && |
26 | echo 1 >file1 && | |
27 | git add -u && | |
28 | test_tick && | |
a48fcd83 | 29 | git commit -m "fixup! first" && |
f59baa50 | 30 | |
dd1e5b31 | 31 | git tag $1 && |
f59baa50 | 32 | test_tick && |
dd1e5b31 | 33 | git rebase $2 -i HEAD^^^ && |
f59baa50 NS |
34 | git log --oneline >actual && |
35 | test 3 = $(wc -l <actual) && | |
dd1e5b31 | 36 | git diff --exit-code $1 && |
f59baa50 NS |
37 | test 1 = "$(git cat-file blob HEAD^:file1)" && |
38 | test 1 = $(git cat-file commit HEAD^ | grep first | wc -l) | |
dd1e5b31 HV |
39 | } |
40 | ||
41 | test_expect_success 'auto fixup (option)' ' | |
42 | test_auto_fixup final-fixup-option --autosquash | |
43 | ' | |
44 | ||
45 | test_expect_success 'auto fixup (config)' ' | |
46 | git config rebase.autosquash true && | |
47 | test_auto_fixup final-fixup-config-true && | |
48 | test_must_fail test_auto_fixup fixup-config-true-no --no-autosquash && | |
49 | git config rebase.autosquash false && | |
50 | test_must_fail test_auto_fixup final-fixup-config-false | |
f59baa50 NS |
51 | ' |
52 | ||
dd1e5b31 | 53 | test_auto_squash() { |
f59baa50 NS |
54 | git reset --hard base && |
55 | echo 1 >file1 && | |
56 | git add -u && | |
57 | test_tick && | |
a48fcd83 | 58 | git commit -m "squash! first" && |
f59baa50 | 59 | |
dd1e5b31 | 60 | git tag $1 && |
f59baa50 | 61 | test_tick && |
dd1e5b31 | 62 | git rebase $2 -i HEAD^^^ && |
f59baa50 NS |
63 | git log --oneline >actual && |
64 | test 3 = $(wc -l <actual) && | |
dd1e5b31 | 65 | git diff --exit-code $1 && |
f59baa50 NS |
66 | test 1 = "$(git cat-file blob HEAD^:file1)" && |
67 | test 2 = $(git cat-file commit HEAD^ | grep first | wc -l) | |
dd1e5b31 HV |
68 | } |
69 | ||
70 | test_expect_success 'auto squash (option)' ' | |
71 | test_auto_squash final-squash --autosquash | |
72 | ' | |
73 | ||
74 | test_expect_success 'auto squash (config)' ' | |
75 | git config rebase.autosquash true && | |
76 | test_auto_squash final-squash-config-true && | |
77 | test_must_fail test_auto_squash squash-config-true-no --no-autosquash && | |
78 | git config rebase.autosquash false && | |
79 | test_must_fail test_auto_squash final-squash-config-false | |
f59baa50 NS |
80 | ' |
81 | ||
82 | test_expect_success 'misspelled auto squash' ' | |
83 | git reset --hard base && | |
84 | echo 1 >file1 && | |
85 | git add -u && | |
86 | test_tick && | |
a48fcd83 | 87 | git commit -m "squash! forst" && |
f59baa50 NS |
88 | git tag final-missquash && |
89 | test_tick && | |
90 | git rebase --autosquash -i HEAD^^^ && | |
91 | git log --oneline >actual && | |
92 | test 4 = $(wc -l <actual) && | |
93 | git diff --exit-code final-missquash && | |
94 | test 0 = $(git rev-list final-missquash...HEAD | wc -l) | |
95 | ' | |
96 | ||
97 | test_done |