3 test_description
='auto squash'
7 test_expect_success setup
'
11 git commit -m "initial commit" &&
16 git commit -m "first commit" &&
20 git commit -m "second commit" &&
25 git
reset --hard base
&&
29 git commit
-m "fixup! first" &&
33 git rebase
$2 -i HEAD^^^
&&
34 git log
--oneline >actual
&&
35 test 3 = $
(wc -l <actual
) &&
36 git
diff --exit-code $1 &&
37 test 1 = "$(git cat-file blob HEAD^:file1)" &&
38 test 1 = $
(git cat-file commit HEAD^ |
grep first |
wc -l)
41 test_expect_success
'auto fixup (option)' '
42 test_auto_fixup final-fixup-option --autosquash
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
54 git
reset --hard base
&&
58 git commit
-m "squash! first" &&
62 git rebase
$2 -i HEAD^^^
&&
63 git log
--oneline >actual
&&
64 test 3 = $
(wc -l <actual
) &&
65 git
diff --exit-code $1 &&
66 test 1 = "$(git cat-file blob HEAD^:file1)" &&
67 test 2 = $
(git cat-file commit HEAD^ |
grep first |
wc -l)
70 test_expect_success
'auto squash (option)' '
71 test_auto_squash final-squash --autosquash
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
82 test_expect_success
'misspelled auto squash' '
83 git reset --hard base &&
87 git commit -m "squash! forst" &&
88 git tag final-missquash &&
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)
97 test_expect_success
'auto squash that matches 2 commits' '
98 git reset --hard base &&
102 git commit -m "first new commit" &&
106 git commit -m "squash! first" &&
107 git tag final-multisquash &&
109 git rebase --autosquash -i HEAD~4 &&
110 git log --oneline >actual &&
111 test 4 = $(wc -l <actual) &&
112 git diff --exit-code final-multisquash &&
113 test 1 = "$(git cat-file blob HEAD^^:file1)" &&
114 test 2 = $(git cat-file commit HEAD^^ | grep first | wc -l) &&
115 test 1 = $(git cat-file commit HEAD | grep first | wc -l)
118 test_expect_success
'auto squash that matches a commit after the squash' '
119 git reset --hard base &&
123 git commit -m "squash! third" &&
127 git commit -m "third commit" &&
128 git tag final-presquash &&
130 git rebase --autosquash -i HEAD~4 &&
131 git log --oneline >actual &&
132 test 5 = $(wc -l <actual) &&
133 git diff --exit-code final-presquash &&
134 test 0 = "$(git cat-file blob HEAD^^:file1)" &&
135 test 1 = "$(git cat-file blob HEAD^:file1)" &&
136 test 1 = $(git cat-file commit HEAD | grep third | wc -l) &&
137 test 1 = $(git cat-file commit HEAD^ | grep third | wc -l)
139 test_expect_success
'auto squash that matches a sha1' '
140 git reset --hard base &&
144 git commit -m "squash! $(git rev-parse --short HEAD^)" &&
145 git tag final-shasquash &&
147 git rebase --autosquash -i HEAD^^^ &&
148 git log --oneline >actual &&
149 test 3 = $(wc -l <actual) &&
150 git diff --exit-code final-shasquash &&
151 test 1 = "$(git cat-file blob HEAD^:file1)" &&
152 test 1 = $(git cat-file commit HEAD^ | grep squash | wc -l)
155 test_expect_success
'auto squash that matches longer sha1' '
156 git reset --hard base &&
160 git commit -m "squash! $(git rev-parse --short=11 HEAD^)" &&
161 git tag final-longshasquash &&
163 git rebase --autosquash -i HEAD^^^ &&
164 git log --oneline >actual &&
165 test 3 = $(wc -l <actual) &&
166 git diff --exit-code final-longshasquash &&
167 test 1 = "$(git cat-file blob HEAD^:file1)" &&
168 test 1 = $(git cat-file commit HEAD^ | grep squash | wc -l)