t / t3402-rebase-merge.shon commit Merge branch 'jk/push-quiet' (56b36b8)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006 Junio C Hamano
   4#
   5
   6test_description='git rebase --merge test'
   7
   8. ./test-lib.sh
   9
  10T="A quick brown fox
  11jumps over the lazy dog."
  12for i in 1 2 3 4 5 6 7 8 9 10
  13do
  14        echo "$i $T"
  15done >original
  16
  17test_expect_success setup '
  18        git add original &&
  19        git commit -m"initial" &&
  20        git branch side &&
  21        echo "11 $T" >>original &&
  22        git commit -a -m"master updates a bit." &&
  23
  24        echo "12 $T" >>original &&
  25        git commit -a -m"master updates a bit more." &&
  26
  27        git checkout side &&
  28        (echo "0 $T" ; cat original) >renamed &&
  29        git add renamed &&
  30        git update-index --force-remove original &&
  31        git commit -a -m"side renames and edits." &&
  32
  33        tr "[a-z]" "[A-Z]" <original >newfile &&
  34        git add newfile &&
  35        git commit -a -m"side edits further." &&
  36
  37        tr "[a-m]" "[A-M]" <original >newfile &&
  38        rm -f original &&
  39        git commit -a -m"side edits once again." &&
  40
  41        git branch test-rebase side &&
  42        git branch test-rebase-pick side &&
  43        git branch test-reference-pick side &&
  44        git checkout -b test-merge side
  45'
  46
  47test_expect_success 'reference merge' '
  48        git merge -s recursive "reference merge" HEAD master
  49'
  50
  51PRE_REBASE=$(git rev-parse test-rebase)
  52test_expect_success rebase '
  53        git checkout test-rebase &&
  54        GIT_TRACE=1 git rebase --merge master
  55'
  56
  57test_expect_success 'test-rebase@{1} is pre rebase' '
  58        test $PRE_REBASE = $(git rev-parse test-rebase@{1})
  59'
  60
  61test_expect_success 'merge and rebase should match' '
  62        git diff-tree -r test-rebase test-merge >difference &&
  63        if test -s difference
  64        then
  65                cat difference
  66                (exit 1)
  67        else
  68                echo happy
  69        fi
  70'
  71
  72test_expect_success 'rebase the other way' '
  73        git reset --hard master &&
  74        git rebase --merge side
  75'
  76
  77test_expect_success 'merge and rebase should match' '
  78        git diff-tree -r test-rebase test-merge >difference &&
  79        if test -s difference
  80        then
  81                cat difference
  82                (exit 1)
  83        else
  84                echo happy
  85        fi
  86'
  87
  88test_expect_success 'picking rebase' '
  89        git reset --hard side &&
  90        git rebase --merge --onto master side^^ &&
  91        mb=$(git merge-base master HEAD) &&
  92        if test "$mb" = "$(git rev-parse master)"
  93        then
  94                echo happy
  95        else
  96                git show-branch
  97                (exit 1)
  98        fi &&
  99        f=$(git diff-tree --name-only HEAD^ HEAD) &&
 100        g=$(git diff-tree --name-only HEAD^^ HEAD^) &&
 101        case "$f,$g" in
 102        newfile,newfile)
 103                echo happy ;;
 104        *)
 105                echo "$f"
 106                echo "$g"
 107                (exit 1)
 108        esac
 109'
 110
 111test_done