t / t3033-merge-toplevel.shon commit userdiff: add a builtin pattern for dts files (3c81760)
   1#!/bin/sh
   2
   3test_description='"git merge" top-level frontend'
   4
   5. ./test-lib.sh
   6
   7t3033_reset () {
   8        git checkout -B master two &&
   9        git branch -f left three &&
  10        git branch -f right four
  11}
  12
  13test_expect_success setup '
  14        test_commit one &&
  15        git branch left &&
  16        git branch right &&
  17        test_commit two &&
  18        git checkout left &&
  19        test_commit three &&
  20        git checkout right &&
  21        test_commit four &&
  22        git checkout --orphan newroot &&
  23        test_commit five &&
  24        git checkout master
  25'
  26
  27# Local branches
  28
  29test_expect_success 'merge an octopus into void' '
  30        t3033_reset &&
  31        git checkout --orphan test &&
  32        git rm -fr . &&
  33        test_must_fail git merge left right &&
  34        test_must_fail git rev-parse --verify HEAD &&
  35        git diff --quiet &&
  36        test_must_fail git rev-parse HEAD
  37'
  38
  39test_expect_success 'merge an octopus, fast-forward (ff)' '
  40        t3033_reset &&
  41        git reset --hard one &&
  42        git merge left right &&
  43        # one is ancestor of three (left) and four (right)
  44        test_must_fail git rev-parse --verify HEAD^3 &&
  45        git rev-parse HEAD^1 HEAD^2 | sort >actual &&
  46        git rev-parse three four | sort >expect &&
  47        test_cmp expect actual
  48'
  49
  50test_expect_success 'merge octopus, non-fast-forward (ff)' '
  51        t3033_reset &&
  52        git reset --hard one &&
  53        git merge --no-ff left right &&
  54        # one is ancestor of three (left) and four (right)
  55        test_must_fail git rev-parse --verify HEAD^4 &&
  56        git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
  57        git rev-parse one three four | sort >expect &&
  58        test_cmp expect actual
  59'
  60
  61test_expect_success 'merge octopus, fast-forward (does not ff)' '
  62        t3033_reset &&
  63        git merge left right &&
  64        # two (master) is not an ancestor of three (left) and four (right)
  65        test_must_fail git rev-parse --verify HEAD^4 &&
  66        git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
  67        git rev-parse two three four | sort >expect &&
  68        test_cmp expect actual
  69'
  70
  71test_expect_success 'merge octopus, non-fast-forward' '
  72        t3033_reset &&
  73        git merge --no-ff left right &&
  74        test_must_fail git rev-parse --verify HEAD^4 &&
  75        git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
  76        git rev-parse two three four | sort >expect &&
  77        test_cmp expect actual
  78'
  79
  80# The same set with FETCH_HEAD
  81
  82test_expect_success 'merge FETCH_HEAD octopus into void' '
  83        t3033_reset &&
  84        git checkout --orphan test &&
  85        git rm -fr . &&
  86        git fetch . left right &&
  87        test_must_fail git merge FETCH_HEAD &&
  88        test_must_fail git rev-parse --verify HEAD &&
  89        git diff --quiet &&
  90        test_must_fail git rev-parse HEAD
  91'
  92
  93test_expect_success 'merge FETCH_HEAD octopus fast-forward (ff)' '
  94        t3033_reset &&
  95        git reset --hard one &&
  96        git fetch . left right &&
  97        git merge FETCH_HEAD &&
  98        # one is ancestor of three (left) and four (right)
  99        test_must_fail git rev-parse --verify HEAD^3 &&
 100        git rev-parse HEAD^1 HEAD^2 | sort >actual &&
 101        git rev-parse three four | sort >expect &&
 102        test_cmp expect actual
 103'
 104
 105test_expect_success 'merge FETCH_HEAD octopus non-fast-forward (ff)' '
 106        t3033_reset &&
 107        git reset --hard one &&
 108        git fetch . left right &&
 109        git merge --no-ff FETCH_HEAD &&
 110        # one is ancestor of three (left) and four (right)
 111        test_must_fail git rev-parse --verify HEAD^4 &&
 112        git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
 113        git rev-parse one three four | sort >expect &&
 114        test_cmp expect actual
 115'
 116
 117test_expect_success 'merge FETCH_HEAD octopus fast-forward (does not ff)' '
 118        t3033_reset &&
 119        git fetch . left right &&
 120        git merge FETCH_HEAD &&
 121        # two (master) is not an ancestor of three (left) and four (right)
 122        test_must_fail git rev-parse --verify HEAD^4 &&
 123        git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
 124        git rev-parse two three four | sort >expect &&
 125        test_cmp expect actual
 126'
 127
 128test_expect_success 'merge FETCH_HEAD octopus non-fast-forward' '
 129        t3033_reset &&
 130        git fetch . left right &&
 131        git merge --no-ff FETCH_HEAD &&
 132        test_must_fail git rev-parse --verify HEAD^4 &&
 133        git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
 134        git rev-parse two three four | sort >expect &&
 135        test_cmp expect actual
 136'
 137
 138# two-project merge
 139test_expect_success 'refuse two-project merge by default' '
 140        t3033_reset &&
 141        git reset --hard four &&
 142        test_must_fail git merge five
 143'
 144
 145test_expect_success 'two-project merge with --allow-unrelated-histories' '
 146        t3033_reset &&
 147        git reset --hard four &&
 148        git merge --allow-unrelated-histories five &&
 149        git diff --exit-code five
 150'
 151
 152test_done