t / t6037-merge-ours-theirs.shon commit Merge branch 'jn/make-assembly-in-right-directory' into maint (dbf64e1)
   1#!/bin/sh
   2
   3test_description='Merge-recursive ours and theirs variants'
   4. ./test-lib.sh
   5
   6test_expect_success setup '
   7        for i in 1 2 3 4 5 6 7 8 9
   8        do
   9                echo "$i"
  10        done >file &&
  11        git add file &&
  12        cp file elif &&
  13        git commit -m initial &&
  14
  15        sed -e "s/1/one/" -e "s/9/nine/" >file <elif &&
  16        git commit -a -m ours &&
  17
  18        git checkout -b side HEAD^ &&
  19
  20        sed -e "s/9/nueve/" >file <elif &&
  21        git commit -a -m theirs &&
  22
  23        git checkout master^0
  24'
  25
  26test_expect_success 'plain recursive - should conflict' '
  27        git reset --hard master &&
  28        test_must_fail git merge -s recursive side &&
  29        grep nine file &&
  30        grep nueve file &&
  31        ! grep 9 file &&
  32        grep one file &&
  33        ! grep 1 file
  34'
  35
  36test_expect_success 'recursive favouring theirs' '
  37        git reset --hard master &&
  38        git merge -s recursive -Xtheirs side &&
  39        ! grep nine file &&
  40        grep nueve file &&
  41        ! grep 9 file &&
  42        grep one file &&
  43        ! grep 1 file
  44'
  45
  46test_expect_success 'recursive favouring ours' '
  47        git reset --hard master &&
  48        git merge -s recursive -X ours side &&
  49        grep nine file &&
  50        ! grep nueve file &&
  51        ! grep 9 file &&
  52        grep one file &&
  53        ! grep 1 file
  54'
  55
  56test_expect_success 'pull with -X' '
  57        git reset --hard master && git pull -s recursive -Xours . side &&
  58        git reset --hard master && git pull -s recursive -X ours . side &&
  59        git reset --hard master && git pull -s recursive -Xtheirs . side &&
  60        git reset --hard master && git pull -s recursive -X theirs . side &&
  61        git reset --hard master && test_must_fail git pull -s recursive -X bork . side
  62'
  63
  64test_done