t / t3407-rebase-abort.shon commit Merge branch 'maint' (d9f39d9)
   1#!/bin/sh
   2
   3test_description='git rebase --abort tests'
   4
   5. ./test-lib.sh
   6
   7test_expect_success setup '
   8        echo a > a &&
   9        git add a &&
  10        git commit -m a &&
  11        git branch to-rebase &&
  12
  13        echo b > a &&
  14        git commit -a -m b &&
  15        echo c > a &&
  16        git commit -a -m c &&
  17
  18        git checkout to-rebase &&
  19        echo d > a &&
  20        git commit -a -m "merge should fail on this" &&
  21        echo e > a &&
  22        git commit -a -m "merge should fail on this, too" &&
  23        git branch pre-rebase
  24'
  25
  26testrebase() {
  27        type=$1
  28        dotest=$2
  29
  30        test_expect_success "rebase$type --abort" '
  31                # Clean up the state from the previous one
  32                git reset --hard pre-rebase
  33                test_must_fail git rebase'"$type"' master &&
  34                test -d '$dotest' &&
  35                git rebase --abort &&
  36                test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
  37                test ! -d '$dotest'
  38        '
  39
  40        test_expect_success "rebase$type --abort after --skip" '
  41                # Clean up the state from the previous one
  42                git reset --hard pre-rebase
  43                test_must_fail git rebase'"$type"' master &&
  44                test -d '$dotest' &&
  45                test_must_fail git rebase --skip &&
  46                test $(git rev-parse HEAD) = $(git rev-parse master) &&
  47                git-rebase --abort &&
  48                test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
  49                test ! -d '$dotest'
  50        '
  51
  52        test_expect_success "rebase$type --abort after --continue" '
  53                # Clean up the state from the previous one
  54                git reset --hard pre-rebase
  55                test_must_fail git rebase'"$type"' master &&
  56                test -d '$dotest' &&
  57                echo c > a &&
  58                echo d >> a &&
  59                git add a &&
  60                test_must_fail git rebase --continue &&
  61                test $(git rev-parse HEAD) != $(git rev-parse master) &&
  62                git rebase --abort &&
  63                test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
  64                test ! -d '$dotest'
  65        '
  66}
  67
  68testrebase "" .dotest
  69testrebase " --merge" .git/.dotest-merge
  70
  71test_done