1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-29 01:36:13 +02:00

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>
This commit is contained in:
Pat Notz 2010-11-02 13:59:10 -06:00 committed by Junio C Hamano
parent d71b8ba7c9
commit b1a6c0a96f
3 changed files with 83 additions and 2 deletions

View File

@ -14,6 +14,7 @@ test_expect_success setup '
git add . &&
test_tick &&
git commit -m "first commit" &&
git tag first-commit &&
echo 3 >file3 &&
git add . &&
test_tick &&
@ -21,7 +22,7 @@ test_expect_success setup '
git tag base
'
test_auto_fixup() {
test_auto_fixup () {
git reset --hard base &&
echo 1 >file1 &&
git add -u &&
@ -50,7 +51,7 @@ test_expect_success 'auto fixup (config)' '
test_must_fail test_auto_fixup final-fixup-config-false
'
test_auto_squash() {
test_auto_squash () {
git reset --hard base &&
echo 1 >file1 &&
git add -u &&
@ -94,4 +95,24 @@ test_expect_success 'misspelled auto squash' '
test 0 = $(git rev-list final-missquash...HEAD | wc -l)
'
test_auto_commit_flags () {
git reset --hard base &&
echo 1 >file1 &&
git add -u &&
test_tick &&
git commit --$1 first-commit &&
git tag final-commit-$1 &&
test_tick &&
git rebase --autosquash -i HEAD^^^ &&
git log --oneline >actual &&
test 3 = $(wc -l <actual) &&
git diff --exit-code final-commit-$1 &&
test 1 = "$(git cat-file blob HEAD^:file1)" &&
test $2 = $(git cat-file commit HEAD^ | grep first | wc -l)
}
test_expect_success 'use commit --fixup' '
test_auto_commit_flags fixup 1
'
test_done

View File

@ -133,4 +133,31 @@ do
'
done
test_commit_autosquash_flags () {
H=$1
flag=$2
test_expect_success "commit --$flag with $H encoding" '
git config i18n.commitencoding $H &&
git checkout -b $H-$flag C0 &&
echo $H >>F &&
git commit -a -F "$TEST_DIRECTORY"/t3900/$H.txt &&
test_tick &&
echo intermediate stuff >>G &&
git add G &&
git commit -a -m "intermediate commit" &&
test_tick &&
echo $H $flag >>F &&
git commit -a --$flag HEAD~1 $3 &&
E=$(git cat-file commit '$H-$flag' |
sed -ne "s/^encoding //p") &&
test "z$E" = "z$H" &&
git config --unset-all i18n.commitencoding &&
git rebase --autosquash -i HEAD^^^ &&
git log --oneline >actual &&
test 3 = $(wc -l <actual)
'
}
test_commit_autosquash_flags eucJP fixup
test_done

View File

@ -215,4 +215,37 @@ test_expect_success 'Commit a message with --allow-empty-message' '
commit_msg_is "hello there"
'
commit_for_rebase_autosquash_setup () {
echo "first content line" >>foo &&
git add foo &&
cat >log <<EOF &&
target message subject line
target message body line 1
target message body line 2
EOF
git commit -F log &&
echo "second content line" >>foo &&
git add foo &&
git commit -m "intermediate commit" &&
echo "third content line" >>foo &&
git add foo
}
test_expect_success 'commit --fixup provides correct one-line commit message' '
commit_for_rebase_autosquash_setup &&
git commit --fixup HEAD~1 &&
commit_msg_is "fixup! target message subject line"
'
test_expect_success 'invalid message options when using --fixup' '
echo changes >>foo &&
echo "message" >log &&
git add foo &&
test_must_fail git commit --fixup HEAD~1 -C HEAD~2 &&
test_must_fail git commit --fixup HEAD~1 -c HEAD~2 &&
test_must_fail git commit --fixup HEAD~1 -m "cmdline message" &&
test_must_fail git commit --fixup HEAD~1 -F log
'
test_done