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