2008-03-01 06:08:47 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='git rebase --abort tests'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2008-05-04 13:37:51 +08:00
|
|
|
### Test that we handle space characters properly
|
|
|
|
work_dir="$(pwd)/test dir"
|
|
|
|
|
2008-03-01 06:08:47 +08:00
|
|
|
test_expect_success setup '
|
2008-05-04 13:37:51 +08:00
|
|
|
mkdir -p "$work_dir" &&
|
|
|
|
cd "$work_dir" &&
|
|
|
|
git init &&
|
2008-03-01 06:08:47 +08: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 19:12:13 +08:00
|
|
|
testrebase() {
|
|
|
|
type=$1
|
|
|
|
dotest=$2
|
2008-03-01 06:08:47 +08:00
|
|
|
|
2008-03-01 19:12:13 +08:00
|
|
|
test_expect_success "rebase$type --abort" '
|
2008-05-04 13:37:51 +08:00
|
|
|
cd "$work_dir" &&
|
2008-03-01 19:12:13 +08:00
|
|
|
# Clean up the state from the previous one
|
2008-05-04 13:37:51 +08:00
|
|
|
git reset --hard pre-rebase &&
|
|
|
|
test_must_fail git rebase$type master &&
|
2010-08-10 23:17:52 +08:00
|
|
|
test_path_is_dir "$dotest" &&
|
2008-03-01 19:12:13 +08:00
|
|
|
git rebase --abort &&
|
|
|
|
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
|
2008-05-04 13:37:51 +08:00
|
|
|
test ! -d "$dotest"
|
2008-03-01 19:12:13 +08:00
|
|
|
'
|
2008-03-01 06:08:47 +08:00
|
|
|
|
2008-03-01 19:12:13 +08:00
|
|
|
test_expect_success "rebase$type --abort after --skip" '
|
2008-05-04 13:37:51 +08:00
|
|
|
cd "$work_dir" &&
|
2008-03-01 19:12:13 +08:00
|
|
|
# Clean up the state from the previous one
|
2008-05-04 13:37:51 +08:00
|
|
|
git reset --hard pre-rebase &&
|
|
|
|
test_must_fail git rebase$type master &&
|
2010-08-10 23:17:52 +08:00
|
|
|
test_path_is_dir "$dotest" &&
|
2008-03-01 19:12:13 +08:00
|
|
|
test_must_fail git rebase --skip &&
|
|
|
|
test $(git rev-parse HEAD) = $(git rev-parse master) &&
|
2008-09-03 16:59:27 +08:00
|
|
|
git rebase --abort &&
|
2008-03-01 19:12:13 +08:00
|
|
|
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
|
2008-05-04 13:37:51 +08:00
|
|
|
test ! -d "$dotest"
|
2008-03-01 19:12:13 +08:00
|
|
|
'
|
2008-03-01 06:08:47 +08:00
|
|
|
|
2008-03-01 19:12:13 +08:00
|
|
|
test_expect_success "rebase$type --abort after --continue" '
|
2008-05-04 13:37:51 +08:00
|
|
|
cd "$work_dir" &&
|
2008-03-01 19:12:13 +08:00
|
|
|
# Clean up the state from the previous one
|
2008-05-04 13:37:51 +08:00
|
|
|
git reset --hard pre-rebase &&
|
|
|
|
test_must_fail git rebase$type master &&
|
2010-08-10 23:17:52 +08:00
|
|
|
test_path_is_dir "$dotest" &&
|
2008-03-01 19:12:13 +08: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 13:37:51 +08:00
|
|
|
test ! -d "$dotest"
|
2008-03-01 19:12:13 +08:00
|
|
|
'
|
2010-11-21 19:11:21 +08: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-07 02:43:36 +08: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 19:12:13 +08:00
|
|
|
}
|
2008-03-01 06:08:47 +08:00
|
|
|
|
2008-07-21 18:51:02 +08:00
|
|
|
testrebase "" .git/rebase-apply
|
2008-07-16 09:33:44 +08:00
|
|
|
testrebase " --merge" .git/rebase-merge
|
2008-03-01 06:08:47 +08:00
|
|
|
|
|
|
|
test_done
|