summaryrefslogtreecommitdiff
path: root/t/t3400-rebase.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t3400-rebase.sh')
-rwxr-xr-xt/t3400-rebase.sh60
1 files changed, 51 insertions, 9 deletions
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 221b35f..40d2975 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -143,11 +143,11 @@ test_expect_success 'setup: recover' '
test_expect_success 'Show verbose error when HEAD could not be detached' '
>B &&
+ test_when_finished "rm -f B" &&
test_must_fail git rebase topic 2>output.err >output.out &&
test_i18ngrep "The following untracked working tree files would be overwritten by checkout:" output.err &&
test_i18ngrep B output.err
'
-rm -f B
test_expect_success 'fail when upstream arg is missing and not on branch' '
git checkout topic &&
@@ -165,19 +165,37 @@ test_expect_success 'rebase works with format.useAutoBase' '
git rebase master
'
-test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg' '
+test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg (--merge)' '
git checkout -b default-base master &&
git checkout -b default topic &&
git config branch.default.remote . &&
git config branch.default.merge refs/heads/default-base &&
- git rebase &&
+ git rebase --merge &&
git rev-parse --verify default-base >expect &&
git rev-parse default~1 >actual &&
test_cmp expect actual &&
git checkout default-base &&
git reset --hard HEAD^ &&
git checkout default &&
- git rebase &&
+ git rebase --merge &&
+ git rev-parse --verify default-base >expect &&
+ git rev-parse default~1 >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg (--apply)' '
+ git checkout -B default-base master &&
+ git checkout -B default topic &&
+ git config branch.default.remote . &&
+ git config branch.default.merge refs/heads/default-base &&
+ git rebase --apply &&
+ git rev-parse --verify default-base >expect &&
+ git rev-parse default~1 >actual &&
+ test_cmp expect actual &&
+ git checkout default-base &&
+ git reset --hard HEAD^ &&
+ git checkout default &&
+ git rebase --apply &&
git rev-parse --verify default-base >expect &&
git rev-parse default~1 >actual &&
test_cmp expect actual
@@ -206,9 +224,15 @@ test_expect_success 'cherry-picked commits and fork-point work together' '
test_cmp expect D
'
-test_expect_success 'rebase -q is quiet' '
+test_expect_success 'rebase --apply -q is quiet' '
git checkout -b quiet topic &&
- git rebase -q master >output.out 2>&1 &&
+ git rebase --apply -q master >output.out 2>&1 &&
+ test_must_be_empty output.out
+'
+
+test_expect_success 'rebase --merge -q is quiet' '
+ git checkout -B quiet topic &&
+ git rebase --merge -q master >output.out 2>&1 &&
test_must_be_empty output.out
'
@@ -291,7 +315,7 @@ EOF
test_cmp From_.msg out
'
-test_expect_success 'rebase --am and --show-current-patch' '
+test_expect_success 'rebase --apply and --show-current-patch' '
test_create_repo conflict-apply &&
(
cd conflict-apply &&
@@ -301,13 +325,13 @@ test_expect_success 'rebase --am and --show-current-patch' '
echo two >>init.t &&
git commit -a -m two &&
git tag two &&
- test_must_fail git rebase -f --onto init HEAD^ &&
+ test_must_fail git rebase --apply -f --onto init HEAD^ &&
GIT_TRACE=1 git rebase --show-current-patch >/dev/null 2>stderr &&
grep "show.*$(git rev-parse two)" stderr
)
'
-test_expect_success 'rebase --am and .gitattributes' '
+test_expect_success 'rebase --apply and .gitattributes' '
test_create_repo attributes &&
(
cd attributes &&
@@ -377,4 +401,22 @@ test_expect_success 'rebase -c rebase.useBuiltin=false warning' '
test_must_be_empty err
'
+test_expect_success 'switch to branch checked out here' '
+ git checkout master &&
+ git rebase master master
+'
+
+test_expect_success 'switch to branch not checked out' '
+ git checkout master &&
+ git branch other &&
+ git rebase master other
+'
+
+test_expect_success 'refuse to switch to branch checked out elsewhere' '
+ git checkout master &&
+ git worktree add wt &&
+ test_must_fail git -C wt rebase master master 2>err &&
+ test_i18ngrep "already checked out" err
+'
+
test_done