Merge branch 'kb/maint-rebase-autosquash'
* kb/maint-rebase-autosquash: rebase: teach --autosquash to match on sha1 in addition to message rebase: better rearranging of fixup!/squash! lines with --autosquash
This commit is contained in:
@ -94,4 +94,78 @@ test_expect_success 'misspelled auto squash' '
|
||||
test 0 = $(git rev-list final-missquash...HEAD | wc -l)
|
||||
'
|
||||
|
||||
test_expect_success 'auto squash that matches 2 commits' '
|
||||
git reset --hard base &&
|
||||
echo 4 >file4 &&
|
||||
git add file4 &&
|
||||
test_tick &&
|
||||
git commit -m "first new commit" &&
|
||||
echo 1 >file1 &&
|
||||
git add -u &&
|
||||
test_tick &&
|
||||
git commit -m "squash! first" &&
|
||||
git tag final-multisquash &&
|
||||
test_tick &&
|
||||
git rebase --autosquash -i HEAD~4 &&
|
||||
git log --oneline >actual &&
|
||||
test 4 = $(wc -l <actual) &&
|
||||
git diff --exit-code final-multisquash &&
|
||||
test 1 = "$(git cat-file blob HEAD^^:file1)" &&
|
||||
test 2 = $(git cat-file commit HEAD^^ | grep first | wc -l) &&
|
||||
test 1 = $(git cat-file commit HEAD | grep first | wc -l)
|
||||
'
|
||||
|
||||
test_expect_success 'auto squash that matches a commit after the squash' '
|
||||
git reset --hard base &&
|
||||
echo 1 >file1 &&
|
||||
git add -u &&
|
||||
test_tick &&
|
||||
git commit -m "squash! third" &&
|
||||
echo 4 >file4 &&
|
||||
git add file4 &&
|
||||
test_tick &&
|
||||
git commit -m "third commit" &&
|
||||
git tag final-presquash &&
|
||||
test_tick &&
|
||||
git rebase --autosquash -i HEAD~4 &&
|
||||
git log --oneline >actual &&
|
||||
test 5 = $(wc -l <actual) &&
|
||||
git diff --exit-code final-presquash &&
|
||||
test 0 = "$(git cat-file blob HEAD^^:file1)" &&
|
||||
test 1 = "$(git cat-file blob HEAD^:file1)" &&
|
||||
test 1 = $(git cat-file commit HEAD | grep third | wc -l) &&
|
||||
test 1 = $(git cat-file commit HEAD^ | grep third | wc -l)
|
||||
'
|
||||
test_expect_success 'auto squash that matches a sha1' '
|
||||
git reset --hard base &&
|
||||
echo 1 >file1 &&
|
||||
git add -u &&
|
||||
test_tick &&
|
||||
git commit -m "squash! $(git rev-parse --short HEAD^)" &&
|
||||
git tag final-shasquash &&
|
||||
test_tick &&
|
||||
git rebase --autosquash -i HEAD^^^ &&
|
||||
git log --oneline >actual &&
|
||||
test 3 = $(wc -l <actual) &&
|
||||
git diff --exit-code final-shasquash &&
|
||||
test 1 = "$(git cat-file blob HEAD^:file1)" &&
|
||||
test 1 = $(git cat-file commit HEAD^ | grep squash | wc -l)
|
||||
'
|
||||
|
||||
test_expect_success 'auto squash that matches longer sha1' '
|
||||
git reset --hard base &&
|
||||
echo 1 >file1 &&
|
||||
git add -u &&
|
||||
test_tick &&
|
||||
git commit -m "squash! $(git rev-parse --short=11 HEAD^)" &&
|
||||
git tag final-longshasquash &&
|
||||
test_tick &&
|
||||
git rebase --autosquash -i HEAD^^^ &&
|
||||
git log --oneline >actual &&
|
||||
test 3 = $(wc -l <actual) &&
|
||||
git diff --exit-code final-longshasquash &&
|
||||
test 1 = "$(git cat-file blob HEAD^:file1)" &&
|
||||
test 1 = $(git cat-file commit HEAD^ | grep squash | wc -l)
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Reference in New Issue
Block a user