t / t3415-rebase-autosquash.shon commit Merge branch 'fn/maint-mkdtemp-compat' into maint (990169b)
   1#!/bin/sh
   2
   3test_description='auto squash'
   4
   5. ./test-lib.sh
   6
   7test_expect_success setup '
   8        echo 0 >file0 &&
   9        git add . &&
  10        test_tick &&
  11        git commit -m "initial commit" &&
  12        echo 0 >file1 &&
  13        echo 2 >file2 &&
  14        git add . &&
  15        test_tick &&
  16        git commit -m "first commit" &&
  17        echo 3 >file3 &&
  18        git add . &&
  19        test_tick &&
  20        git commit -m "second commit" &&
  21        git tag base
  22'
  23
  24test_expect_success 'auto fixup' '
  25        git reset --hard base &&
  26        echo 1 >file1 &&
  27        git add -u &&
  28        test_tick &&
  29        git commit -m "fixup! first"
  30
  31        git tag final-fixup &&
  32        test_tick &&
  33        git rebase --autosquash -i HEAD^^^ &&
  34        git log --oneline >actual &&
  35        test 3 = $(wc -l <actual) &&
  36        git diff --exit-code final-fixup &&
  37        test 1 = "$(git cat-file blob HEAD^:file1)" &&
  38        test 1 = $(git cat-file commit HEAD^ | grep first | wc -l)
  39'
  40
  41test_expect_success 'auto squash' '
  42        git reset --hard base &&
  43        echo 1 >file1 &&
  44        git add -u &&
  45        test_tick &&
  46        git commit -m "squash! first"
  47
  48        git tag final-squash &&
  49        test_tick &&
  50        git rebase --autosquash -i HEAD^^^ &&
  51        git log --oneline >actual &&
  52        test 3 = $(wc -l <actual) &&
  53        git diff --exit-code final-squash &&
  54        test 1 = "$(git cat-file blob HEAD^:file1)" &&
  55        test 2 = $(git cat-file commit HEAD^ | grep first | wc -l)
  56'
  57
  58test_expect_success 'misspelled auto squash' '
  59        git reset --hard base &&
  60        echo 1 >file1 &&
  61        git add -u &&
  62        test_tick &&
  63        git commit -m "squash! forst"
  64        git tag final-missquash &&
  65        test_tick &&
  66        git rebase --autosquash -i HEAD^^^ &&
  67        git log --oneline >actual &&
  68        test 4 = $(wc -l <actual) &&
  69        git diff --exit-code final-missquash &&
  70        test 0 = $(git rev-list final-missquash...HEAD | wc -l)
  71'
  72
  73test_done