@@ -94,4 +94,78 @@ test_expect_success 'misspelled auto squash' '
9494 test 0 = $(git rev-list final-missquash...HEAD | wc -l)
9595'
9696
97+ test_expect_success ' auto squash that matches 2 commits' '
98+ git reset --hard base &&
99+ echo 4 >file4 &&
100+ git add file4 &&
101+ test_tick &&
102+ git commit -m "first new commit" &&
103+ echo 1 >file1 &&
104+ git add -u &&
105+ test_tick &&
106+ git commit -m "squash! first" &&
107+ git tag final-multisquash &&
108+ test_tick &&
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)
116+ '
117+
118+ test_expect_success ' auto squash that matches a commit after the squash' '
119+ git reset --hard base &&
120+ echo 1 >file1 &&
121+ git add -u &&
122+ test_tick &&
123+ git commit -m "squash! third" &&
124+ echo 4 >file4 &&
125+ git add file4 &&
126+ test_tick &&
127+ git commit -m "third commit" &&
128+ git tag final-presquash &&
129+ test_tick &&
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)
138+ '
139+ test_expect_success ' auto squash that matches a sha1' '
140+ git reset --hard base &&
141+ echo 1 >file1 &&
142+ git add -u &&
143+ test_tick &&
144+ git commit -m "squash! $(git rev-parse --short HEAD^)" &&
145+ git tag final-shasquash &&
146+ test_tick &&
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)
153+ '
154+
155+ test_expect_success ' auto squash that matches longer sha1' '
156+ git reset --hard base &&
157+ echo 1 >file1 &&
158+ git add -u &&
159+ test_tick &&
160+ git commit -m "squash! $(git rev-parse --short=11 HEAD^)" &&
161+ git tag final-longshasquash &&
162+ test_tick &&
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)
169+ '
170+
97171test_done
0 commit comments