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