2008-03-01 01:08:47 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='git rebase --abort tests'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2008-05-04 09:37:51 +04:00
|
|
|
### Test that we handle space characters properly
|
|
|
|
work_dir="$(pwd)/test dir"
|
|
|
|
|
2008-03-01 01:08:47 +03:00
|
|
|
test_expect_success setup '
|
2008-05-04 09:37:51 +04:00
|
|
|
mkdir -p "$work_dir" &&
|
|
|
|
cd "$work_dir" &&
|
|
|
|
git init &&
|
2008-03-01 01:08:47 +03:00
|
|
|
echo a > a &&
|
|
|
|
git add a &&
|
|
|
|
git commit -m a &&
|
|
|
|
git branch to-rebase &&
|
|
|
|
|
|
|
|
echo b > a &&
|
|
|
|
git commit -a -m b &&
|
|
|
|
echo c > a &&
|
|
|
|
git commit -a -m c &&
|
|
|
|
|
|
|
|
git checkout to-rebase &&
|
|
|
|
echo d > a &&
|
|
|
|
git commit -a -m "merge should fail on this" &&
|
|
|
|
echo e > a &&
|
|
|
|
git commit -a -m "merge should fail on this, too" &&
|
|
|
|
git branch pre-rebase
|
|
|
|
'
|
|
|
|
|
2008-03-01 14:12:13 +03:00
|
|
|
testrebase() {
|
|
|
|
type=$1
|
|
|
|
dotest=$2
|
2008-03-01 01:08:47 +03:00
|
|
|
|
2008-03-01 14:12:13 +03:00
|
|
|
test_expect_success "rebase$type --abort" '
|
2008-05-04 09:37:51 +04:00
|
|
|
cd "$work_dir" &&
|
2008-03-01 14:12:13 +03:00
|
|
|
# Clean up the state from the previous one
|
2008-05-04 09:37:51 +04:00
|
|
|
git reset --hard pre-rebase &&
|
|
|
|
test_must_fail git rebase$type master &&
|
2010-08-10 19:17:52 +04:00
|
|
|
test_path_is_dir "$dotest" &&
|
2008-03-01 14:12:13 +03:00
|
|
|
git rebase --abort &&
|
|
|
|
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
|
2008-05-04 09:37:51 +04:00
|
|
|
test ! -d "$dotest"
|
2008-03-01 14:12:13 +03:00
|
|
|
'
|
2008-03-01 01:08:47 +03:00
|
|
|
|
2008-03-01 14:12:13 +03:00
|
|
|
test_expect_success "rebase$type --abort after --skip" '
|
2008-05-04 09:37:51 +04:00
|
|
|
cd "$work_dir" &&
|
2008-03-01 14:12:13 +03:00
|
|
|
# Clean up the state from the previous one
|
2008-05-04 09:37:51 +04:00
|
|
|
git reset --hard pre-rebase &&
|
|
|
|
test_must_fail git rebase$type master &&
|
2010-08-10 19:17:52 +04:00
|
|
|
test_path_is_dir "$dotest" &&
|
2008-03-01 14:12:13 +03:00
|
|
|
test_must_fail git rebase --skip &&
|
|
|
|
test $(git rev-parse HEAD) = $(git rev-parse master) &&
|
2008-09-03 12:59:27 +04:00
|
|
|
git rebase --abort &&
|
2008-03-01 14:12:13 +03:00
|
|
|
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
|
2008-05-04 09:37:51 +04:00
|
|
|
test ! -d "$dotest"
|
2008-03-01 14:12:13 +03:00
|
|
|
'
|
2008-03-01 01:08:47 +03:00
|
|
|
|
2008-03-01 14:12:13 +03:00
|
|
|
test_expect_success "rebase$type --abort after --continue" '
|
2008-05-04 09:37:51 +04:00
|
|
|
cd "$work_dir" &&
|
2008-03-01 14:12:13 +03:00
|
|
|
# Clean up the state from the previous one
|
2008-05-04 09:37:51 +04:00
|
|
|
git reset --hard pre-rebase &&
|
|
|
|
test_must_fail git rebase$type master &&
|
2010-08-10 19:17:52 +04:00
|
|
|
test_path_is_dir "$dotest" &&
|
2008-03-01 14:12:13 +03:00
|
|
|
echo c > a &&
|
|
|
|
echo d >> a &&
|
|
|
|
git add a &&
|
|
|
|
test_must_fail git rebase --continue &&
|
|
|
|
test $(git rev-parse HEAD) != $(git rev-parse master) &&
|
|
|
|
git rebase --abort &&
|
|
|
|
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
|
2008-05-04 09:37:51 +04:00
|
|
|
test ! -d "$dotest"
|
2008-03-01 14:12:13 +03:00
|
|
|
'
|
2010-11-21 14:11:21 +03:00
|
|
|
|
|
|
|
test_expect_success "rebase$type --abort does not update reflog" '
|
|
|
|
cd "$work_dir" &&
|
|
|
|
# Clean up the state from the previous one
|
|
|
|
git reset --hard pre-rebase &&
|
|
|
|
git reflog show to-rebase > reflog_before &&
|
|
|
|
test_must_fail git rebase$type master &&
|
|
|
|
git rebase --abort &&
|
|
|
|
git reflog show to-rebase > reflog_after &&
|
|
|
|
test_cmp reflog_before reflog_after &&
|
|
|
|
rm reflog_before reflog_after
|
|
|
|
'
|
2011-02-06 21:43:36 +03:00
|
|
|
|
|
|
|
test_expect_success 'rebase --abort can not be used with other options' '
|
|
|
|
cd "$work_dir" &&
|
|
|
|
# Clean up the state from the previous one
|
|
|
|
git reset --hard pre-rebase &&
|
|
|
|
test_must_fail git rebase$type master &&
|
|
|
|
test_must_fail git rebase -v --abort &&
|
|
|
|
test_must_fail git rebase --abort -v &&
|
|
|
|
git rebase --abort
|
|
|
|
'
|
2008-03-01 14:12:13 +03:00
|
|
|
}
|
2008-03-01 01:08:47 +03:00
|
|
|
|
2008-07-21 14:51:02 +04:00
|
|
|
testrebase "" .git/rebase-apply
|
2008-07-16 05:33:44 +04:00
|
|
|
testrebase " --merge" .git/rebase-merge
|
2008-03-01 01:08:47 +03:00
|
|
|
|
|
|
|
test_done
|